spokes

package module
v0.0.0-...-58455b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 15 Imported by: 0

README

spokes-go

Go client library for spokes server. Please check out our docs for more details on endpoints and data descriptions. This client library and the Admin API is being actively developed. Please report any bugs or issues to support or DM us on Twitter.

Requirements

You'll need the following to use this client library:

  • Spokes setup on a server or virtual machine
  • License

Basic Usage

The Admin API for Spokes uses a key to authenticate a web session. This is performed only once until the client is logged out or session expires.

Below is a following snippet to authenticate:


client, err := spokes.NewClientWithURL("https://spokes.example.com")
...
if _, err := client.Auth("INSERT KEY HERE"); err != nil {
	log.Fatal("authentication failed...")
}

Commonly, you may want to poll and check which tunnels are online:

tuns, err := client.OnlineTunnels()
if err != nil {
	log.Fatal("...")
}

for _, tun := range tuns {
	// Print out the host IP address for the tunnel
	fmt.Printf("Tun-Hostname: %s, hosted at %s\n", tun.Hostname, tun.Address)
}

You may want to shutdown a tunnel. This will terminate the tunnel session and immediately drop all traffic between client and the tunnel.


var tun *spokes.Tunnel
...

if resp, err := client.ShutdownTunnel(tun.ID); err != nil {
	log.Fataln(err.Error())
} else if resp.Status {
	fmt.Println("Tunnel was shut down")
}

Documentation

Index

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) Generate

func (a *APIKey) Generate()

func (*APIKey) KeySnippet

func (a *APIKey) KeySnippet() string

func (*APIKey) KeySnippetN

func (a *APIKey) KeySnippetN(n int) string

type AuthPageOptions

type AuthPageOptions struct {
	Title   string `json:"title,omitempty"`
	LogoURL string `json:"logoURL,omitempty"`
	SiteURL string `json:"siteURL,omitempty"`
}

type AuthRequest

type AuthRequest struct {
	Key     string `json:"key"`
	Version string `json:"version,omitempty"`
	OS      string `json:"os,omitempty"`
	Arch    string `json:"arch,omitempty"`
}

type BandwidthRequest

type BandwidthRequest struct {
	UserID UID `json:"userID"`
	Max    int `json:"max"` // MB, e.g. 1000 == 1 Gigabyte
}

type BasicResponse

