domain

package
v1.4.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultPort     = 10808
	DefaultDNS      = "8.8.8.8"
	DefaultLogLevel = "error"
	DefaultTunMTU   = 9000
	DefaultTunStack = "gvisor"
	DefaultRefresh  = 6
	DefaultProbeURL = "http://www.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

func ValidPort(port int) bool

Types

type Auth

type Auth struct {
	UUID     string `yaml:"uuid,omitempty"`     // vmess, vless, tuic
	Password string `yaml:"password,omitempty"` // trojan, ss, hysteria, anytls, tuic
	Username string `yaml:"username,omitempty"` // socks, http
	Method   string `yaml:"method,omitempty"`   // ss cipher, vmess security
	Flow     string `yaml:"flow,omitempty"`     // vless, e.g. xtls
	AlterID  int    `yaml:"alter_id,omitempty"` // 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     `yaml:"id"`
	Name           string     `yaml:"name,omitempty"`
	Protocol       Proto      `yaml:"protocol"`
	Server         string     `yaml:"server"`
	Port           int        `yaml:"port"`
	Auth           Auth       `yaml:"auth,omitempty"`
	Transport      Transport  `yaml:"transport,omitempty"`
	TLS            *TLS       `yaml:"tls,omitempty"`
	Reality        *Reality   `yaml:"reality,omitempty"`
	Obfs           string     `yaml:"obfs,omitempty"`            // hysteria2
	ObfsPassword   string     `yaml:"obfs_password,omitempty"`   // hysteria2, hysteria xplus
	UpMbps         int        `yaml:"up_mbps,omitempty"`         // hysteria
	DownMbps       int        `yaml:"down_mbps,omitempty"`       // hysteria
	Congestion     string     `yaml:"congestion,omitempty"`      // tuic
	UDPRelayMode   string     `yaml:"udp_relay_mode,omitempty"`  // tuic
	PacketEncoding string     `yaml:"packet_encoding,omitempty"` // vless, vmess: xudp, packetaddr; empty = xudp
	ShadowTLS      *ShadowTLS `yaml:"shadow_tls,omitempty"`
	WireGuard      *WireGuard `yaml:"wireguard,omitempty"`
}

type NodeRef

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 `yaml:"public_key,omitempty"`
	ShortID   string `yaml:"short_id,omitempty"`
}

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    `yaml:"version,omitempty"`
	Password string `yaml:"password,omitempty"`
	SNI      string `yaml:"sni,omitempty"`
}

type TLS

type TLS struct {
	SNI         string   `yaml:"sni,omitempty"`
	ALPN        []string `yaml:"alpn,omitempty"`
	Fingerprint string   `yaml:"fingerprint,omitempty"`
	Insecure    bool     `yaml:"insecure,omitempty"`
}

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 `yaml:"network,omitempty"` // tcp, ws, grpc, quic, xhttp
	Path        string `yaml:"path,omitempty"`
	Host        string `yaml:"host,omitempty"`
	ServiceName string `yaml:"service_name,omitempty"` // grpc
	Mode        string `yaml:"mode,omitempty"`         // xhttp: auto, packet-up, stream-up, stream-one
	Extra       string `yaml:"extra,omitempty"`
}

type WireGuard

type WireGuard struct {
	PrivateKey    string   `yaml:"private_key,omitempty"`
	PeerPublicKey string   `yaml:"peer_public_key,omitempty"`
	PreSharedKey  string   `yaml:"pre_shared_key,omitempty"`
	Address       []string `yaml:"address,omitempty"`
	Reserved      []uint8  `yaml:"reserved,omitempty"`
	MTU           uint32   `yaml:"mtu,omitempty"`
}

Jump to

Keyboard shortcuts

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