2022-08-16 15:37:51 +00:00
|
|
|
package option
|
|
|
|
|
2024-11-18 10:55:34 +00:00
|
|
|
import (
|
|
|
|
"net/netip"
|
|
|
|
|
|
|
|
"github.com/sagernet/sing/common/json/badoption"
|
|
|
|
)
|
2023-10-21 04:00:00 +00:00
|
|
|
|
2024-11-21 10:10:41 +00:00
|
|
|
type WireGuardEndpointOptions struct {
|
|
|
|
System bool `json:"system,omitempty"`
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
MTU uint32 `json:"mtu,omitempty"`
|
|
|
|
Address badoption.Listable[netip.Prefix] `json:"address"`
|
|
|
|
PrivateKey string `json:"private_key"`
|
|
|
|
ListenPort uint16 `json:"listen_port,omitempty"`
|
|
|
|
Peers []WireGuardPeer `json:"peers,omitempty"`
|
2024-11-24 06:45:40 +00:00
|
|
|
UDPTimeout badoption.Duration `json:"udp_timeout,omitempty"`
|
2024-11-21 10:10:41 +00:00
|
|
|
Workers int `json:"workers,omitempty"`
|
|
|
|
DialerOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
type WireGuardPeer struct {
|
|
|
|
Address string `json:"address,omitempty"`
|
|
|
|
Port uint16 `json:"port,omitempty"`
|
|
|
|
PublicKey string `json:"public_key,omitempty"`
|
|
|
|
PreSharedKey string `json:"pre_shared_key,omitempty"`
|
|
|
|
AllowedIPs badoption.Listable[netip.Prefix] `json:"allowed_ips,omitempty"`
|
|
|
|
PersistentKeepaliveInterval uint16 `json:"persistent_keepalive_interval,omitempty"`
|
|
|
|
Reserved []uint8 `json:"reserved,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type LegacyWireGuardOutboundOptions struct {
|
2022-09-03 04:55:10 +00:00
|
|
|
DialerOptions
|
2024-11-18 10:55:34 +00:00
|
|
|
SystemInterface bool `json:"system_interface,omitempty"`
|
|
|
|
GSO bool `json:"gso,omitempty"`
|
|
|
|
InterfaceName string `json:"interface_name,omitempty"`
|
|
|
|
LocalAddress badoption.Listable[netip.Prefix] `json:"local_address"`
|
|
|
|
PrivateKey string `json:"private_key"`
|
2024-11-21 10:10:41 +00:00
|
|
|
Peers []LegacyWireGuardPeer `json:"peers,omitempty"`
|
2023-03-31 04:31:26 +00:00
|
|
|
ServerOptions
|
|
|
|
PeerPublicKey string `json:"peer_public_key"`
|
|
|
|
PreSharedKey string `json:"pre_shared_key,omitempty"`
|
|
|
|
Reserved []uint8 `json:"reserved,omitempty"`
|
|
|
|
Workers int `json:"workers,omitempty"`
|
|
|
|
MTU uint32 `json:"mtu,omitempty"`
|
|
|
|
Network NetworkList `json:"network,omitempty"`
|
|
|
|
}
|
|
|
|
|
2024-11-21 10:10:41 +00:00
|
|
|
type LegacyWireGuardPeer struct {
|
2023-03-31 04:31:26 +00:00
|
|
|
ServerOptions
|
2024-11-21 10:10:41 +00:00
|
|
|
PublicKey string `json:"public_key,omitempty"`
|
|
|
|
PreSharedKey string `json:"pre_shared_key,omitempty"`
|
|
|
|
AllowedIPs badoption.Listable[netip.Prefix] `json:"allowed_ips,omitempty"`
|
|
|
|
Reserved []uint8 `json:"reserved,omitempty"`
|
2022-08-16 15:37:51 +00:00
|
|
|
}
|