devtunnel

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: AGPL-3.0 Imports: 25 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",
				HostnameWireguard: "pit-1.try.coder.app",
				WireguardPort:     55551,
			},
		},
	},
}

Functions

This section is empty.

Types

type Config added in v0.6.6

type Config struct {
	Version    int                    `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() (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"`
	HostnameWireguard string `json:"hostname_wireguard"`
	WireguardPort     uint16 `json:"wireguard_port"`

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

func FindClosestNode added in v0.7.7

func FindClosestNode() (Node, error)

type Region added in v0.7.7

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

type ServerResponse added in v0.7.7

type ServerResponse struct {
	Hostname        string     `json:"hostname"`
	ServerIP        netip.Addr `json:"server_ip"`
	ServerPublicKey string     `json:"server_public_key"` // hex
	ClientIP        netip.Addr `json:"client_ip"`
}

type Tunnel added in v0.6.6

type Tunnel struct {
	URL      string
	Listener net.Listener
}

func New

func New(ctx context.Context, logger slog.Logger) (*Tunnel, <-chan error, 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.

func NewWithConfig added in v0.6.6

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

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

Jump to

Keyboard shortcuts

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