proxy

package
v0.0.12-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllMarshalers

func GetAllMarshalers() map[string]ProxyMarshaler

GetAllMarshalers 获取所有注册的序列化器

func GetSupportedTypes

func GetSupportedTypes() []string

GetSupportedTypes 获取所有支持的协议类型

func RegisterMarshaler

func RegisterMarshaler(marshaler ProxyMarshaler)

RegisterMarshaler 注册YAML序列化器

Types

type Anytls

type Anytls struct {
	Type                     string   `yaml:"type"`
	Name                     string   `yaml:"name"`
	Server                   string   `yaml:"server"`
	Port                     int      `yaml:"port"`
	Password                 string   `yaml:"password,omitempty"`
	Alpn                     []string `yaml:"alpn,omitempty"`
	SNI                      string   `yaml:"sni,omitempty"`
	ClientFingerprint        string   `yaml:"client-fingerprint,omitempty"`
	SkipCertVerify           bool     `yaml:"skip-cert-verify,omitempty"`
	Fingerprint              string   `yaml:"fingerprint,omitempty"`
	UDP                      bool     `yaml:"udp,omitempty"`
	IdleSessionCheckInterval int      `yaml:"idle-session-check-interval,omitempty"`
	IdleSessionTimeout       int      `yaml:"idle-session-timeout,omitempty"`
	MinIdleSession           int      `yaml:"min-idle-session,omitempty"`
}

func ProxyToAnytls

func ProxyToAnytls(p Proxy) Anytls

type AnytlsMarshaler

type AnytlsMarshaler struct{}

func (*AnytlsMarshaler) GetType

func (m *AnytlsMarshaler) GetType() string

func (*AnytlsMarshaler) MarshalProxy

func (m *AnytlsMarshaler) MarshalProxy(p Proxy) (interface{}, error)

type GrpcOptions

type GrpcOptions struct {
	GrpcServiceName string `yaml:"grpc-service-name,omitempty"`
}

type HTTP2Options

type HTTP2Options struct {
	Host []string `yaml:"host,omitempty"`
	Path string   `yaml:"path,omitempty"`
}

type HTTPOptions

type HTTPOptions struct {
	Method  string              `yaml:"method,omitempty"`
	Path    []string            `yaml:"path,omitempty"`
	Headers map[string][]string `yaml:"headers,omitempty"`
}

type Hysteria

type Hysteria struct {
	Type                string   `yaml:"type"`
	Name                string   `yaml:"name"`
	Server              string   `yaml:"server"`
	Port                int      `yaml:"port,omitempty"`
	Ports               string   `yaml:"ports,omitempty"`
	Protocol            string   `yaml:"protocol,omitempty"`
	ObfsProtocol        string   `yaml:"obfs-protocol,omitempty"`
	Up                  string   `yaml:"up"`
	UpSpeed             int      `yaml:"up-speed,omitempty"`
	Down                string   `yaml:"down"`
	DownSpeed           int      `yaml:"down-speed,omitempty"`
	Auth                string   `yaml:"auth,omitempty"`
	AuthStringOLD       string   `yaml:"auth_str,omitempty"`
	AuthString          string   `yaml:"auth-str,omitempty"`
	Obfs                string   `yaml:"obfs,omitempty"`
	SNI                 string   `yaml:"sni,omitempty"`
	SkipCertVerify      bool     `yaml:"skip-cert-verify,omitempty"`
	Fingerprint         string   `yaml:"fingerprint,omitempty"`
	ALPN                []string `yaml:"alpn,omitempty"`
	CustomCA            string   `yaml:"ca,omitempty"`
	CustomCAString      string   `yaml:"ca-str,omitempty"`
	ReceiveWindowConn   int      `yaml:"recv-window-conn,omitempty"`
	ReceiveWindow       int      `yaml:"recv-window,omitempty"`
	DisableMTUDiscovery bool     `yaml:"disable-mtu-discovery,omitempty"`
	FastOpen            bool     `yaml:"fast-open,omitempty"`
	HopInterval         int      `yaml:"hop-interval,omitempty"`
}

func ProxyToHysteria

func ProxyToHysteria(p Proxy) Hysteria

type Hysteria2

