config

package
v1.6.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BackendSOCKS = "socks"
	BackendSSH   = "ssh"
)

Backend types.

View Source
const (
	DefaultConfigDir  = "/etc/slipgate"
	DefaultConfigFile = "/etc/slipgate/config.json"
	DefaultTunnelDir  = "/etc/slipgate/tunnels"
	DefaultBinDir     = "/usr/local/bin"
	SystemUser        = "slipgate"
	SystemGroup       = "slipgate"
	SSHGroup          = "slipgate-ssh"
)
View Source
const (
	TransportDNSTT      = "dnstt"
	TransportSlipstream = "slipstream"
	TransportVayDNS     = "vaydns"
	TransportNaive      = "naive"
	TransportStunTLS    = "stuntls"
	TransportSSH        = "direct-ssh"
	TransportSOCKS      = "direct-socks5"
	TransportExternal   = "external"
)

Transport types.

View Source
const BasePort = 5310

BasePort is the starting port for DNS tunnel forwarding.

View Source
const DefaultMTU = 1232

DefaultMTU for DNS tunnels.

Variables

View Source
var TransportBinaries = map[string]string{
	TransportDNSTT:      "dnstt-server",
	TransportSlipstream: "slipstream-server",
	TransportVayDNS:     "vaydns-server",
	TransportNaive:      "caddy-naive",
}

TransportBinaries maps transport types to their required binaries.

View Source
var ValidVayDNSRecordTypes = []string{"txt", "cname", "a", "aaaa", "mx", "ns", "srv", "null", "caa"}

ValidVayDNSRecordTypes lists the valid DNS record types for VayDNS.

Functions

func RandomDecoyURL

func RandomDecoyURL() string

RandomDecoyURL returns a random decoy site URL.

func TunnelDir

func TunnelDir(tag string) string

TunnelDir returns the directory for a tunnel's files.

func ValidatePassword added in v1.6.3

func ValidatePassword(p string) error

ValidatePassword rejects characters that can't round-trip through every place slipgate serializes a password: `chpasswd` stdin (`user:pass` lines, so ':' splits and '\n' terminates), and the SOCKS5 creds file (same `user:pass\n` framing). Also rejects control characters, which are generally unsafe in shadow-file passwords.

func ValidateTagName added in v1.4.1

func ValidateTagName(tag string) error

ValidateTagName checks if a tag name is valid.

Types

type BackendConfig

type BackendConfig struct {
	Tag     string       `json:"tag"`
	Type    string       `json:"type"`
	Address string       `json:"address"`
	SOCKS   *SOCKSConfig `json:"socks,omitempty"`
}

BackendConfig defines a backend service.

func DefaultBackends

func DefaultBackends() []BackendConfig

DefaultBackends returns the standard backend configs.

type Config

type Config struct {
	Listen   ListenConfig    `json:"listen"`
	Tunnels  []TunnelConfig  `json:"tunnels"`
	Backends []BackendConfig `json:"backends"`
	Users    []UserConfig    `json:"users,omitempty"`
	Route    RouteConfig     `json:"route"`
	Warp     WarpConfig      `json:"warp,omitempty"`
	// contains filtered or unexported fields
}

Config is the top-level slipgate configuration.

func Default

func Default() *Config

Default returns a new config with sensible defaults.

func Load

func Load() (*Config, error)

Load reads config from the default path.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads config from a specific path.

func (*Config) AddTunnel

func (c *Config) AddTunnel(t TunnelConfig)

AddTunnel adds a tunnel to the config.

func (*Config) AddUser

func (c *Config) AddUser(u UserConfig)

AddUser adds a user to the config. If a user with the same username already exists, it is updated in place instead of creating a duplicate.

func (*Config) GetBackend

func (c *Config) GetBackend(tag string) *BackendConfig

GetBackend returns a backend by tag.

func (*Config) GetTunnel

func (c *Config) GetTunnel(tag string) *TunnelConfig

GetTunnel returns a tunnel by tag.

func (*Config) GetUser

func (c *Config) GetUser(username string) *UserConfig

GetUser returns a user by username.

func (*Config) NextAvailablePort

func (c *Config) NextAvailablePort() int

NextAvailablePort returns the next unused port starting from BasePort.

func (*Config) RemoveTunnel

func (c *Config) RemoveTunnel(tag string) bool

RemoveTunnel removes a tunnel by tag.

func (*Config) RemoveUser

func (c *Config) RemoveUser(username string) bool

RemoveUser removes a user by username.

func (*Config) Save

func (c *Config) Save() error

Save writes the config to disk.

func (*Config) SaveTo

func (c *Config) SaveTo(path string) error

SaveTo writes the config to a specific path.

func (*Config) UniqueTag added in v1.4.1

func (c *Config) UniqueTag(base string) string

UniqueTag returns a tag that doesn't conflict with existing tunnels. If base is available it is returned as-is, otherwise a numeric suffix is appended.

func (*Config) UpdateTunnel

func (c *Config) UpdateTunnel(t TunnelConfig)

UpdateTunnel replaces a tunnel config by tag.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the entire config for errors.

func (*Config) ValidateNewTunnel

func (c *Config) ValidateNewTunnel(t *TunnelConfig) error

ValidateNewTunnel checks a tunnel against the existing config.

type DNSTTConfig

