config

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 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"
	TransportNaive      = "naive"
	TransportSSH        = "direct-ssh"
	TransportSOCKS      = "direct-socks5"
)

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",
	TransportNaive:      "caddy-naive",
}

TransportBinaries maps transport types to their required binaries.

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.

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"`
	// 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.

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) 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 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"`
	Naive      *NaiveConfig      `json:"naive,omitempty"`
}

TunnelConfig defines a single 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).

Jump to

Keyboard shortcuts

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