type Hysteria2 struct {
	Type           string   `yaml:"type"`
	Name           string   `yaml:"name"`
	Server         string   `yaml:"server"`
	Port           int      `yaml:"port"`
	Up             string   `yaml:"up,omitempty"`
	Down           string   `yaml:"down,omitempty"`
	Password       string   `yaml:"password,omitempty"`
	Obfs           string   `yaml:"obfs,omitempty"`
	ObfsPassword   string   `yaml:"obfs-password,omitempty"`
	SNI            string   `yaml:"sni,omitempty"`
	SkipCertVerify bool     `yaml:"skip-cert-verify,omitempty"`
	Fingerprint    string   `yaml:"fingerprint,omitempty"`
	ALPN           []string `yaml:"alpn,omitempty"`
	CustomCA       string   `yaml:"ca,omitempty"`
	CustomCAString string   `yaml:"ca-str,omitempty"`
	CWND           int      `yaml:"cwnd,omitempty"`
}

func ProxyToHysteria2

func ProxyToHysteria2(p Proxy) Hysteria2

type Hysteria2Marshaler

type Hysteria2Marshaler struct{}

func (*Hysteria2Marshaler) GetType

func (m *Hysteria2Marshaler) GetType() string

func (*Hysteria2Marshaler) MarshalProxy

func (m *Hysteria2Marshaler) MarshalProxy(p Proxy) (interface{}, error)

type HysteriaMarshaler

type HysteriaMarshaler struct{}

func (*HysteriaMarshaler) GetType

func (m *HysteriaMarshaler) GetType() string

func (*HysteriaMarshaler) MarshalProxy

func (m *HysteriaMarshaler) MarshalProxy(p Proxy) (interface{}, error)

type Proxy

type Proxy struct {
	Name                     string                `yaml:"name,omitempty"`
	Server                   string                `yaml:"server,omitempty"`
	Port                     int                   `yaml:"port,omitempty"`
	Type                     string                `yaml:"type,omitempty"`
	Cipher                   string                `yaml:"cipher,omitempty"`
	Username                 string                `yaml:"username,omitempty"`
	Password                 string                `yaml:"password,omitempty"`
	UDP                      bool                  `yaml:"udp,omitempty"`
	UUID                     string                `yaml:"uuid,omitempty"`
	Network                  string                `yaml:"network,omitempty"`
	Flow                     string                `yaml:"flow,omitempty"`
	TLS                      bool                  `yaml:"tls,omitempty"`
	ClientFingerprint        string                `yaml:"client-fingerprint,omitempty"`
	Plugin                   string                `yaml:"plugin,omitempty"`
	PluginOpts               map[string]any        `yaml:"plugin-opts,omitempty"`
	Smux                     SmuxStruct            `yaml:"smux,omitempty"`
	Sni                      string                `yaml:"sni,omitempty"`
	AllowInsecure            bool                  `yaml:"allow-insecure,omitempty"`
	Fingerprint              string                `yaml:"fingerprint,omitempty"`
	SkipCertVerify           bool                  `yaml:"skip-cert-verify,omitempty"`
	Alpn                     []string              `yaml:"alpn,omitempty"`
	XUDP                     bool                  `yaml:"xudp,omitempty"`
	Servername               string                `yaml:"servername,omitempty"`
	WSOpts                   WSOptions             `yaml:"ws-opts,omitempty"`
	AlterID                  int                   `yaml:"alterId,omitempty"`
	GrpcOpts                 GrpcOptions           `yaml:"grpc-opts,omitempty"`
	RealityOpts              RealityOptions        `yaml:"reality-opts,omitempty"`
	Protocol                 string                `yaml:"protocol,omitempty"`
	Obfs                     string                `yaml:"obfs,omitempty"`
	ObfsParam                string                `yaml:"obfs-param,omitempty"`
	ProtocolParam            string                `yaml:"protocol-param,omitempty"`
	Remarks                  []string              `yaml:"remarks,omitempty"`
	HTTPOpts                 HTTPOptions           `yaml:"http-opts,omitempty"`
	HTTP2Opts                HTTP2Options          `yaml:"h2-opts,omitempty"`
	PacketAddr               bool                  `yaml:"packet-addr,omitempty"`
	PacketEncoding           string                `yaml:"packet-encoding,omitempty"`
	GlobalPadding            bool                  `yaml:"global-padding,omitempty"`
	AuthenticatedLength      bool                  `yaml:"authenticated-length,omitempty"`
	UDPOverTCP               bool                  `yaml:"udp-over-tcp,omitempty"`
	UDPOverTCPVersion        int                   `yaml:"udp-over-tcp-version,omitempty"`
	SubName                  string                `yaml:"-"`
	Up                       string                `yaml:"up,omitempty"`
	Down                     string                `yaml:"down,omitempty"`
	CustomCA                 string                `yaml:"ca,omitempty"`
	CustomCAString           string                `yaml:"ca-str,omitempty"`
	CWND                     int                   `yaml:"cwnd,omitempty"`
	Auth                     string                `yaml:"auth,omitempty"`
	ReceiveWindowConn        int                   `yaml:"recv-window-conn,omitempty"`
	ReceiveWindow            int                   `yaml:"recv-window,omitempty"`
	DisableMTUDiscovery      bool                  `yaml:"disable-mtu-discovery,omitempty"`
	FastOpen                 bool                  `yaml:"fast-open,omitempty"`
	HopInterval              int                   `yaml:"hop-interval,omitempty"`
	Ports                    string                `yaml:"ports,omitempty"`
	AuthStringOLD            string                `yaml:"auth_str,omitempty"`
	AuthString               string                `yaml:"auth-str,omitempty"`
	Ip                       string                `yaml:"ip,omitempty"`
	Ipv6                     string                `yaml:"ipv6,omitempty"`
	PrivateKey               string                `yaml:"private-key,omitempty"`
	Workers                  int                   `yaml:"workers,omitempty"`
	MTU                      int                   `yaml:"mtu,omitempty"`
	PersistentKeepalive      int                   `yaml:"persistent-keepalive,omitempty"`
	Peers                    []WireGuardPeerOption `yaml:"peers,omitempty"`
	RemoteDnsResolve         bool                  `yaml:"remote-dns-resolve,omitempty"`
	Dns                      []string              `yaml:"dns,omitempty"`
	IdleSessionCheckInterval int                   `yaml:"idle-session-check-interval,omitempty"`
	IdleSessionTimeout       int                   `yaml:"idle-session-timeout,omitempty"`
	MinIdleSession           int                   `yaml:"min-idle-session,omitempty"`
}