type DNSTTConfig struct {
	MTU        int    `json:"mtu"`
	PrivateKey string `json:"private_key"` // path to key file
	PublicKey  string `json:"public_key"`  // hex-encoded public key
}

DNSTTConfig holds config for DNSTT transport (serves both DNSTT and NoizDNS clients).

type ListenConfig

type ListenConfig struct {
	Address string `json:"address"`
}

ListenConfig defines the DNS listen address.

type NaiveConfig

type NaiveConfig struct {
	Email    string `json:"email"`
	DecoyURL string `json:"decoy_url"`
	Port     int    `json:"port"` // typically 443
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
}

NaiveConfig holds config for naiveproxy transport.

type RouteConfig

type RouteConfig struct {
	Mode    string `json:"mode"`    // "single" or "multi"
	Active  string `json:"active"`  // active tunnel tag (single mode)
	Default string `json:"default"` // default tunnel tag (multi mode fallback)
}

RouteConfig defines routing behavior.

type SOCKSConfig

type SOCKSConfig struct {
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
}

SOCKSConfig holds SOCKS-specific settings.

type SlipstreamConfig

type SlipstreamConfig struct {
	Cert string `json:"cert"` // path to cert file
	Key  string `json:"key"`  // path to key file
}

SlipstreamConfig holds config for slipstream transport.

type StunTLSConfig added in v1.6.0

type StunTLSConfig struct {
	Cert string `json:"cert"` // path to TLS certificate
	Key  string `json:"key"`  // path to TLS private key
	Port int    `json:"port"` // listen port (typically 443)
}

StunTLSConfig holds config for the TLS + WebSocket SSH proxy transport. Accepts both raw TLS connections (stunnel-style) and WebSocket upgrades, forwarding traffic to the SSH daemon.

type TunnelConfig

type TunnelConfig struct {
	Tag       string `json:"tag"`
	Transport string `json:"transport"`
	Backend   string `json:"backend"`
	Domain    string `json:"domain"`
	Port      int    `json:"port,omitempty"` // DNS tunnels: internal forwarding port (5310+)
	Enabled   bool   `json:"enabled"`

	// Transport-specific configs (only one set per tunnel)
	DNSTT      *DNSTTConfig      `json:"dnstt,omitempty"`
	Slipstream *SlipstreamConfig `json:"slipstream,omitempty"`
	VayDNS     *VayDNSConfig     `json:"vaydns,omitempty"`
	Naive      *NaiveConfig      `json:"naive,omitempty"`
	StunTLS    *StunTLSConfig    `json:"stuntls,omitempty"`
}

TunnelConfig defines a single tunnel.

func (*TunnelConfig) HasManagedService added in v1.6.0

func (t *TunnelConfig) HasManagedService() bool

HasManagedService returns true if slipgate manages a systemd service for this tunnel.

func (*TunnelConfig) IsDNSTunnel

func (t *TunnelConfig) IsDNSTunnel() bool

IsDNSTunnel returns true if the transport uses DNS port 53.

func (*TunnelConfig) IsDirectTransport

func (t *TunnelConfig) IsDirectTransport() bool

IsDirectTransport returns true for transports that expose a service directly (no tunnel).

type UserConfig

type UserConfig struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

UserConfig tracks a managed user (same credentials for SSH + SOCKS).

type VayDNSConfig added in v1.4.0

type VayDNSConfig struct {
	MTU           int    `json:"mtu"`
	PrivateKey    string `json:"private_key"`             // path to key file
	PublicKey     string `json:"public_key"`              // hex-encoded public key
	IdleTimeout   string `json:"idle_timeout,omitempty"`  // e.g. "10s", "2m"
	KeepAlive     string `json:"keep_alive,omitempty"`    // e.g. "2s"
	Fallback      string `json:"fallback,omitempty"`      // fallback DNS address
	DnsttCompat   bool   `json:"dnstt_compat,omitempty"`  // dnstt wire-format compatibility
	ClientIDSize  int    `json:"clientid_size,omitempty"` // client ID bytes (default 2)
	QueueSize     int    `json:"queue_size,omitempty"`    // KCP queue size (default 512)
	KCPWindowSize int    `json:"kcp_window_size,omitempty"`
	QueueOverflow string `json:"queue_overflow,omitempty"` // "drop" or "block"
	RecordType    string `json:"record_type,omitempty"`    // txt, cname, a, aaaa, mx, ns, srv, null, caa
}

VayDNSConfig holds config for VayDNS transport (KCP + Curve25519).

func (*VayDNSConfig) ResolvedClientIDSize added in v1.4.0

func (v *VayDNSConfig) ResolvedClientIDSize() int

ResolvedClientIDSize returns the clientid-size flag value, or 0 if omitted (dnstt-compat).

func (*VayDNSConfig) ResolvedIdleTimeout added in v1.4.0

func (v *VayDNSConfig) ResolvedIdleTimeout() string

ResolvedIdleTimeout returns the idle-timeout value, applying defaults.

func (*VayDNSConfig) ResolvedKeepAlive added in v1.4.0

func (v *VayDNSConfig) ResolvedKeepAlive() string

ResolvedKeepAlive returns the keepalive value, applying defaults.

type WarpConfig added in v1.4.0

type WarpConfig struct {
	Enabled bool `json:"enabled"`
}

WarpConfig tracks Cloudflare WARP outbound state.

Jump to

Keyboard shortcuts

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