Add shadowtls (#49)

* Add shadowtls outbound

* Add shadowtls inbound

* Add shadowtls example

* Add shadowtls documentation
This commit is contained in:
世界
2022-08-31 14:21:53 +08:00
committed by GitHub
parent 917c4f0e91
commit 73746383cc
19 changed files with 586 additions and 15 deletions

View File

@@ -21,6 +21,7 @@ type _Inbound struct {
TrojanOptions TrojanInboundOptions `json:"-"`
NaiveOptions NaiveInboundOptions `json:"-"`
HysteriaOptions HysteriaInboundOptions `json:"-"`
ShadowTLSOptions ShadowTLSInboundOptions `json:"-"`
}
type Inbound _Inbound
@@ -52,6 +53,8 @@ func (h Inbound) MarshalJSON() ([]byte, error) {
v = h.NaiveOptions
case C.TypeHysteria:
v = h.HysteriaOptions
case C.TypeShadowTLS:
v = h.ShadowTLSOptions
default:
return nil, E.New("unknown inbound type: ", h.Type)
}
@@ -89,6 +92,8 @@ func (h *Inbound) UnmarshalJSON(bytes []byte) error {
v = &h.NaiveOptions
case C.TypeHysteria:
v = &h.HysteriaOptions
case C.TypeShadowTLS:
v = &h.ShadowTLSOptions
default:
return E.New("unknown inbound type: ", h.Type)
}

View File

@@ -20,6 +20,7 @@ type _Outbound struct {
HysteriaOptions HysteriaOutboundOptions `json:"-"`
TorOptions TorOutboundOptions `json:"-"`
SSHOptions SSHOutboundOptions `json:"-"`
ShadowTLSOptions ShadowTLSOutboundOptions `json:"-"`
SelectorOptions SelectorOutboundOptions `json:"-"`
}
@@ -50,6 +51,8 @@ func (h Outbound) MarshalJSON() ([]byte, error) {
v = h.TorOptions
case C.TypeSSH:
v = h.SSHOptions
case C.TypeShadowTLS:
v = h.ShadowTLSOptions
case C.TypeSelector:
v = h.SelectorOptions
default:
@@ -87,6 +90,8 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error {
v = &h.TorOptions
case C.TypeSSH:
v = &h.SSHOptions
case C.TypeShadowTLS:
v = &h.ShadowTLSOptions
case C.TypeSelector:
v = &h.SelectorOptions
default:

17
option/shadowtls.go Normal file
View File

@@ -0,0 +1,17 @@
package option
type ShadowTLSInboundOptions struct {
ListenOptions
Handshake ShadowTLSHandshakeOptions `json:"handshake"`
}
type ShadowTLSHandshakeOptions struct {
ServerOptions
DialerOptions
}
type ShadowTLSOutboundOptions struct {
OutboundDialerOptions
ServerOptions
TLS *OutboundTLSOptions `json:"tls,omitempty"`
}