Documentation ¶
Index ¶
- Constants
- Variables
- type API
- func (a *API) Device(ctx context.Context, id int64) (Device, error)
- func (a *API) Devices(ctx context.Context) ([]Device, error)
- func (a *API) Endpoint(ep Endpoint) string
- func (a *API) Gateway(ctx context.Context, c chan<- GatewayMsg, dev int64, port int)
- func (a *API) GatewaySend(ctx context.Context, msg GatewayMsg) error
- func (a *API) JoinNetwork(ctx context.Context, dev, nw int64) error
- func (a *API) LeaveNetwork(ctx context.Context, dev, nw int64) error
- func (a *API) Login(ctx context.Context, username, password string) error
- func (a *API) Network(ctx context.Context, id int64) (Network, error)
- func (a *API) Networks(ctx context.Context) ([]Network, error)
- func (a *API) NewDevice(ctx context.Context, name, key string) (Device, error)
- func (a *API) NewNetwork(ctx context.Context, name string) (Network, error)
- func (a *API) PunchDetails(ctx context.Context) (PunchDetails, error)
- type Device
- type Endpoint
- type GatewayMsg
- type Network
- type PunchDetails
- type User
Constants ¶
View Source
const ( Ping gatewayMsgType = iota NetworkJoin NetworkLeave DeviceUpdate Disconnect gatewayMsgType = -1 Connect gatewayMsgType = -2 )
Variables ¶
View Source
var (
ErrNotFound = httpError(404)
)
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { // Server is where the Pikonet Rendezvous server is hosted. // This must not change after the first call. Server string // Token is the Rendezvous token we receive after logging in. // This must be set, or will be set with a call to Login. // // Token must not change once set. Token string HTTP *http.Client // contains filtered or unexported fields }
API handles API calls.
func (*API) GatewaySend ¶
func (a *API) GatewaySend(ctx context.Context, msg GatewayMsg) error
func (*API) JoinNetwork ¶
JoinNetwork joins a device to a network.
func (*API) LeaveNetwork ¶
LeaveNetwork removes a device from a network.
func (*API) Login ¶
Login attempts to login to the Rendezvous server.
Login automatically updates the token in the API struct. If error is nil, assume it is updated.
func (*API) NewNetwork ¶
NewNetwork adds a new network to the user.
func (*API) PunchDetails ¶
func (a *API) PunchDetails(ctx context.Context) (PunchDetails, error)
PunchDetails fetches Pikopunch details from the rendezvous server.
type Device ¶
type Device struct { ID int64 `json:"id"` Owner int64 `json:"owner"` Name string `json:"name"` // PublicKey is the WireGuard public key for this device. PublicKey string `json:"key"` // IP is the Pikonet IP, which likely means a random IP in the range // fd00::/32. // This IP is not routable by the Internet, and only by Pikonet nodes. IP string `json:"ip,omitempty"` Endpoint string `json:"endpoint,omitempty"` Networks []Network `json:"networks,omitempty"` PrivateKey string `json:"-"` }
Device represents a device, its unique Pikonet IP, and its public key.
type Endpoint ¶
type Endpoint string
const ( EndpointAuth Endpoint = "/auth" EndpointListDevices Endpoint = "/list/devices" EndpointListNetworks Endpoint = "/list/networks" EndpointNewDevice Endpoint = "/new/device" EndpointNewNetwork Endpoint = "/new/network" EndpointNetworkInfo Endpoint = "/network/info" EndpointDeviceJoin Endpoint = "/device/join" EndpointDeviceLeave Endpoint = "/device/leave" EndpointDeviceInfo Endpoint = "/device/info" EndpointGateway Endpoint = "/gateway" EndpointPunch Endpoint = "/punch" )
type GatewayMsg ¶
type GatewayMsg struct { Type gatewayMsgType Device *Device `json:"device,omitempty"` Network *Network `json:"network,omitempty"` Remove bool Endpoint string `json:"endpoint,omitempty"` DeviceID int64 `json:"device_id,omitempty"` NetworkID int64 `json:"network_id,omitempty"` Delay time.Duration `json:"-"` Error error `json:"-"` }
type Network ¶
type Network struct { ID int64 `json:"id"` Owner int64 `json:"owner"` Name string `json:"name"` Devices []Device `json:"devices"` }
Network represents a network to which devices connect to
type PunchDetails ¶
Click to show internal directories.
Click to hide internal directories.