singbox

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Trojan      = "trojan"
	VLESS       = "vless"
	VMess       = "vmess"
	TUIC        = "tuic"
	Hysteria2   = "hysteria2"
	AnyTLS      = "anytls"
	Shadowsocks = "shadowsocks"
	Selector    = "selector"
	URLTest     = "urltest"
	Direct      = "direct"
	Block       = "block"
	DNS         = "dns"
)
View Source
const DefaultTemplate = `` /* 1947-byte string literal not displayed */

Variables

This section is empty.

Functions

func BuildSingbox

func BuildSingbox(adapter proxy.Adapter, uuid string) ([]byte, error)

Types

type AnyTLSOutboundOptions added in v1.0.2

type AnyTLSOutboundOptions struct {
	ServerOptions
	OutboundTLSOptionsContainer
	Password string `json:"password,omitempty"`
}

type BrutalOptions

type BrutalOptions struct {
	Enabled  bool `json:"enabled,omitempty"`
	UpMbps   int  `json:"up_mbps,omitempty"`
	DownMbps int  `json:"down_mbps,omitempty"`
}

type Duration

type Duration time.Duration

type HTTPHeader

type HTTPHeader map[string]Listable[string]

type Hysteria2Obfs

type Hysteria2Obfs struct {
	Type     string `json:"type,omitempty"`
	Password string `json:"password,omitempty"`
}

type Hysteria2OutboundOptions

type Hysteria2OutboundOptions struct {
	ServerOptions
	ServerPorts []string       `json:"server_ports,omitempty"`
	HopInterval int            `json:"hop_interval,omitempty"`
	UpMbps      int            `json:"up_mbps,omitempty"`
	DownMbps    int            `json:"down_mbps,omitempty"`
	Obfs        *Hysteria2Obfs `json:"obfs,omitempty"`
	Password    string         `json:"password,omitempty"`
	Network     string         `json:"network,omitempty"`
	OutboundTLSOptionsContainer
	Multiplex *OutboundMultiplexOptions `json:"multiplex,omitempty"`
	Transport *V2RayTransportOptions    `json:"transport,omitempty"`
}

type Listable

type Listable[T any] []T

type OutboundECHOptions

type OutboundECHOptions struct {
	Enabled                     bool             `json:"enabled,omitempty"`
	PQSignatureSchemesEnabled   bool             `json:"pq_signature_schemes_enabled,omitempty"`
	DynamicRecordSizingDisabled bool             `json:"dynamic_record_sizing_disabled,omitempty"`
	Config                      Listable[string] `json:"config,omitempty"`
	ConfigPath                  string           `json:"config_path,omitempty"`
}

type OutboundMultiplexOptions

type OutboundMultiplexOptions struct {
	Enabled        bool           `json:"enabled,omitempty"`
	Protocol       string         `json:"protocol,omitempty"`
	MaxConnections int            `json:"max_connections,omitempty"`
	MinStreams     int            `json:"min_streams,omitempty"`
	MaxStreams     int            `json:"max_streams,omitempty"`
	Padding        bool           `json:"padding,omitempty"`
	Brutal         *BrutalOptions `json:"brutal,omitempty"`
}

type OutboundOptions

type OutboundOptions struct {
	Tag  string `json:"tag"`
	Type string `json:"type"`
}

type OutboundRealityOptions

type OutboundRealityOptions struct {
	Enabled   bool   `json:"enabled,omitempty"`
	PublicKey string `json:"public_key,omitempty"`
	ShortID   string `json:"short_id,omitempty"`
}

type OutboundTLSOptions

type OutboundTLSOptions struct {
	Enabled         bool                    `json:"enabled,omitempty"`
	DisableSNI      bool                    `json:"disable_sni,omitempty"`
	ServerName      string                  `json:"server_name,omitempty"`
	Insecure        bool                    `json:"insecure,omitempty"`
	ALPN            Listable[string]        `json:"alpn,omitempty"`
	MinVersion      string                  `json:"min_version,omitempty"`
	MaxVersion      string                  `json:"max_version,omitempty"`
	CipherSuites    Listable[string]        `json:"cipher_suites,omitempty"`
	Certificate     Listable[string]        `json:"certificate,omitempty"`
	CertificatePath string                  `json:"certificate_path,omitempty"`
	ECH             *OutboundECHOptions     `json:"ech,omitempty"`
	UTLS            *OutboundUTLSOptions    `json:"utls,omitempty"`
	Reality         *OutboundRealityOptions `json:"reality,omitempty"`
}

func NewOutboundTLSOptions

func NewOutboundTLSOptions(security string, cfg proxy.SecurityConfig) *OutboundTLSOptions

type OutboundTLSOptionsContainer

type OutboundTLSOptionsContainer struct {
	TLS *OutboundTLSOptions `json:"tls,omitempty"`
}

type OutboundUTLSOptions

