domain

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultPort     = 10808
	DefaultDNS      = "1.1.1.1"
	DefaultLogLevel = "error"
	DefaultTunMTU   = 9000
	DefaultTunStack = "gvisor"
	DefaultRefresh  = 6
	DefaultProbeURL = "https://connectivitycheck.gstatic.com/generate_204"
	TunInterface    = "justray"
)
View Source
const (
	ProxyAll  = "proxy all"
	DirectAll = "direct all"
)

Variables

View Source
var (
	LogLevels  = []string{"error", "warn", "info", "debug"}
	TunStacks  = []string{"gvisor", "system", "mixed"}
	IPVersions = []string{"auto", "ipv4", "ipv6"}
	Modes      = []string{ProxyAll, DirectAll}
	Toggle     = []string{"on", "off"}
)

Functions

func ParseRule

func ParseRule(raw string) (string, error)

ParseRule canonicalises a network, domain or program rule

func SplitRules

func SplitRules(list []string) (cidrs, domains, keywords, names, paths []string)

SplitRules splits entries into cidrs, domains, keywords, names and paths

func ValidPort added in v1.0.1

func ValidPort(port int) bool

Types

type Auth

type Auth struct {
	UUID     string // vmess, vless, tuic
	Password string // trojan, ss, hysteria, anytls, tuic
	Username string // socks, http
	Method   string // ss cipher, vmess security
	Flow     string // vless, e.g. xtls
	AlterID  int    // legacy vmess
}

type General

type General struct {
	Autostart    string `yaml:"-"`                       // on/off, kept by the OS
	RefreshEvery int    `yaml:"refresh_hours,omitempty"` // 0 = never
	Port         int    `yaml:"port,omitempty"`
	LogLevel     string `yaml:"log_level,omitempty"`
	ProbeURL     string `yaml:"probe_url,omitempty"`
	Emoji        string `yaml:"emoji,omitempty"`
}

type Network

type Network struct {
	DNSHijack string `yaml:"dns_hijack,omitempty"` // on/off, empty = on
	DNS       string `yaml:"dns,omitempty"`
	IPVersion string `yaml:"ip_version,omitempty"`
	TunStack  string `yaml:"stack,omitempty"`
	TunMTU    int    `yaml:"mtu,omitempty"`
	TunStrict string `yaml:"strict_route,omitempty"` // on/off, empty = on
}

type Node

type Node struct {
	ID             string
	Name           string
	Protocol       Proto
	Server         string
	Port           int
	Auth           Auth
	Transport      Transport
	TLS            *TLS // nil means plaintext
	Reality        *Reality
	Obfs           string // hysteria2
	ObfsPassword   string // hysteria2, hysteria xplus
	UpMbps         int    // hysteria
	DownMbps       int    // hysteria
	Congestion     string // tuic
	UDPRelayMode   string // tuic
	PacketEncoding string // vless, vmess: xudp, packetaddr; empty = xudp
	ShadowTLS      *ShadowTLS
	WireGuard      *WireGuard
}

type NodeRef added in v1.2.0

type NodeRef struct {
	SubscriptionID string
	NodeID         string
}

type Proto

type Proto string
const (
	VMess  Proto = "vmess"
	VLess  Proto = "vless"
	Trojan Proto = "trojan"
	SS     Proto = "shadowsocks"
	HY1    Proto = "hysteria"
	HY2    Proto = "hysteria2"
	TUIC   Proto = "tuic"
	AnyTLS Proto = "anytls"
	SOCKS  Proto = "socks"
	HTTP   Proto = "http"
	WG     Proto = "wireguard"
	Shadow Proto = "shadowtls"
)

type Reality

type Reality struct {
	PublicKey string
	ShortID   string
}

type Routing

type Routing struct {
	Mode        string   `yaml:"mode,omitempty"`         // proxy-all/direct-all, empty = proxy-all
	BypassLocal string   `yaml:"bypass_local,omitempty"` // on/off, empty = on
	BlockQUIC   string   `yaml:"block_quic,omitempty"`   // on/off, empty = off
	Except      []string `yaml:"except,omitempty"`
	Blocked     []string `yaml:"blocked,omitempty"`
}

type Settings

type Settings struct {
	General `yaml:"general,omitempty"`
	Network `yaml:"network,omitempty"`
	Routing `yaml:"routing,omitempty"`
}

func (Settings) Equal

func (s Settings) Equal(o Settings) bool

func (Settings) IPv4

func (s Settings) IPv4() bool

func (Settings) IPv6

func (s Settings) IPv6() bool

func (Settings) Normalize

func (s Settings) Normalize() (Settings, error)

Normalize fills defaults and validates

type ShadowTLS

type ShadowTLS struct {
	Version  int
	Password string
	SNI      string
}

type TLS

type TLS struct {
	SNI         string
	ALPN        []string
	Fingerprint string
	Insecure    bool
}

type Traffic

type Traffic struct {
	UploadBytes   int64     `yaml:"upload_bytes,omitempty"`
	DownloadBytes int64     `yaml:"download_bytes,omitempty"`
	TotalBytes    int64     `yaml:"total_bytes,omitempty"`
	ExpiresAt     time.Time `yaml:"expires_at,omitempty"`
}

type Transport

type Transport struct {
	Network     string // tcp, ws, grpc, quic, xhttp
	Path        string
	Host        string
	ServiceName string // grpc
	Mode        string // xhttp: auto, packet-up, stream-up, stream-one
}

type WireGuard

type WireGuard struct {
	PrivateKey    string
	PeerPublicKey string
	PreSharedKey  string
	Address       []string
	Reserved      []uint8
	MTU           uint32
}

Jump to

Keyboard shortcuts

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