func (Proxy) MarshalYAML

func (p Proxy) MarshalYAML() (interface{}, error)

type ProxyMarshaler

type ProxyMarshaler interface {
	// MarshalProxy 将通用Proxy对象序列化为特定协议的YAML结构
	MarshalProxy(p Proxy) (interface{}, error)
	// GetType 返回支持的协议类型
	GetType() string
}

ProxyMarshaler 代理YAML序列化接口

func GetMarshaler

func GetMarshaler(proxyType string) (ProxyMarshaler, bool)

GetMarshaler 根据协议类型获取序列化器

type RealityOptions

type RealityOptions struct {
	PublicKey string `yaml:"public-key"`
	ShortID   string `yaml:"short-id,omitempty"`
}

type ShadowSocks

type ShadowSocks struct {
	Type              string         `yaml:"type"`
	Name              string         `yaml:"name"`
	Server            string         `yaml:"server"`
	Port              int            `yaml:"port"`
	Password          string         `yaml:"password"`
	Cipher            string         `yaml:"cipher"`
	UDP               bool           `yaml:"udp,omitempty"`
	Plugin            string         `yaml:"plugin,omitempty"`
	PluginOpts        map[string]any `yaml:"plugin-opts,omitempty"`
	UDPOverTCP        bool           `yaml:"udp-over-tcp,omitempty"`
	UDPOverTCPVersion int            `yaml:"udp-over-tcp-version,omitempty"`
	ClientFingerprint string         `yaml:"client-fingerprint,omitempty"`
}

func ProxyToShadowSocks

func ProxyToShadowSocks(p Proxy) ShadowSocks

type ShadowSocksR