type BasicResponse struct {
	Status  bool   `json:"status"`
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`
}

type ByteSize

type ByteSize int64

func (ByteSize) String

func (bs ByteSize) String() string

func (ByteSize) Units

func (bs ByteSize) Units() (float64, string)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClientWithURL

func NewClientWithURL(address string) (*Client, error)

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) Auth

func (c *Client) Auth(key 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) EditToken

func (c *Client) EditToken(tokenID UID, description string, active bool) (*TokenResponse, 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) GetUser

func (c *Client) GetUser(userID UID) (*UserResponse, 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

func (c *Client) SetInsecure(b bool) error

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) Tunnel

func (c *Client) Tunnel(id UID) (*TunResponse, 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)

func (*Client) UserExists

func (c *Client) UserExists(userID UID) (bool, 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 CreateTokenRequest struct {
	Description string `json:"description"`
	Active      bool   `json:"active"`
}

type CreateTunRequest

type CreateTunRequest struct {
	UserID   UID    `json:"userID"`
	TunID    UID    `json:"tunID"`
	Name     string `json:"name"`
	Hostname string `json:"hostname"`
}

type DataUsage

type DataUsage struct {
	Daily   ByteSize `json:"daily"`   // bytes
	Monthly ByteSize `json:"monthly"` // bytes
}

type DomainLimits

type DomainLimits struct {
	Allowed []string `json:"allowed"`
}

type DomainRequest

type DomainRequest struct {
	UserID  UID      `json:"userID"`
	Domains []string `json:"domains"`
}

type DomainResponse

type DomainResponse struct {
	Status  bool     `json:"status"`
	Error   string   `json:"error,omitempty"`
	Domains []string `json:"domains"`
}

type EditTokenRequest

type EditTokenRequest struct {
	TokenID     UID    `json:"tokenID"`
	Description string `json:"description"`
	Active      bool   `json:"active"`
}

type FwRule

type FwRule struct {
	Sequence int    `json:"sequence"`
	Action   string `json:"action"`
	Network  string `json:"network"`
}

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 HttpService struct {
	ID         UID       `json:"id"`
	UserID     UID       `json:"userID"`
	TunID      UID       `json:"tunID"`
	Active     bool      `json:"active"`
	Available  bool      `json:"available"`
	Secure     bool      `json:"secure"` // true == https, false == http
	DomainName string    `json:"domainName"`
	Bandwidth  DataUsage `json:"bandwidth"`
}

type LicenseInfoResponse

type LicenseInfoResponse struct {
	Status     bool      `json:"status"`
	Error      string    `json:"error,omitempty"`
	MaxTunnels int       `json:"maxTunnels"`
	Expires    time.Time `json:"expires"`
}

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 PortRange

type PortRange struct {
	Begin int `json:"begin"`
	End   int `json:"end"`
}

type PortRangeResponse

type PortRangeResponse struct {
	Status bool      `json:"status"`
	Error  string    `json:"error,omitempty"`
	Range  PortRange `json:"range"`
}

type PortResponse

type PortResponse struct {
	Status bool       `json:"status"`
	Error  string     `json:"error,omitempty"`
	Ports  []*PortTun `json:"ports"`
}

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 PortTun

type PortTun struct {
	Port  int `json:"port"`
	TunID UID `json:"tunID"`
}

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 SearchTunRequest struct {
	Term    string `json:"term"`
	OS      string `json:"os"`
	Arch    string `json:"arch"`
	Version string `json:"version"`
}

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 TokenResponse struct {
	Status bool   `json:"status"`
	Error  string `json:"error,omitempty"`

	// List token operations (registration, auth)
	Tokens []*APIKey `json:"tokens,omitempty"`

	// Create (registration, authtoken token response
	Token *APIKey `json:"token,omitempty"`
}

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 TunConfigResponse struct {
	Status bool       `json:"status"`
	Error  string     `json:"error,omitempty"`
	Config *TunConfig `json:"config"`
}

type TunRequest

type TunRequest struct {
	TunID UID `json:"tunnelID"`
}
type TunRespLink struct {
	UID   string `json:"uid"`
	Order int    `json:"order"`
	Count int    `json:"count"`
	URL   string `json:"url"`
}

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) DataUsage

func (t *Tunnel) DataUsage() int64

func (*Tunnel) DomainNames

func (t *Tunnel) DomainNames() (domains []string)

func (*Tunnel) IsActive

func (t *Tunnel) IsActive() bool

func (*Tunnel) IsOnline

func (t *Tunnel) IsOnline() bool

func (*Tunnel) IsVisible

func (t *Tunnel) IsVisible() bool

func (*Tunnel) NumServices

func (t *Tunnel) NumServices() int

func (*Tunnel) StateString

func (t *Tunnel) StateString() string

func (*Tunnel) UptimeString

func (t *Tunnel) UptimeString() string

type UID

type UID [UIDLen]byte
var (
	SystemID UID // all zeros
)

func NewUID

func NewUID() UID

func UIDFromBytes

func UIDFromBytes(b []byte) (UID, error)

func UIDFromString

func UIDFromString(s string) UID

func (*UID) Bytes

func (this *UID) Bytes() []byte

func (*UID) Equals

func (this *UID) Equals(uid UID) bool

func (*UID) EqualsHex

func (this *UID) EqualsHex(hex string) bool

func (*UID) IsZero

func (this *UID) IsZero() bool

func (*UID) MarshalJSON

func (this *UID) MarshalJSON() ([]byte, error)

implementing the Marshaler interface

func (*UID) Set

func (this *UID) Set(s string) error

func (*UID) String

func (this *UID) String() string

func (*UID) UnmarshalJSON

func (this *UID) UnmarshalJSON(b []byte) error

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"`
}

type UserResponse

type UserResponse struct {
	Status bool   `json:"status"`
	Error  string `json:"error,omitempty"`

	// List of all (basic) users on the system
	Users []*User `json:"users,omitempty"`

	// User object for creation, import
	User *User `json:"user,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL