1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-23 15:14:43 -05:00
This commit is contained in:
Nite07 2024-05-21 15:28:09 +08:00
parent 98bca0a7ac
commit 0946412ea7

View File

@ -5,62 +5,82 @@ type SmuxStruct struct {
} }
type Proxy struct { type Proxy struct {
Name string `yaml:"name,omitempty"` Name string `yaml:"name,omitempty"`
Server string `yaml:"server,omitempty"` Server string `yaml:"server,omitempty"`
Port int `yaml:"port,omitempty"` Port int `yaml:"port,omitempty"`
Type string `yaml:"type,omitempty"` Type string `yaml:"type,omitempty"`
Cipher string `yaml:"cipher,omitempty"` Cipher string `yaml:"cipher,omitempty"`
Password string `yaml:"password,omitempty"` Password string `yaml:"password,omitempty"`
UDP bool `yaml:"udp,omitempty"` UDP bool `yaml:"udp,omitempty"`
UUID string `yaml:"uuid,omitempty"` UUID string `yaml:"uuid,omitempty"`
Network string `yaml:"network,omitempty"` Network string `yaml:"network,omitempty"`
Flow string `yaml:"flow,omitempty"` Flow string `yaml:"flow,omitempty"`
TLS bool `yaml:"tls,omitempty"` TLS bool `yaml:"tls,omitempty"`
ClientFingerprint string `yaml:"client-fingerprint,omitempty"` ClientFingerprint string `yaml:"client-fingerprint,omitempty"`
Plugin string `yaml:"plugin,omitempty"` Plugin string `yaml:"plugin,omitempty"`
PluginOpts map[string]any `yaml:"plugin-opts,omitempty"` PluginOpts map[string]any `yaml:"plugin-opts,omitempty"`
Smux SmuxStruct `yaml:"smux,omitempty"` Smux SmuxStruct `yaml:"smux,omitempty"`
Sni string `yaml:"sni,omitempty"` Sni string `yaml:"sni,omitempty"`
AllowInsecure bool `yaml:"allow-insecure,omitempty"` AllowInsecure bool `yaml:"allow-insecure,omitempty"`
Fingerprint string `yaml:"fingerprint,omitempty"` Fingerprint string `yaml:"fingerprint,omitempty"`
SkipCertVerify bool `yaml:"skip-cert-verify,omitempty"` SkipCertVerify bool `yaml:"skip-cert-verify,omitempty"`
Alpn []string `yaml:"alpn,omitempty"` Alpn []string `yaml:"alpn,omitempty"`
XUDP bool `yaml:"xudp,omitempty"` XUDP bool `yaml:"xudp,omitempty"`
Servername string `yaml:"servername,omitempty"` Servername string `yaml:"servername,omitempty"`
WSOpts WSOptions `yaml:"ws-opts,omitempty"` WSOpts WSOptions `yaml:"ws-opts,omitempty"`
AlterID int `yaml:"alterId,omitempty"` AlterID int `yaml:"alterId,omitempty"`
GrpcOpts GrpcOptions `yaml:"grpc-opts,omitempty"` GrpcOpts GrpcOptions `yaml:"grpc-opts,omitempty"`
RealityOpts RealityOptions `yaml:"reality-opts,omitempty"` RealityOpts RealityOptions `yaml:"reality-opts,omitempty"`
Protocol string `yaml:"protocol,omitempty"` Protocol string `yaml:"protocol,omitempty"`
Obfs string `yaml:"obfs,omitempty"` Obfs string `yaml:"obfs,omitempty"`
ObfsParam string `yaml:"obfs-param,omitempty"` ObfsParam string `yaml:"obfs-param,omitempty"`
ProtocolParam string `yaml:"protocol-param,omitempty"` ProtocolParam string `yaml:"protocol-param,omitempty"`
Remarks []string `yaml:"remarks,omitempty"` Remarks []string `yaml:"remarks,omitempty"`
HTTPOpts HTTPOptions `yaml:"http-opts,omitempty"` HTTPOpts HTTPOptions `yaml:"http-opts,omitempty"`
HTTP2Opts HTTP2Options `yaml:"h2-opts,omitempty"` HTTP2Opts HTTP2Options `yaml:"h2-opts,omitempty"`
PacketAddr bool `yaml:"packet-addr,omitempty"` PacketAddr bool `yaml:"packet-addr,omitempty"`
PacketEncoding string `yaml:"packet-encoding,omitempty"` PacketEncoding string `yaml:"packet-encoding,omitempty"`
GlobalPadding bool `yaml:"global-padding,omitempty"` GlobalPadding bool `yaml:"global-padding,omitempty"`
AuthenticatedLength bool `yaml:"authenticated-length,omitempty"` AuthenticatedLength bool `yaml:"authenticated-length,omitempty"`
UDPOverTCP bool `yaml:"udp-over-tcp,omitempty"` UDPOverTCP bool `yaml:"udp-over-tcp,omitempty"`
UDPOverTCPVersion int `yaml:"udp-over-tcp-version,omitempty"` UDPOverTCPVersion int `yaml:"udp-over-tcp-version,omitempty"`
SubName string `yaml:"-"` SubName string `yaml:"-"`
Up string `yaml:"up,omitempty"` Up string `yaml:"up,omitempty"`
Down string `yaml:"down,omitempty"` Down string `yaml:"down,omitempty"`
CustomCA string `yaml:"ca,omitempty"` CustomCA string `yaml:"ca,omitempty"`
CustomCAString string `yaml:"ca-str,omitempty"` CustomCAString string `yaml:"ca-str,omitempty"`
CWND int `yaml:"cwnd,omitempty"` CWND int `yaml:"cwnd,omitempty"`
Auth string `yaml:"auth,omitempty"` Auth string `yaml:"auth,omitempty"`
ReceiveWindowConn int `yaml:"recv-window-conn,omitempty"` ReceiveWindowConn int `yaml:"recv-window-conn,omitempty"`
ReceiveWindow int `yaml:"recv-window,omitempty"` ReceiveWindow int `yaml:"recv-window,omitempty"`
DisableMTUDiscovery bool `yaml:"disable-mtu-discovery,omitempty"` DisableMTUDiscovery bool `yaml:"disable-mtu-discovery,omitempty"`
FastOpen bool `yaml:"fast-open,omitempty"` FastOpen bool `yaml:"fast-open,omitempty"`
HopInterval int `yaml:"hop-interval,omitempty"` HopInterval int `yaml:"hop-interval,omitempty"`
Ports string `yaml:"ports,omitempty"` Ports string `yaml:"ports,omitempty"`
AuthStringOLD string `yaml:"auth_str,omitempty"` AuthStringOLD string `yaml:"auth_str,omitempty"`
AuthString 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"`
} }
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"`
}
type _Proxy Proxy
func (p Proxy) MarshalYAML() (interface{}, error) { func (p Proxy) MarshalYAML() (interface{}, error) {
switch p.Type { switch p.Type {
case "vmess": case "vmess":
@ -77,6 +97,7 @@ func (p Proxy) MarshalYAML() (interface{}, error) {
return ProxyToHysteria(p), nil return ProxyToHysteria(p), nil
case "hysteria2": case "hysteria2":
return ProxyToHysteria2(p), nil return ProxyToHysteria2(p), nil
default:
return _Proxy(p), nil
} }
return nil, nil
} }