type ShadowSocksR struct {
	Type          string `yaml:"type"`
	Name          string `yaml:"name"`
	Server        string `yaml:"server"`
	Port          int    `yaml:"port"`
	Password      string `yaml:"password"`
	Cipher        string `yaml:"cipher"`
	Obfs          string `yaml:"obfs"`
	ObfsParam     string `yaml:"obfs-param,omitempty"`
	Protocol      string `yaml:"protocol"`
	ProtocolParam string `yaml:"protocol-param,omitempty"`
	UDP           bool   `yaml:"udp,omitempty"`
}

func ProxyToShadowSocksR

func ProxyToShadowSocksR(p Proxy) ShadowSocksR

type ShadowsocksMarshaler

type ShadowsocksMarshaler struct{}

ShadowsocksMarshaler Shadowsocks协议的YAML序列化器

func (*ShadowsocksMarshaler) GetType

func (m *ShadowsocksMarshaler) GetType() string

GetType 返回协议类型

func (*ShadowsocksMarshaler) MarshalProxy

func (m *ShadowsocksMarshaler) MarshalProxy(p Proxy) (interface{}, error)

MarshalProxy 序列化Shadowsocks代理

type ShadowsocksRMarshaler

type ShadowsocksRMarshaler struct{}

func (*ShadowsocksRMarshaler) GetType

func (m *ShadowsocksRMarshaler) GetType() string

func (*ShadowsocksRMarshaler) MarshalProxy

func (m *ShadowsocksRMarshaler) MarshalProxy(p Proxy) (interface{}, error)

type SmuxStruct

type SmuxStruct struct {
	Enabled bool `yaml:"enable"`
}

type Trojan

type Trojan struct {
	Type              string         `yaml:"type"`
	Name              string         `yaml:"name"`
	Server            string         `yaml:"server"`
	Port              int            `yaml:"port"`
	Password          string         `yaml:"password"`
	ALPN              []string       `yaml:"alpn,omitempty"`
	SNI               string         `yaml:"sni,omitempty"`
	SkipCertVerify    bool           `yaml:"skip-cert-verify,omitempty"`
	Fingerprint       string         `yaml:"fingerprint,omitempty"`
	UDP               bool           `yaml:"udp,omitempty"`
	Network           string         `yaml:"network,omitempty"`
	RealityOpts       RealityOptions `yaml:"reality-opts,omitempty"`
	GrpcOpts          GrpcOptions    `yaml:"grpc-opts,omitempty"`
	WSOpts            WSOptions      `yaml:"ws-opts,omitempty"`
	ClientFingerprint string         `yaml:"client-fingerprint,omitempty"`
}

func ProxyToTrojan

func ProxyToTrojan(p Proxy) Trojan

type TrojanMarshaler

type TrojanMarshaler struct{}

func (*TrojanMarshaler) GetType

func (m *TrojanMarshaler) GetType() string

func (*TrojanMarshaler) MarshalProxy

func (m *TrojanMarshaler) MarshalProxy(p Proxy) (interface{}, error)

type Vless

type Vless struct {
	Type              string            `yaml:"type"`
	Name              string            `yaml:"name"`
	Server            string            `yaml:"server"`
	Port              int               `yaml:"port"`
	UUID              string            `yaml:"uuid"`
	Flow              string            `yaml:"flow,omitempty"`
	TLS               bool              `yaml:"tls,omitempty"`
	ALPN              []string          `yaml:"alpn,omitempty"`
	UDP               bool              `yaml:"udp,omitempty"`
	PacketAddr        bool              `yaml:"packet-addr,omitempty"`
	XUDP              bool              `yaml:"xudp,omitempty"`
	PacketEncoding    string            `yaml:"packet-encoding,omitempty"`
	Network           string            `yaml:"network,omitempty"`
	RealityOpts       RealityOptions    `yaml:"reality-opts,omitempty"`
	HTTPOpts          HTTPOptions       `yaml:"http-opts,omitempty"`
	HTTP2Opts         HTTP2Options      `yaml:"h2-opts,omitempty"`
	GrpcOpts          GrpcOptions       `yaml:"grpc-opts,omitempty"`
	WSOpts            WSOptions         `yaml:"ws-opts,omitempty"`
	WSPath            string            `yaml:"ws-path,omitempty"`
	WSHeaders         map[string]string `yaml:"ws-headers,omitempty"`
	SkipCertVerify    bool              `yaml:"skip-cert-verify,omitempty"`
	Fingerprint       string            `yaml:"fingerprint,omitempty"`
	ServerName        string            `yaml:"servername,omitempty"`
	ClientFingerprint string            `yaml:"client-fingerprint,omitempty"`
}

