mirror of
https://github.com/bestnite/sub2clash.git
synced 2025-06-17 20:53:18 +08:00
refactor
This commit is contained in:
51
model/proxy/anytls.go
Normal file
51
model/proxy/anytls.go
Normal file
@ -0,0 +1,51 @@
|
||||
package proxy
|
||||
|
||||
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(p Proxy) Anytls {
|
||||
return Anytls{
|
||||
Type: "anytls",
|
||||
Name: p.Name,
|
||||
Server: p.Server,
|
||||
Port: p.Port,
|
||||
Password: p.Password,
|
||||
Alpn: p.Alpn,
|
||||
SNI: p.Sni,
|
||||
ClientFingerprint: p.ClientFingerprint,
|
||||
SkipCertVerify: p.SkipCertVerify,
|
||||
Fingerprint: p.Fingerprint,
|
||||
UDP: p.UDP,
|
||||
IdleSessionCheckInterval: p.IdleSessionCheckInterval,
|
||||
IdleSessionTimeout: p.IdleSessionTimeout,
|
||||
MinIdleSession: p.MinIdleSession,
|
||||
}
|
||||
}
|
||||
|
||||
type AnytlsMarshaler struct{}
|
||||
|
||||
func (m *AnytlsMarshaler) GetType() string {
|
||||
return "anytls"
|
||||
}
|
||||
|
||||
func (m *AnytlsMarshaler) MarshalProxy(p Proxy) (interface{}, error) {
|
||||
return ProxyToAnytls(p), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterMarshaler(&AnytlsMarshaler{})
|
||||
}
|
Reference in New Issue
Block a user