wireguard.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. Address badoption.Listable[netip.Prefix] `json:"address"`
  11. PrivateKey string `json:"private_key"`
  12. ListenPort uint16 `json:"listen_port,omitempty"`
  13. Peers []WireGuardPeer `json:"peers,omitempty"`
  14. UDPTimeout badoption.Duration `json:"udp_timeout,omitempty"`
  15. Workers int `json:"workers,omitempty"`
  16. DialerOptions
  17. }
  18. type WireGuardPeer struct {
  19. Address string `json:"address,omitempty"`
  20. Port uint16 `json:"port,omitempty"`
  21. PublicKey string `json:"public_key,omitempty"`
  22. PreSharedKey string `json:"pre_shared_key,omitempty"`
  23. AllowedIPs badoption.Listable[netip.Prefix] `json:"allowed_ips,omitempty"`
  24. PersistentKeepaliveInterval uint16 `json:"persistent_keepalive_interval,omitempty"`
  25. Reserved []uint8 `json:"reserved,omitempty"`
  26. }
  27. type LegacyWireGuardOutboundOptions struct {
  28. DialerOptions
  29. SystemInterface bool `json:"system_interface,omitempty"`
  30. GSO bool `json:"gso,omitempty"`
  31. InterfaceName string `json:"interface_name,omitempty"`
  32. LocalAddress badoption.Listable[netip.Prefix] `json:"local_address"`
  33. PrivateKey string `json:"private_key"`
  34. Peers []LegacyWireGuardPeer `json:"peers,omitempty"`
  35. ServerOptions
  36. PeerPublicKey string `json:"peer_public_key"`
  37. PreSharedKey string `json:"pre_shared_key,omitempty"`
  38. Reserved []uint8 `json:"reserved,omitempty"`
  39. Workers int `json:"workers,omitempty"`
  40. MTU uint32 `json:"mtu,omitempty"`
  41. Network NetworkList `json:"network,omitempty"`
  42. }
  43. type LegacyWireGuardPeer struct {
  44. ServerOptions
  45. PublicKey string `json:"public_key,omitempty"`
  46. PreSharedKey string `json:"pre_shared_key,omitempty"`
  47. AllowedIPs badoption.Listable[netip.Prefix] `json:"allowed_ips,omitempty"`
  48. Reserved []uint8 `json:"reserved,omitempty"`
  49. }