func ProxyToVless

func ProxyToVless(p Proxy) Vless

type VlessMarshaler

type VlessMarshaler struct{}

func (*VlessMarshaler) GetType

func (m *VlessMarshaler) GetType() string

func (*VlessMarshaler) MarshalProxy

func (m *VlessMarshaler) MarshalProxy(p Proxy) (interface{}, error)

type Vmess

type Vmess struct {
	Type                string         `yaml:"type"`
	Name                string         `yaml:"name"`
	Server              string         `yaml:"server"`
	Port                int            `yaml:"port"`
	UUID                string         `yaml:"uuid"`
	AlterID             int            `yaml:"alterId"`
	Cipher              string         `yaml:"cipher"`
	UDP                 bool           `yaml:"udp,omitempty"`
	Network             string         `yaml:"network,omitempty"`
	TLS                 bool           `yaml:"tls,omitempty"`
	ALPN                []string       `yaml:"alpn,omitempty"`
	SkipCertVerify      bool           `yaml:"skip-cert-verify,omitempty"`
	Fingerprint         string         `yaml:"fingerprint,omitempty"`
	ServerName          string         `yaml:"servername,omitempty"`
	RealityOpts         RealityOptions `yaml:"reality-opts,omitempty"`
	HTTPOpts            HTTPOptions    `yaml:"http-opts,omitempty"`
	HTTP2Opts           HTTP2Options   `yaml:"h2-opts,omitempty"`
	GrpcOpts            GrpcOptions    `yaml:"grpc-opts,omitempty"`
	WSOpts              WSOptions      `yaml:"ws-opts,omitempty"`
	PacketAddr          bool           `yaml:"packet-addr,omitempty"`
	XUDP                bool           `yaml:"xudp,omitempty"`
	PacketEncoding      string         `yaml:"packet-encoding,omitempty"`
	GlobalPadding       bool           `yaml:"global-padding,omitempty"`
	AuthenticatedLength bool           `yaml:"authenticated-length,omitempty"`
	ClientFingerprint   string         `yaml:"client-fingerprint,omitempty"`
}

func ProxyToVmess

func ProxyToVmess(p Proxy) Vmess

type VmessJson

type VmessJson struct {
	V    string      `json:"v"`
	Ps   string      `json:"ps"`
	Add  string      `json:"add"`
	Port interface{} `json:"port"`
	Id   string      `json:"id"`
	Aid  interface{} `json:"aid"`
	Scy  string      `json:"scy"`
	Net  string      `json:"net"`
	Type string      `json:"type"`
	Host string      `json:"host"`
	Path string      `json:"path"`
	Tls  string      `json:"tls"`
	Sni  string      `json:"sni"`
	Alpn string      `json:"alpn"`
	Fp   string      `json:"fp"`
}

type VmessMarshaler

type VmessMarshaler struct{}

func (*VmessMarshaler) GetType

func (m *VmessMarshaler) GetType() string

func (*VmessMarshaler) MarshalProxy

func (m *VmessMarshaler) MarshalProxy(p Proxy) (interface{}, error)

type WSOptions

type WSOptions struct {
	Path                string            `yaml:"path,omitempty"`
	Headers             map[string]string `yaml:"headers,omitempty"`
	MaxEarlyData        int               `yaml:"max-early-data,omitempty"`
	EarlyDataHeaderName string            `yaml:"early-data-header-name,omitempty"`
}

type WireGuardPeerOption

type WireGuardPeerOption struct {
	Server       string   `yaml:"server"`
	Port         int      `yaml:"port"`
	PublicKey    string   `yaml:"public-key,omitempty"`
	PreSharedKey string   `yaml:"pre-shared-key,omitempty"`
	Reserved     []uint8  `yaml:"reserved,omitempty"`
	AllowedIPs   []string `yaml:"allowed-ips,omitempty"`
}

Jump to

Keyboard shortcuts

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