rest

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: GPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenRequest

type AccessTokenRequest struct {
	Host        string `json:"host,omitempty"`        // VPN connection host
	Domain      string `json:"domain,omitempty"`      // VPN connection Domain
	AccessToken []byte `json:"accessToken,omitempty"` // Access-Token, takes precedence over Username/Password pair
	Username    string `json:"username,omitempty"`    // Username ( should be empty when updating an Access-Token )
	Password    string `json:"password,omitempty"`    // Password ( should be empty when updating an Access-Token )
}

func (*AccessTokenRequest) Check

func (a *AccessTokenRequest) Check() (err error)

type Client

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

func NewClient

func NewClient(config *Config) (c *Client, err error)

func (*Client) Connect

func (c *Client) Connect(key wgtypes.Key) (connectResponse *ConnectResponse, err error)

Hide.me "Connect" endpoint expects an ordinary POST request with a ConnectRequest JSON payload

func (*Client) Disconnect

func (c *Client) Disconnect(sessionToken []byte) (err error)

Hide.me "Disconnect" endpoint expects an ordinary POST request with a DisconnectRequest JSON payload

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() (err error)

Hide.me "AccessToken" endpoint expects an ordinary POST request with a AccessTokenRequest JSON payload

func (*Client) HaveAccessToken

func (c *Client) HaveAccessToken() bool

func (*Client) Pins

func (c *Client) Pins(_ [][]byte, verifiedChains [][]*x509.Certificate) error

Check public key pins of authorized hide.me/hideservers.net CA certificates

func (*Client) Remote

func (c *Client) Remote() *net.TCPAddr

func (*Client) Resolve

func (c *Client) Resolve() (err error)

Resolves the IP of hide.me endpoint and stores that IP for further use. Hide.me balances DNS rapidly, so once an IP is acquired it needs to be used for the remainder of the session

type Config

type Config struct {
	APIVersion             string        `yaml:"-"`                                // Current API version is 1.0.0
	Host                   string        `yaml:"host,omitempty"`                   // FQDN of the server
	Port                   int           `yaml:"port,omitempty"`                   // Port to connect to when issuing REST requests
	Domain                 string        `yaml:"-"`                                // Domain ( hide.me )
	AccessTokenFile        string        `yaml:"accessToken,omitempty"`            // Access-Token for REST requests
	Username               string        `yaml:"username,omitempty"`               // Username ( Access-Token takes precedence )
	Password               string        `yaml:"password,omitempty"`               // Password ( Access-Token takes precedence )
	ConnectTimeout         time.Duration `yaml:"connectTimeout,omitempty"`         // Timeout for REST requests
	AccessTokenUpdateDelay time.Duration `yaml:"AccessTokenUpdateDelay,omitempty"` // Period to wait for when updating a stale Access-Token
	CA                     string        `yaml:"CA,omitempty"`                     // CA certificate bundle ( empty for system-wide CA roots )
	FirewallMark           int           `yaml:"firewallMark,omitempty"`           // Firewall mark for the traffic generated by this app
	DnsServers             string        `yaml:"dnsServers,omitempty"`             // DNS servers to use when resolving names for client requests ( wireguard link uses it's assigned DNS servers )
}

type ConnectRequest

type ConnectRequest struct {
	Host        string `json:"host,omitempty"`        // VPN connection host
	Domain      string `json:"domain,omitempty"`      // VPN connection Domain
	AccessToken []byte `json:"accessToken,omitempty"` // Access-Token, takes precedence over Username/Password pair
	PublicKey   []byte `json:"publicKey"`             // Our public key
}

func (*ConnectRequest) Check

func (req *ConnectRequest) Check() (err error)

type ConnectResponse

type ConnectResponse struct {
	PublicKey                   []byte        `json:"publicKey"`                     // Server's public key
	Endpoint                    net.UDPAddr   `json:"endpoint,omitempty"`            // Server's endpoint
	PresharedKey                []byte        `json:"presharedKey,omitempty"`        // Preshared key ( if negotiated )
	PersistentKeepaliveInterval time.Duration `json:"persistentKeepalive,omitempty"` // PersistentKeepAlive interval
	AllowedIps                  []net.IP      `json:"allowedIps,omitempty"`          // Server assigned IPs
	DNS                         []net.IP      `json:"DNS,omitempty"`                 // Server assigned DNS server IPs
	Gateway                     []net.IP      `json:"gateway,omitempty"`             // Server assigned gateway IPs
	StaleAccessToken            bool          `json:"staleAccessToken,omitempty"`    // If true the Access-Token presented in the ConnectRequest is stale and should be updated
	SessionToken                []byte        `json:"sessionToken,omitempty"`        // Session-Token uniquely identifies the VPN connection session
}

func (*ConnectResponse) Print

func (w *ConnectResponse) Print()

type DisconnectRequest

type DisconnectRequest struct {
	Host         string `json:"host,omitempty"`         // VPN connection host
	Domain       string `json:"domain,omitempty"`       // VPN connection domain
	SessionToken []byte `json:"sessionToken,omitempty"` // Session-Token uniquely identifies the VPN connection session to disconnect
}

func (*DisconnectRequest) Check

func (req *DisconnectRequest) Check() (err error)

Jump to

Keyboard shortcuts

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