type OutboundUTLSOptions struct {
	Enabled     bool   `json:"enabled,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
}

type Proxy

type Proxy struct {
	Tag                string                    `json:"tag,omitempty"`
	Type               string                    `json:"type"`
	ShadowsocksOptions *ShadowsocksOptions       `json:"-"`
	TUICOptions        *TUICOutboundOptions      `json:"-"`
	TrojanOptions      *TrojanOutboundOptions    `json:"-"`
	VLESSOptions       *VLESSOutboundOptions     `json:"-"`
	VMessOptions       *VMessOutboundOptions     `json:"-"`
	AnyTLSOptions      *AnyTLSOutboundOptions    `json:"-"`
	Hysteria2Options   *Hysteria2OutboundOptions `json:"-"`
	SelectorOptions    *SelectorOutboundOptions  `json:"-"`
	URLTestOptions     *URLTestOutboundOptions   `json:"-"`
}

func ParseAnyTLS added in v1.0.2

func ParseAnyTLS(data proxy.Proxy, password string) (*Proxy, error)

func ParseHysteria2

func ParseHysteria2(data proxy.Proxy, password string) (*Proxy, error)

func ParseShadowsocks

func ParseShadowsocks(data proxy.Proxy, uuid string) (*Proxy, error)

func ParseTUIC

func ParseTUIC(data proxy.Proxy, uuid string) (*Proxy, error)

func ParseTrojan

func ParseTrojan(data proxy.Proxy, uuid string) (*Proxy, error)

func ParseVMess

func ParseVMess(data proxy.Proxy, uuid string) (*Proxy, error)

func ParseVless

func ParseVless(data proxy.Proxy, uuid string) (*Proxy, error)

func (Proxy) MarshalJSON

func (p Proxy) MarshalJSON() ([]byte, error)

type RouteOptions

type RouteOptions struct {
	Rules               []Rule    `json:"rules,omitempty"`
	Final               string    `json:"final,omitempty"`
	RuleSet             []RuleSet `json:"rule_set,omitempty"`
	AutoDetectInterface bool      `json:"auto_detect_interface,omitempty"`
}

type Rule

type Rule struct {
	Outbound      string   `json:"outbound,omitempty"`
	ClashMode     string   `json:"clash_mode,omitempty"`
	RuleSet       []string `json:"rule_set,omitempty"`
	Domain        []string `json:"domain,omitempty"`
	DomainSuffix  []string `json:"domain_suffix,omitempty"`
	DomainKeyword []string `json:"domain_keyword,omitempty"`
	DomainRegex   []string `json:"domain_regex,omitempty"`
	GeoIP         []string `json:"geoip,omitempty"`
	IPCIDR        []string `json:"ip_cidr,omitempty"`
	IPIsPrivate   bool     `json:"ip_is_private,omitempty"`
	SourceIPCIDR  []string `json:"source_ip_cidr,omitempty"`
	ProcessName   []string `json:"process_name,omitempty"`
	ProcessPath   []string `json:"process_path,omitempty"`
	SourcePort    []uint16 `json:"source_port,omitempty"`
	Protocol      []string `json:"protocol,omitempty"`
	Port          []uint16 `json:"port,omitempty"`
	Action        string   `json:"action,omitempty"`
	Inbound       []string `json:"inbound,omitempty"`
	Rules         []Rule   `json:"rules,omitempty"`
	Type          string   `json:"type,omitempty"`
	Mode          string   `json:"mode,omitempty"`
}

type RuleSet

type RuleSet struct {
	Tag            string `json:"tag,omitempty"`
	Type           string `json:"type,omitempty"`
	Format         string `json:"format,omitempty"`
	URL            string `json:"url,omitempty"`
	DownloadDetour string `json:"download_detour,omitempty"`
}

type SelectorOutboundOptions

type SelectorOutboundOptions struct {
	OutboundOptions
	Outbounds                 []string `json:"outbounds"`
	Default                   string   `json:"default,omitempty"`
	InterruptExistConnections bool     `json:"interrupt_exist_connections,omitempty"`
}

type ServerOptions

type ServerOptions struct {
	Tag        string `json:"tag"`
	Type       string `json:"type"`
	Server     string `json:"server"`
	ServerPort int    `json:"server_port,omitempty"`
}

type ShadowsocksOptions

type ShadowsocksOptions struct {
	ServerOptions
	Method        string `json:"method,omitempty"`
	Password      string `json:"password,omitempty"`
	Plugin        string `json:"plugin,omitempty"`
	PluginOptions string `json:"plugin_opts,omitempty"`
	Network       string `json:"network,omitempty"`
}

type TUICOutboundOptions

type TUICOutboundOptions struct {
	ServerOptions
	UUID              string `json:"uuid,omitempty"`
	Password          string `json:"password,omitempty"`
	CongestionControl string `json:"congestion_control,omitempty"`
	UDPRelayMode      string `json:"udp_relay_mode,omitempty"`
	UDPOverStream     bool   `json:"udp_over_stream,omitempty"`
	ZeroRTTHandshake  bool   `json:"zero_rtt_handshake,omitempty"`
	Heartbeat         string `json:"heartbeat,omitempty"`
	Network           string `json:"network,omitempty"`
	OutboundTLSOptionsContainer
}

type TrojanOutboundOptions

type TrojanOutboundOptions struct {
	ServerOptions
	Password string `json:"password"`
	Network  string `json:"network,omitempty"`
	OutboundTLSOptionsContainer
	Multiplex *OutboundMultiplexOptions `json:"multiplex,omitempty"`
	Transport *V2RayTransportOptions    `json:"transport,omitempty"`
}

type URLTestOutboundOptions

type URLTestOutboundOptions struct {
	OutboundOptions
	Outbounds                 []string `json:"outbounds"`
	URL                       string   `json:"url,omitempty"`
	Interval                  Duration `json:"interval,omitempty"`
	Tolerance                 uint16   `json:"tolerance,omitempty"`
	IdleTimeout               Duration `json:"idle_timeout,omitempty"`
	InterruptExistConnections bool     `json:"interrupt_exist_connections,omitempty"`
}

type V2RayGRPCOptions

type V2RayGRPCOptions struct {
	ServiceName         string `json:"service_name,omitempty"`
	IdleTimeout         string `json:"idle_timeout,omitempty"`
	PingTimeout         string `json:"ping_timeout,omitempty"`
	PermitWithoutStream bool   `json:"permit_without_stream,omitempty"`
	ForceLite           bool   `json:"-"` // for test
}

type V2RayHTTPOptions

type V2RayHTTPOptions struct {
	Host        Listable[string] `json:"host,omitempty"`
	Path        string           `json:"path,omitempty"`
	Method      string           `json:"method,omitempty"`
	Headers     HTTPHeader       `json:"headers,omitempty"`
	IdleTimeout Duration         `json:"idle_timeout,omitempty"`
	PingTimeout Duration         `json:"ping_timeout,omitempty"`
}

type V2RayHTTPUpgradeOptions

type V2RayHTTPUpgradeOptions struct {
	Host    string     `json:"host,omitempty"`
	Path    string     `json:"path,omitempty"`
	Headers HTTPHeader `json:"headers,omitempty"`
}

type V2RayQUICOptions

type V2RayQUICOptions struct{}

type V2RayTransportOptions

type V2RayTransportOptions struct {
	Type               string                  `json:"type"`
	HTTPOptions        V2RayHTTPOptions        `json:"-"`
	WebsocketOptions   V2RayWebsocketOptions   `json:"-"`
	QUICOptions        V2RayQUICOptions        `json:"-"`
	GRPCOptions        V2RayGRPCOptions        `json:"-"`
	HTTPUpgradeOptions V2RayHTTPUpgradeOptions `json:"-"`
}

func NewV2RayTransportOptions

func NewV2RayTransportOptions(network string, transport proxy.TransportConfig) *V2RayTransportOptions

func (V2RayTransportOptions) MarshalJSON

func (v V2RayTransportOptions) MarshalJSON() ([]byte, error)

type V2RayWebsocketOptions

type V2RayWebsocketOptions struct {
	Path                string     `json:"path,omitempty"`
	Headers             HTTPHeader `json:"headers,omitempty"`
	MaxEarlyData        uint32     `json:"max_early_data,omitempty"`
	EarlyDataHeaderName string     `json:"early_data_header_name,omitempty"`
}

type VLESSOutboundOptions

type VLESSOutboundOptions struct {
	ServerOptions
	OutboundTLSOptionsContainer
	UUID           string                    `json:"uuid"`
	Flow           string                    `json:"flow,omitempty"`
	Network        string                    `json:"network,omitempty"`
	Multiplex      *OutboundMultiplexOptions `json:"multiplex,omitempty"`
	Transport      *V2RayTransportOptions    `json:"transport,omitempty"`
	PacketEncoding *string                   `json:"packet_encoding,omitempty"`
}

type VMessOutboundOptions

type VMessOutboundOptions struct {
	ServerOptions
	UUID                string                    `json:"uuid"`
	Security            string                    `json:"security"`
	AlterId             int                       `json:"alter_id,omitempty"`
	GlobalPadding       bool                      `json:"global_padding,omitempty"`
	AuthenticatedLength bool                      `json:"authenticated_length,omitempty"`
	Network             string                    `json:"network,omitempty"`
	PacketEncoding      string                    `json:"packet_encoding,omitempty"`
	Multiplex           *OutboundMultiplexOptions `json:"multiplex,omitempty"`
	Transport           *V2RayTransportOptions    `json:"transport,omitempty"`
	OutboundTLSOptionsContainer
}

Jump to

Keyboard shortcuts

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