devtunnel

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Regions = []Region{
	{
		ID:           0,
		LocationName: "US East Pittsburgh",
		Nodes: []Node{
			{
				ID:            1,
				RegionID:      0,
				HostnameHTTPS: "pit-1.try.coder.app",
			},
		},
	},
}

Functions

func New

func New(ctx context.Context, logger slog.Logger, customTunnelHost string) (*tunnelsdk.Tunnel, error)

New creates a tunnel with a public URL and returns a listener for incoming connections on that URL. Connections are made over the wireguard protocol. Tunnel configuration is cached in the user's config directory. Successive calls to New will always use the same URL. If multiple public URLs in parallel are required, use NewWithConfig.

This uses https://github.com/coder/wgtunnel as the server and client implementation.

func NewWithConfig added in v0.6.6

func NewWithConfig(ctx context.Context, logger slog.Logger, cfg Config) (*tunnelsdk.Tunnel, error)

NewWithConfig calls New with the given config. For documentation, see New.

Types

type Config added in v0.6.6

type Config struct {
	Version    tunnelsdk.TunnelVersion `json:"version"`
	PrivateKey device.NoisePrivateKey  `json:"private_key"`
	PublicKey  device.NoisePublicKey   `json:"public_key"`

	Tunnel Node `json:"tunnel"`

	// Used in testing.  Normally this is nil, indicating to use DefaultClient.
	HTTPClient *http.Client `json:"-"`
}

func GenerateConfig added in v0.6.6

func GenerateConfig(customTunnelHost string) (Config, error)

type Node added in v0.7.7

type Node struct {
	ID            int    `json:"id"`
	RegionID      int    `json:"region_id"`
	HostnameHTTPS string `json:"hostname_https"`

	AvgLatency time.Duration `json:"-"`
}

func FindClosestNode added in v0.7.7

func FindClosestNode(nodes []Node) (Node, error)

FindClosestNode pings each node and returns the one with the lowest latency.

func Nodes added in v0.20.1

func Nodes(customTunnelHost string) ([]Node, error)

Nodes returns a list of nodes to use for the tunnel. It will pick a random node from each region.

If a customNode is provided, it will be returned as the only node with ID 9999.

type Region added in v0.7.7

type Region struct {
	ID           int
	LocationName string
	Nodes        []Node
}

Jump to

Keyboard shortcuts

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