newt

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlueprintResult

type BlueprintResult struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
}

type BrowserGatewayTarget

type BrowserGatewayTarget struct {
	ID              int    `json:"id"`
	Type            string `json:"type"`
	Destination     string `json:"destination"`
	DestinationPort int    `json:"destinationPort"`
	AuthToken       string `json:"authToken"`
}

type Config

type Config struct {
	// Build info
	Version  string
	Platform string

	// Logging
	LogLevel string

	// Connection
	Endpoint        string
	ID              string
	Secret          string
	ProvisioningKey string
	NewtName        string
	ConfigFile      string

	// Network
	MTU                     int
	DNS                     string
	InterfaceName           string
	Port                    uint16
	UseNativeInterface      bool
	UseNativeMainInterface  bool
	NativeMainInterfaceName string
	NoCloud                 bool
	PreferEndpoint          string

	// Timing
	PingInterval        time.Duration
	PingTimeout         time.Duration
	UDPProxyIdleTimeout time.Duration

	// Features
	DisableClients            bool
	DisableSSH                bool
	EnforceHealthcheckCert    bool
	HealthFile                string
	BlueprintFile             string
	ProvisioningBlueprintFile string
	UpdownScript              string

	// Docker
	DockerSocket                   string
	DockerEnforceNetworkValidation bool

	// Auth daemon
	AuthDaemonKey                    string
	AuthDaemonPrincipalsFile         string
	AuthDaemonCACertPath             string
	AuthDaemonGenerateRandomPassword bool

	// TLS (mTLS)
	TLSClientCert string
	TLSClientKey  string
	TLSClientCAs  []string
	TLSPrivateKey string

	// Metrics/observability
	MetricsEnabled    bool
	OTLPEnabled       bool
	AdminAddr         string
	Region            string
	MetricsAsyncBytes bool
	PprofEnabled      bool

	// Callbacks
	OnRestart func() error
}

Config holds all runtime configuration for a Newt instance.

type ExitNode

type ExitNode struct {
	ID                     int     `json:"exitNodeId"`
	Name                   string  `json:"exitNodeName"`
	Endpoint               string  `json:"endpoint"`
	Weight                 float64 `json:"weight"`
	WasPreviouslyConnected bool    `json:"wasPreviouslyConnected"`
}

type ExitNodeData

type ExitNodeData struct {
	ExitNodes []ExitNode `json:"exitNodes"`
	ChainId   string     `json:"chainId"`
}

type ExitNodePingResult

type ExitNodePingResult struct {
	ExitNodeID             int     `json:"exitNodeId"`
	LatencyMs              int64   `json:"latencyMs"`
	Weight                 float64 `json:"weight"`
	Error                  string  `json:"error,omitempty"`
	Name                   string  `json:"exitNodeName"`
	Endpoint               string  `json:"endpoint"`
	WasPreviouslyConnected bool    `json:"wasPreviouslyConnected"`
}

type Newt

type Newt struct {
	// contains filtered or unexported fields
}

Newt holds all runtime state for a newt tunnel instance.

func Init

func Init(ctx context.Context, cfg Config) (*Newt, error)

Init creates and initialises a Newt instance. It sets up the websocket client, generates WireGuard keys, and starts the auth daemon if enabled. Callers should invoke Start after any additional setup (telemetry, etc.).

func (*Newt) Close

func (n *Newt) Close()

Close performs an emergency shutdown: closes the tunnel, clients, health monitor, and websocket connection. Typically used before re-exec.

func (*Newt) GetConfig

func (n *Newt) GetConfig() Config

GetConfig returns the (potentially resolved) configuration.

func (*Newt) GetTLSClientOpt

func (n *Newt) GetTLSClientOpt() websocket.ClientOption

GetTLSClientOpt returns the websocket TLS option, so callers can reuse the same TLS configuration for other HTTP clients (e.g. self-update).

func (*Newt) Start

func (n *Newt) Start(ctx context.Context)

Start sets up all WebSocket handlers, connects to the server, and blocks until ctx is cancelled.

type SyncData

type SyncData struct {
	Targets               TargetsByType          `json:"proxyTargets"`
	HealthCheckTargets    []healthcheck.Config   `json:"healthCheckTargets"`
	RemoteExitNodeSubnets []string               `json:"remoteExitNodeSubnets"`
	Peers                 []wgclients.Peer       `json:"peers"`
	ClientTargets         []wgclients.Target     `json:"clientTargets"`
	BrowserGatewayTargets []BrowserGatewayTarget `json:"browserGatewayTargets"`
}

Define the sync data structure

type TargetData

type TargetData struct {
	Targets []string `json:"targets"`
}

type TargetsByType

type TargetsByType struct {
	UDP []string `json:"udp"`
	TCP []string `json:"tcp"`
}

type WgData

type WgData struct {
	Endpoint              string                 `json:"endpoint"`
	RelayPort             uint16                 `json:"relayPort"`
	PublicKey             string                 `json:"publicKey"`
	ServerIP              string                 `json:"serverIP"`
	TunnelIP              string                 `json:"tunnelIP"`
	Targets               TargetsByType          `json:"targets"`
	HealthCheckTargets    []healthcheck.Config   `json:"healthCheckTargets"`
	BrowserGatewayTargets []BrowserGatewayTarget `json:"browserGatewayTargets"`
	RemoteExitNodeSubnets []string               `json:"remoteExitNodeSubnets"`
	ChainId               string                 `json:"chainId"`
}

Jump to

Keyboard shortcuts

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