wireguard.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package option
  2. import (
  3. "net/netip"
  4. "github.com/sagernet/sing/common/json/badoption"
  5. )
  6. type WireGuardEndpointOptions struct {
  7. System bool `json:"system,omitempty"`
  8. Name string `json:"name,omitempty"`
  9. MTU uint32 `json:"mtu,omitempty"`
  10. GSO bool `json:"gso,omitempty"`
  11. Address badoption.Listable[netip.Prefix] `json:"address"`
  12. PrivateKey string `json:"private_key"`
  13. ListenPort uint16 `json:"listen_port,omitempty"`
  14. Peers []WireGuardPeer `json:"peers,omitempty"`
  15. UDPTimeout UDPTimeoutCompat `json:"udp_timeout,omitempty"`
  16. Workers int `json:"workers,omitempty"`
  17. DialerOptions
  18. }
  19. type WireGuardPeer struct {
  20. Address string `json:"address,omitempty"`
  21. Port uint16 `json:"port,omitempty"`
  22. PublicKey string `json:"public_key,omitempty"`
  23. PreSharedKey string `json:"pre_shared_key,omitempty"`
  24. AllowedIPs badoption.Listable[netip.Prefix] `json:"allowed_ips,omitempty"`
  25. PersistentKeepaliveInterval uint16 `json:"persistent_keepalive_interval,omitempty"`
  26. Reserved []uint8 `json:"reserved,omitempty"`
  27. }
  28. type LegacyWireGuardOutboundOptions struct {
  29. DialerOptions
  30. SystemInterface bool `json:"system_interface,omitempty"`
  31. GSO bool `json:"gso,omitempty"`
  32. InterfaceName string `json:"interface_name,omitempty"`
  33. LocalAddress badoption.Listable[netip.Prefix] `json:"local_address"`
  34. PrivateKey string `json:"private_key"`
  35. Peers []LegacyWireGuardPeer `json:"peers,omitempty"`
  36. ServerOptions
  37. PeerPublicKey string `json:"peer_public_key"`
  38. PreSharedKey string `json:"pre_shared_key,omitempty"`
  39. Reserved []uint8 `json:"reserved,omitempty"`
  40. Workers int `json:"workers,omitempty"`
  41. MTU uint32 `json:"mtu,omitempty"`
  42. Network NetworkList `json:"network,omitempty"`
  43. }
  44. type LegacyWireGuardPeer struct {
  45. ServerOptions
  46. PublicKey string `json:"public_key,omitempty"`
  47. PreSharedKey string `json:"pre_shared_key,omitempty"`
  48. AllowedIPs badoption.Listable[netip.Prefix] `json:"allowed_ips,omitempty"`
  49. Reserved []uint8 `json:"reserved,omitempty"`
  50. }