tunnelsdk
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Constants
- type Client
- func (c *Client) ClientRegister(ctx context.Context, req ClientRegisterRequest) (ClientRegisterResponse, error)
- func (c *Client) LaunchTunnel(ctx context.Context, cfg TunnelConfig) (*Tunnel, error)
- func (c *Client) Request(ctx context.Context, method, path string, body interface{}) (*http.Response, error)
- type ClientRegisterRequest
- type ClientRegisterResponse
- type Error
- type Key
- type Response
- type Tunnel
- type TunnelConfig
- type TunnelVersion
Constants¶
const TunnelPort = 8090TunnelPort is the port in the virtual wireguard network stack that thelistener is listening on.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeClient¶
Client provides HTTP methods for the tunneld API and a full wireguard tunnelclient implementation.
func (*Client)ClientRegister¶
func (c *Client) ClientRegister(ctxcontext.Context, reqClientRegisterRequest) (ClientRegisterResponse,error)
func (*Client)LaunchTunnel¶
LaunchTunnel makes a request to the tunneld server to register the client'stunnel using the client's public key, then establishes a wireguard connectionto the server and returns a *Tunnel. Connections can be accepted fromtunnel.Listener.
typeClientRegisterRequest¶
type ClientRegisterRequest struct {VersionTunnelVersion `json:"version"`PublicKeydevice.NoisePublicKey `json:"public_key"`}typeClientRegisterResponse¶
type ClientRegisterResponse struct {VersionTunnelVersion `json:"version"`ReregisterWaittime.Duration `json:"reregister_wait"`// TunnelURLs contains a list of valid URLs that will be forwarded from the// server to this tunnel client once connected. The first URL is the// preferred URL, and the other URLs are provided for compatibility// purposes only.//// The order of the URLs changes based on the Version field in the request.TunnelURLs []string `json:"tunnel_urls"`ClientIPnetip.Addr `json:"client_ip"`ServerEndpointstring `json:"server_endpoint"`ServerIPnetip.Addr `json:"server_ip"`ServerPublicKeydevice.NoisePublicKey `json:"server_public_key"`WireguardMTUint `json:"wireguard_mtu"`}typeError¶
type Error struct {Response// contains filtered or unexported fields}Error represents an unaccepted or invalid request to the API.
func (*Error)StatusCode¶
typeKey¶
type Key struct {// contains filtered or unexported fields}Key is a Wireguard private or public key.
funcFromNoisePrivateKey¶added inv0.1.1
func FromNoisePrivateKey(kdevice.NoisePrivateKey)Key
FromNoisePrivateKey converts a device.NoisePrivateKey to a Key.
funcFromNoisePublicKey¶added inv0.1.1
func FromNoisePublicKey(kdevice.NoisePublicKey)Key
FromNoisePublicKey converts a device.NoisePublicKey to a Key.
funcGeneratePrivateKey¶
GenerateWireguardPrivateKey generates a new wireguard private key usingsecure cryptography. The caller should store the key (using key.String()) ina safe place like the user's home directory, and use it in the future ratherthan generating a new key each time.
funcParsePrivateKey¶
ParsePrivateKey parses a private key generated using key.String().
funcParsePublicKey¶added inv0.1.1
ParsePublicKey parses a public key generated using key.String().
func (Key)NoisePrivateKey¶
func (kKey) NoisePrivateKey() (device.NoisePrivateKey,error)
NoisePrivateKey returns the device.NoisePrivateKey for the key. If the key isnot a private key, an error is returned.
func (Key)NoisePublicKey¶
func (kKey) NoisePublicKey()device.NoisePublicKey
NoisePublicKey returns the device.NoisePublicKey for the key. If the key is aprivate key, it is converted to a public key automatically.
typeTunnel¶
typeTunnelConfig¶
type TunnelConfig struct {Logslog.Logger// Version denotes which version of the tunnel URL specification to use.// Undefined version is treated as the latest version.VersionTunnelVersion// PrivateKey is the Wireguard private key. You can use GeneratePrivateKey// to generate a new key. It should be stored in a safe place for future// tunnel sessions, otherwise you will get a new hostname.PrivateKeyKey}typeTunnelVersion¶
type TunnelVersionint
TunnelVersion is the version of the tunnel URL specification.
const (// TunnelVersion1 is the "old style" tunnel URL. Each hostname base is 32// characters long and is base16 (hex) encoded.TunnelVersion1TunnelVersion = 1// TunnelVersion2 is the "new style" tunnel URL. Each hostname base is ~12// characters long and is base32 encoded.TunnelVersion2TunnelVersion = 2TunnelVersionLatest =TunnelVersion2)