Documentation
¶
Index ¶
- Constants
- Variables
- type APIKey
- type AuthPageOptions
- type AuthRequest
- type BandwidthRequest
- type BasicResponse
- type ByteSize
- type Client
- func (c *Client) ActivateUser(userID UID, active bool) (*TunResponse, error)
- func (c *Client) ActiveTunnels(details bool) (*TunResponse, error)
- func (c *Client) AllocatePort(tunID UID) (*PortResponse, error)
- func (c *Client) AllowDomains(userID UID, domains []string) (*BasicResponse, error)
- func (c *Client) Auth(key string) (*BasicResponse, error)
- func (c *Client) CreateToken(description string, active bool) (*TokenResponse, error)
- func (c *Client) CreateTunnel(userID, tunID UID, name, hostname string) (*TunResponse, error)
- func (c *Client) CreateUser(user *UserRequest) (*UserResponse, error)
- func (c *Client) DeleteHTTPSite(tunID UID, domains []string) (*BasicResponse, error)
- func (c *Client) DeleteToken(tokenID UID) (*BasicResponse, error)
- func (c *Client) DeleteUser(userID UID) (*BasicResponse, error)
- func (c *Client) EditToken(tokenID UID, description string, active bool) (*TokenResponse, error)
- func (c *Client) EditUser(user *UserRequest) (*BasicResponse, error)
- func (c *Client) GetTunPageResult(uid string) (*TunResponse, error)
- func (c *Client) GetUser(userID UID) (*UserResponse, error)
- func (c *Client) ImportUser(user *UserRequest) (*UserResponse, error)
- func (c *Client) Info() (*ServerInfoResponse, error)
- func (c *Client) KeepAlive() (*BasicResponse, error)
- func (c *Client) License() (*LicenseInfoResponse, error)
- func (c *Client) ListDomains(userID UID) (*DomainResponse, error)
- func (c *Client) ListUserTunnels(userID UID) (*TunResponse, error)
- func (c *Client) ListUsers() (*UserResponse, error)
- func (c *Client) Logout() (*BasicResponse, error)
- func (c *Client) OnlineTunnels(details bool) (*TunResponse, error)
- func (c *Client) Ping() (*BasicResponse, error)
- func (c *Client) PortRange() (*PortRangeResponse, error)
- func (c *Client) Ports() (*PortResponse, error)
- func (c *Client) ReleasePort(tunID UID, portNo int) (*BasicResponse, error)
- func (c *Client) RemoveDomains(userID UID, domains []string) (*BasicResponse, error)
- func (c *Client) RemovePortMapping(tunID UID, listenPorts []int) (*BasicResponse, error)
- func (c *Client) ResetDomains(userID UID) (*BasicResponse, error)
- func (c *Client) ResetPortForwarding(tunID UID, ports []int) (*BasicResponse, error)
- func (c *Client) SearchTunnels(input *SearchTunRequest) (*TunResponse, error)
- func (c *Client) SetBandwidthCap(userID UID, max int) (*BasicResponse, error)
- func (c *Client) SetInsecure(b bool) error
- func (c *Client) ShutdownTunnel(id UID) (*BasicResponse, error)
- func (c *Client) StopTunnel(tunID UID) (*BasicResponse, error)
- func (c *Client) Tokens() (*TokenResponse, error)
- func (c *Client) Tunnel(id UID) (*TunResponse, error)
- func (c *Client) TunnelAuth(id UID) (*TokenResponse, error)
- func (c *Client) TunnelConfig(id UID) (*TunConfigResponse, error)
- func (c *Client) Tunnels() (*TunResponse, error)
- func (c *Client) UpdateHTTPSite(tunID UID, sites []*Http) (*BasicResponse, error)
- func (c *Client) UpdatePortForwarding(tunID UID, ports []*Port) (*BasicResponse, error)
- func (c *Client) UpdatePortMapping(tunID UID, portmaps []*PortMap) (*BasicResponse, error)
- func (c *Client) UserExists(userID UID) (bool, error)
- type ConnMetric
- type CreateTokenRequest
- type CreateTunRequest
- type DataUsage
- type DomainLimits
- type DomainRequest
- type DomainResponse
- type EditTokenRequest
- type FwRule
- type FwRuleList
- type Http
- type HttpService
- type LicenseInfoResponse
- type Port
- type PortMap
- type PortRange
- type PortRangeResponse
- type PortResponse
- type PortService
- type PortTun
- type RemoveHTTPRequest
- type RemovePortMapRequest
- type ResetPortRequest
- type SearchTunRequest
- type ServerInfoResponse
- type TokenRequest
- type TokenResponse
- type TunConfig
- type TunConfigResponse
- type TunRequest
- type TunRespLink
- type TunResponse
- type TunService
- type Tunnel
- type UID
- func (this *UID) Bytes() []byte
- func (this *UID) Equals(uid UID) bool
- func (this *UID) EqualsHex(hex string) bool
- func (this *UID) IsZero() bool
- func (this *UID) MarshalJSON() ([]byte, error)
- func (this *UID) Set(s string) error
- func (this *UID) String() string
- func (this *UID) UnmarshalJSON(b []byte) error
- type UpdateHTTPRequest
- type UpdatePortMapRequest
- type UpdatePortRequest
- type User
- type UserRequest
- type UserResponse
Constants ¶
View Source
const ( ScopeUser uint16 = iota + 1 // used by pktriot for basic users ScopeAdmin // user by admins ScopeServer // used by servers ScopeRegistration // used by clients to get auth tokens )
View Source
const ( BasePath = "/api/admin/" AuthPath = "/api/admin/v1.0/auth" InfoPath = "/api/admin/v1.0/info" PingPath = "/api/admin/v1.0/ping" KeepAlivePath = "/api/admin/v1.0/keepalive" LogoutPath = "/api/admin/v1.0/logout" LicenseInfoPath = "/api/admin/v1.0/license/info" ListTokensPath = "/api/admin/v1.0/token/registration/list" CreateTokenPath = "/api/admin/v1.0/token/registration/create" EditTokenPath = "/api/admin/v1.0/token/registration/edit" DeleteTokenPath = "/api/admin/v1.0/token/registration/delete" ListTunsPath = "/api/admin/v1.0/tunnel/list" ListActiveTunsPath = "/api/admin/v1.0/tunnel/list/active" ListOnlineTunsPath = "/api/admin/v1.0/tunnel/list/online" SearchTunsPath = "/api/admin/v1.0/tunnel/search" TunPagePath = "/api/admin/v1.0/tunnel/page/" GetTunInfoPath = "/api/admin/v1.0/tunnel/info/" GetTunAuthPath = "/api/admin/v1.0/tunnel/auth/" GetTunConfigPath = "/api/admin/v1.0/tunnel/config/" ShutdownTunPath = "/api/admin/v1.0/tunnel/shutdown/" GetPortsPath = "/api/admin/v1.0/port/list" GetPortRangePath = "/api/admin/v1.0/port/range" )
View Source
const ( UpdateHTTPSitePath = "/api/admin/v1.0/tunnel/traffic/http/update/" DeleteHTTPSitePath = "/api/admin/v1.0/tunnel/traffic/http/remove/" AllocatePortPath = "/api/admin/v1.0/tunnel/traffic/tcp/allocate/" ReleasePortPath = "/api/admin/v1.0/tunnel/traffic/tcp/release/" UpdatePortForwardingPath = "/api/admin/v1.0/tunnel/traffic/tcp/update/" ResetPortForwardingPath = "/api/admin/v1.0/tunnel/traffic/tcp/reset/" UpdatePortMappingPath = "/api/admin/v1.0/tunnel/traffic/portmap/update/" RemovePortMappingPath = "/api/admin/v1.0/tunnel/traffic/portmap/remove/" )
View Source
const ( ListUsersPath = "/api/admin/v1.0/user/list" CreateUserPath = "/api/admin/v1.0/user/create" EditUserPath = "/api/admin/v1.0/user/edit" ImportUserPath = "/api/admin/v1.0/user/import" DeleteUserPath = "/api/admin/v1.0/user/delete/" ActivateUserPath = "/api/admin/v1.0/user/activate" GetUserPath = "/api/admin/v1.0/user/get/" CreateTunPath = "/api/admin/v1.0/user/tunnel/create" StopTunPath = "/api/admin/v1.0/user/tunnel/stop/" ListUserTunsPath = "/api/admin/v1.0/user/tunnel/list/" BandwidthCapPath = "/api/admin/v1.0/user/bandwidth/cap" AllowDomainPath = "/api/admin/v1.0/user/domain/allow" RemoveDomainPath = "/api/admin/v1.0/user/domain/remove" ListDomainPath = "/api/admin/v1.0/user/domain/list/" ResetDomainPath = "/api/admin/v1.0/user/domain/reset/" )
View Source
const ( TunInit uint16 = iota + 1 TunOnline TunOffline TunShutdown TunDeleted )
View Source
const ( TCP uint16 = iota + 1 UDP )
View Source
const ( // Values for ConnMetric.Service ServiceHttp uint16 = iota + 1 ServicePort )
View Source
const ( FwActionAllow = "allow" FwActionDrop = "drop" )
View Source
const (
UIDLen = 16
)
Variables ¶
View Source
var (
Debug = false
)
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
ID UID `json:"id"`
Created time.Time `json:"created"`
Modified time.Time `json:"modified"`
Active bool `json:"active"`
Description string `json:"description"`
Value string `json:"value"`
}
func (*APIKey) KeySnippet ¶
func (*APIKey) KeySnippetN ¶
type AuthPageOptions ¶
type AuthRequest ¶
type BandwidthRequest ¶
type BasicResponse ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithURL ¶
func (*Client) ActivateUser ¶
func (c *Client) ActivateUser(userID UID, active bool) (*TunResponse, error)
func (*Client) ActiveTunnels ¶
func (c *Client) ActiveTunnels(details bool) (*TunResponse, error)
func (*Client) AllocatePort ¶
func (c *Client) AllocatePort(tunID UID) (*PortResponse, error)
func (*Client) AllowDomains ¶
func (c *Client) AllowDomains(userID UID, domains []string) (*BasicResponse, error)
func (*Client) CreateToken ¶
func (c *Client) CreateToken(description string, active bool) (*TokenResponse, error)
func (*Client) CreateTunnel ¶
func (c *Client) CreateTunnel(userID, tunID UID, name, hostname string) (*TunResponse, error)
func (*Client) CreateUser ¶
func (c *Client) CreateUser(user *UserRequest) (*UserResponse, error)
func (*Client) DeleteHTTPSite ¶
func (c *Client) DeleteHTTPSite(tunID UID, domains []string) (*BasicResponse, error)
func (*Client) DeleteToken ¶
func (c *Client) DeleteToken(tokenID UID) (*BasicResponse, error)
func (*Client) DeleteUser ¶
func (c *Client) DeleteUser(userID UID) (*BasicResponse, error)
func (*Client) EditUser ¶
func (c *Client) EditUser(user *UserRequest) (*BasicResponse, error)
func (*Client) GetTunPageResult ¶
func (c *Client) GetTunPageResult(uid string) (*TunResponse, error)
func (*Client) ImportUser ¶
func (c *Client) ImportUser(user *UserRequest) (*UserResponse, error)
func (*Client) Info ¶
func (c *Client) Info() (*ServerInfoResponse, error)
func (*Client) KeepAlive ¶
func (c *Client) KeepAlive() (*BasicResponse, error)
func (*Client) License ¶
func (c *Client) License() (*LicenseInfoResponse, error)
func (*Client) ListDomains ¶
func (c *Client) ListDomains(userID UID) (*DomainResponse, error)
func (*Client) ListUserTunnels ¶
func (c *Client) ListUserTunnels(userID UID) (*TunResponse, error)
func (*Client) ListUsers ¶
func (c *Client) ListUsers() (*UserResponse, error)
func (*Client) Logout ¶
func (c *Client) Logout() (*BasicResponse, error)
func (*Client) OnlineTunnels ¶
func (c *Client) OnlineTunnels(details bool) (*TunResponse, error)
func (*Client) Ping ¶
func (c *Client) Ping() (*BasicResponse, error)
func (*Client) PortRange ¶
func (c *Client) PortRange() (*PortRangeResponse, error)
func (*Client) Ports ¶
func (c *Client) Ports() (*PortResponse, error)
func (*Client) ReleasePort ¶
func (c *Client) ReleasePort(tunID UID, portNo int) (*BasicResponse, error)
func (*Client) RemoveDomains ¶
func (c *Client) RemoveDomains(userID UID, domains []string) (*BasicResponse, error)
func (*Client) RemovePortMapping ¶
func (c *Client) RemovePortMapping(tunID UID, listenPorts []int) (*BasicResponse, error)
func (*Client) ResetDomains ¶
func (c *Client) ResetDomains(userID UID) (*BasicResponse, error)
func (*Client) ResetPortForwarding ¶
func (c *Client) ResetPortForwarding(tunID UID, ports []int) (*BasicResponse, error)
func (*Client) SearchTunnels ¶
func (c *Client) SearchTunnels(input *SearchTunRequest) (*TunResponse, error)
func (*Client) SetBandwidthCap ¶
func (c *Client) SetBandwidthCap(userID UID, max int) (*BasicResponse, error)
func (*Client) SetInsecure ¶
Passing a 'true' value will put this client in insecure-mode and accept any TLS certificate it receives from the server. Passing in false will perform proper verification of server and client-side certificates.
func (*Client) ShutdownTunnel ¶
func (c *Client) ShutdownTunnel(id UID) (*BasicResponse, error)
func (*Client) StopTunnel ¶
func (c *Client) StopTunnel(tunID UID) (*BasicResponse, error)
func (*Client) Tokens ¶
func (c *Client) Tokens() (*TokenResponse, error)
func (*Client) TunnelAuth ¶
func (c *Client) TunnelAuth(id UID) (*TokenResponse, error)
func (*Client) TunnelConfig ¶
func (c *Client) TunnelConfig(id UID) (*TunConfigResponse, error)
func (*Client) Tunnels ¶
func (c *Client) Tunnels() (*TunResponse, error)
func (*Client) UpdateHTTPSite ¶
func (c *Client) UpdateHTTPSite(tunID UID, sites []*Http) (*BasicResponse, error)
func (*Client) UpdatePortForwarding ¶
func (c *Client) UpdatePortForwarding(tunID UID, ports []*Port) (*BasicResponse, error)
func (*Client) UpdatePortMapping ¶
func (c *Client) UpdatePortMapping(tunID UID, portmaps []*PortMap) (*BasicResponse, error)
type ConnMetric ¶
type ConnMetric struct {
ID UID `json:"id"`
TunnelID UID `json:"tunID"`
ServiceID UID `json:"serviceID"` // unique ID for http/port service
Service uint16 `json:"service"` // indicates the service type
Address string `json:"address"` // ip address of client
Bandwidth int64 `json:"bandwidth"` // read + write
Established time.Time `json:"established"`
Closed time.Time `json:"closed"`
// Runtime field
ServerName string `json:"-"`
Port uint16 `json:"-"`
}
func (*ConnMetric) DataUsage ¶
func (cm *ConnMetric) DataUsage() string
type CreateTokenRequest ¶
type CreateTunRequest ¶
type DomainLimits ¶
type DomainLimits struct {
Allowed []string `json:"allowed"`
}
type DomainRequest ¶
type DomainResponse ¶
type EditTokenRequest ¶
type FwRuleList ¶
type FwRuleList []FwRule
type Http ¶
type Http struct {
Domain string `json:"domain,omitempty"` // domain request, e.g. example.com
Secure bool `json:"secure,omitempty"` // indicates http (80) and/or https (443)
Destination string `json:"destination,omitempty"` // forward to this host/address
Port int `json:"port,omitempty"` // port to forward on
TLS int `json:"tls,omitempty"` // port to forward to for TLS
UpstreamURL string `json:"upstreamURL,omitempty"` // upstream service addressed w/URL, e.g. http://127.0.0.1:8080
WebRoot string `json:"webRoot,omitempty"` // static document root to serve content
UseLetsEnc bool `json:"useLetsEnc,omitempty"` // use lets-encrypt for TLS certificates
CA string `json:"ca,omitempty"` // path to custom certificate authority
PrivateKey string `json:"privateKey,omitempty"` // path to custom privacy key
Firewall FwRuleList `json:"firewall,omitempty"` // list of firewall rules
Redirect bool `json:"redirect,omitempty"` // redirect to https
Password string `json:"password,omitempty"` // salted-hash of password to permit traffic
Requires2FA bool `json:"requires2FA,omitempty"` // indicates 2FA is used for authentication
BasicHTTPAuth string `json:"basicHttpAuth,omitempty"` // salted-hash of user:password (HTTP basic auth) to permit traffic
RedirectURL string `json:"redirectURL,omitempty"` // redirect all requests to URL
RewriteHost string `json:"rewriteHost,omitempty"` // modify host header with this value
InsecureUpstream bool `json:"insecureUpstream,omitempty"` // accept insecure TLS upstream servers
AuthPageOpts *AuthPageOptions `json:"authPageOpts,omitempty"` // customization options for authentication pages
}
type HttpService ¶
type LicenseInfoResponse ¶
type Port ¶
type Port struct {
Port int `json:"port,omitempty"` // port used by servers, e.g. 22001 (for ssh)
Destination string `json:"destination,omitempty"` // forward to this host/address
DstPort int `json:"dstPort,omitempty"` // port to forward to
Firewall FwRuleList `json:"firewall,omitempty"` // list of firewall rules
}
type PortMap ¶
type PortMap struct {
ListenPort int `json:"listenPort"`
DstPort int `json:"dstPort"`
Destination string `json:"destination"` // hostname, IP address
Transport string `json:"transport"` // tcp, udp
Label string `json:"label,omitempty"` // e.g. ssh, smtp, docker
HTTP bool `json:"http,omitempty"` // flag indicates http traffic
}
type PortRangeResponse ¶
type PortResponse ¶
type PortService ¶
type PortService struct {
ID UID `json:"id"`
UserID UID `json:"userID"`
TunID UID `json:"tunID"`
Active bool `json:"active"`
Available bool `json:"available"`
Protocol uint16 `json:"protocol"` // tcp/udp
Port int `json:"port"` // port used by servers, e.g. 22001 (for ssh)
Bandwidth DataUsage `json:"bandwidth"` // bandwidth stats
Label string `json:"label"` // e.g. ssh, smtp, docker
}
type RemoveHTTPRequest ¶
type RemoveHTTPRequest struct {
Domains []string `json:"domains"`
}
type RemovePortMapRequest ¶
type RemovePortMapRequest struct {
ListenPorts []int `json:"listenPorts"`
}
type ResetPortRequest ¶
type ResetPortRequest struct {
Ports []int `json:"ports"`
}
type SearchTunRequest ¶
type ServerInfoResponse ¶
type ServerInfoResponse struct {
Status bool `json:"status"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
Version string `json:"version"`
Uptime int `json:"uptime"`
Alerts int `json:"alerts"`
ActiveTuns int `json:"activeTuns"`
OnlineTuns int `json:"onlineTuns"`
MaxTuns int `json:"maxTuns"`
LicenseExpiration time.Time `json:"licenseExpires,omitempty"`
}
type TokenRequest ¶
type TokenRequest struct {
TokenID UID `json:"tokenID"`
}
type TokenResponse ¶
type TunConfig ¶
type TunConfig struct {
// Extra fields that exist in the client configuration so we can
// rebuild client configurations when required.
Hostname string `json:"hostname,omitempty"`
ServerKey string `json:"serverKey,omitempty"`
ServerHost string `json:"serverHost,omitempty"`
Unmanaged bool `json:"unmanaged,omitempty"`
Key string `json:"key,omitempty"`
// Original fields in the Spokes Admin API.
Version string `json:"version,omitempty"`
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
Https []*Http `json:"https,omitempty"`
Ports []*Port `json:"ports,omitempty"`
PortMappings []*PortMap `json:"portmaps,omitempty"`
}
Supports pktriot client HTTP API. Can be used as a request or a response.
type TunConfigResponse ¶
type TunRequest ¶
type TunRequest struct {
TunID UID `json:"tunnelID"`
}
type TunRespLink ¶
type TunResponse ¶
type TunResponse struct {
Status bool `json:"status"`
Error string `json:"error"`
// List of tunnels (all, active, online)
Total int `json:"total,omitempty"`
Tunnels []*Tunnel `json:"tunnels,omitempty"`
Links []*TunRespLink `json:"links,omitempty"`
// Detailed single tunnel response
Tunnel *Tunnel `json:"tunnel,omitempty"`
// Authentication Token (used during creation
Token *APIKey `json:"token,omitempty"`
}
type TunService ¶
type TunService struct {
Tun *Tunnel `json:"tunnel"`
HTTP *HttpService `json:"http,omitempty"`
Port *PortService `json:"port,omitempty"`
Available bool `json:"available"`
Timestamp time.Time `json:"timestamp"`
}
TunService is used to associate a tunnel with an HTTP *or* a PortService and an availability state for the service. This struct is used to communicate when a service goes up/down.
type Tunnel ¶
type Tunnel struct {
ID UID `json:"id"`
UserID UID `json:"userID"`
Created time.Time `json:"created"`
LastActive time.Time `json:"lastActive"`
State uint16 `json:"state"`
Uptime time.Duration `json:"uptime"` // value is saved in seconds
Bandwidth DataUsage `json:"bandwidth"`
Name string `json:"name"`
Hostname string `json:"hostname"` // domain assigned to tunnel
Address string `json:"address"` // ip address of client
Version string `json:"version"` // client version (most recent session)
OS string `json:"os"` // operating system
Arch string `json:"arch"` // architecture
// Used during runtime
Https []*HttpService `json:"https,omitempty"`
Ports []*PortService `json:"ports,omitempty"`
}
func (*Tunnel) DomainNames ¶
func (*Tunnel) NumServices ¶
func (*Tunnel) StateString ¶
func (*Tunnel) UptimeString ¶
type UID ¶
var (
SystemID UID // all zeros
)
func UIDFromBytes ¶
func UIDFromString ¶
func (*UID) MarshalJSON ¶
implementing the Marshaler interface
func (*UID) UnmarshalJSON ¶
implementing the Unmarshaler interface
type UpdateHTTPRequest ¶
type UpdateHTTPRequest struct {
Sites []*Http `json:"sites"`
}
type UpdatePortMapRequest ¶
type UpdatePortMapRequest struct {
PortMappings []*PortMap `json:"portmaps"`
}
type UpdatePortRequest ¶
type UpdatePortRequest struct {
Ports []*Port `json:"ports"`
}
type User ¶
type User struct {
ID UID `json:"id"`
Created time.Time `json:"created"`
Modified time.Time `json:"modified"`
Active bool `json:"active"`
Fullname string `json:"fullname"`
Email string `json:"email"`
Phone string `json:"phone"`
Bandwidth int `json:"bandwidth"` // monthly limit (MB)
MaxBandwidth bool `json:"maxBandwidth"` // flag indicates max bandwidth limit hit for user
CheckDomains bool `json:"checkDomains"` // flag indicates a validation check should be performed on HTTP rules
MaxPorts int `json:"maxPorts"` // max number of port allocations/rules for user
CheckPorts bool `json:"checkPorts"` // flag indicates max ports limit should be enforced
// Runtime field...
Domains *DomainLimits `json:"-"`
}
type UserRequest ¶
type UserRequest struct {
UserID UID `json:"userID"`
Email string `json:"email,omitempty"`
Fullname string `json:"fullname,omitempty"`
Phone string `json:"phone,omitempty"`
Active bool `json:"active,omitempty`
Bandwidth int `json:"bandwidth,omitempty"`
MaxBandwidth bool `json:"maxBandwidth,omitempty"`
CheckDomains bool `json:"checkDomains,omitempty"`
MaxPorts int `json:"maxPorts,omitempty"`
CheckPorts bool `json:"checkPorts,omitempty"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.