Add wireguard outbound and test

This commit is contained in:
世界
2022-08-16 23:37:51 +08:00
parent ca94a2ddcb
commit d6a0aa7ccf
20 changed files with 724 additions and 55 deletions

View File

@@ -16,6 +16,7 @@ type _Outbound struct {
ShadowsocksOptions ShadowsocksOutboundOptions `json:"-"`
VMessOptions VMessOutboundOptions `json:"-"`
TrojanOptions TrojanOutboundOptions `json:"-"`
WireGuardOptions WireGuardOutboundOptions `json:"-"`
SelectorOptions SelectorOutboundOptions `json:"-"`
}
@@ -38,6 +39,8 @@ func (h Outbound) MarshalJSON() ([]byte, error) {
v = h.VMessOptions
case C.TypeTrojan:
v = h.TrojanOptions
case C.TypeWireGuard:
v = h.WireGuardOptions
case C.TypeSelector:
v = h.SelectorOptions
default:
@@ -67,6 +70,8 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error {
v = &h.VMessOptions
case C.TypeTrojan:
v = &h.TrojanOptions
case C.TypeWireGuard:
v = &h.WireGuardOptions
case C.TypeSelector:
v = &h.SelectorOptions
default:

12
option/wireguard.go Normal file
View File

@@ -0,0 +1,12 @@
package option
type WireGuardOutboundOptions struct {
OutboundDialerOptions
ServerOptions
LocalAddress Listable[string] `json:"local_address"`
PrivateKey string `json:"private_key"`
PeerPublicKey string `json:"peer_public_key"`
PreSharedKey string `json:"pre_shared_key,omitempty"`
MTU uint32 `json:"mtu,omitempty"`
Network NetworkList `json:"network,omitempty"`
}