types.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package vpn
  2. // OverallVPNStatus provides quick telemetry for the sidebar badges
  3. type OverallVPNStatus struct {
  4. TotalPPPoE int `json:"total_pppoe"`
  5. ActivePPPoE int `json:"active_pppoe"`
  6. TotalWireGuard int `json:"total_wireguard"`
  7. ActiveWireGuard int `json:"active_wireguard"`
  8. TotalWireGuardPeers int `json:"total_wg_peers"`
  9. TotalPPTP int `json:"total_pptp"`
  10. ActivePPTP int `json:"active_pptp"`
  11. TotalL2TP int `json:"total_l2tp"`
  12. ActiveL2TP int `json:"active_l2tp"`
  13. TotalIPSec int `json:"total_ipsec"`
  14. ActiveIPSec int `json:"active_ipsec"`
  15. TotalEoIP int `json:"total_eoip"`
  16. ActiveEoIP int `json:"active_eoip"`
  17. TotalAeroTUN int `json:"total_aerotun"`
  18. ActiveAeroTUN int `json:"active_aerotun"`
  19. AeroTUNSavedBytes uint64 `json:"aerotun_saved_bytes"`
  20. AeroTUNRatio string `json:"aerotun_ratio"`
  21. TotalPPPSessions int `json:"total_ppp_sessions"`
  22. PPPoEServerRunning bool `json:"pppoe_server_running"`
  23. PPTPServerRunning bool `json:"pptp_server_running"`
  24. L2TPServerRunning bool `json:"l2tp_server_running"`
  25. IPSecServerRunning bool `json:"ipsec_server_running"`
  26. TotalActiveTunnels int `json:"total_active_tunnels"`
  27. }
  28. // ======================== PPPoE Client (MikroTik style) ========================
  29. type PPPoEInstance struct {
  30. Name string `json:"name"` // e.g. "pppoe-out1", "pppoe-wan2"
  31. Interface string `json:"interface"` // Physical or VLAN interface, e.g. "eth0", "eth0.100"
  32. Username string `json:"username"`
  33. Password string `json:"password"`
  34. Profile string `json:"profile,omitempty"` // PPP Profile from /ppp profile (default "default")
  35. ServiceName string `json:"service_name,omitempty"`
  36. MTU int `json:"mtu"` // default 1492
  37. DefaultRoute bool `json:"default_route"`
  38. AutoReconnect bool `json:"auto_reconnect"`
  39. Disabled bool `json:"disabled"`
  40. Running bool `json:"running"` // MikroTik 'R' flag
  41. AssignedIP string `json:"assigned_ip,omitempty"`
  42. PPPDevice string `json:"ppp_device,omitempty"` // e.g. "ppp0"
  43. Uptime string `json:"uptime,omitempty"`
  44. LastError string `json:"last_error,omitempty"`
  45. }
  46. // ======================== WireGuard (MikroTik style) ========================
  47. type WireGuardPeer struct {
  48. Interface string `json:"interface"` // Name of parent WG interface (e.g. "wg0")
  49. Name string `json:"name"` // Friendly label (e.g. "Peer-Office", "Laptop")
  50. Comment string `json:"comment,omitempty"`
  51. PublicKey string `json:"public_key"`
  52. AllowedIPs []string `json:"allowed_ips"`
  53. EndpointAddress string `json:"endpoint_address,omitempty"`
  54. EndpointPort int `json:"endpoint_port,omitempty"`
  55. PersistentKeepalive int `json:"persistent_keepalive,omitempty"`
  56. PresharedKey string `json:"preshared_key,omitempty"`
  57. Disabled bool `json:"disabled"`
  58. LatestHandshake string `json:"latest_handshake,omitempty"`
  59. TransferRxBytes uint64 `json:"transfer_rx_bytes,omitempty"`
  60. TransferTxBytes uint64 `json:"transfer_tx_bytes,omitempty"`
  61. TransferRxHuman string `json:"transfer_rx_human,omitempty"`
  62. TransferTxHuman string `json:"transfer_tx_human,omitempty"`
  63. }
  64. type WireGuardInterface struct {
  65. Name string `json:"name"` // e.g. "wg0", "wg-office", "wg-site2site"
  66. ListenPort int `json:"listen_port"` // UDP port e.g. 51820
  67. PrivateKey string `json:"private_key"`
  68. PublicKey string `json:"public_key"`
  69. Address string `json:"address"` // e.g. "10.10.0.1/24"
  70. MTU int `json:"mtu"` // default 1420
  71. Comment string `json:"comment,omitempty"`
  72. Disabled bool `json:"disabled"`
  73. Running bool `json:"running"` // MikroTik 'R' flag
  74. PeersCount int `json:"peers_count"`
  75. Peers []WireGuardPeer `json:"peers"`
  76. LastError string `json:"last_error,omitempty"`
  77. }
  78. type SaveWireGuardInterfaceRequest struct {
  79. WireGuardInterface
  80. OrigName string `json:"orig_name,omitempty"`
  81. }
  82. type SaveWireGuardPeerRequest struct {
  83. WireGuardPeer
  84. OrigInterface string `json:"orig_interface,omitempty"`
  85. OrigPublicKey string `json:"orig_public_key,omitempty"`
  86. }
  87. // ======================== PPTP Client (MikroTik style) ========================
  88. type PPTPInstance struct {
  89. Name string `json:"name"` // e.g. "pptp-out1"
  90. ConnectTo string `json:"connect_to"` // Server IP / hostname
  91. Username string `json:"username"`
  92. Password string `json:"password"`
  93. Profile string `json:"profile,omitempty"` // PPP Profile from /ppp profile (default "default-encryption")
  94. RequireMPPE bool `json:"require_mppe"`
  95. DefaultRoute bool `json:"default_route"`
  96. AutoReconnect bool `json:"auto_reconnect"`
  97. Disabled bool `json:"disabled"`
  98. Running bool `json:"running"`
  99. AssignedIP string `json:"assigned_ip,omitempty"`
  100. PPPDevice string `json:"ppp_device,omitempty"`
  101. LastError string `json:"last_error,omitempty"`
  102. }
  103. // ======================== L2TP Client (MikroTik style) ========================
  104. type L2TPInstance struct {
  105. Name string `json:"name"` // e.g. "l2tp-out1"
  106. ConnectTo string `json:"connect_to"` // Server IP / hostname
  107. Username string `json:"username"`
  108. Password string `json:"password"`
  109. Profile string `json:"profile,omitempty"` // PPP Profile from /ppp profile (default "default-encryption")
  110. IPsecSecret string `json:"ipsec_secret,omitempty"` // For L2TP/IPsec
  111. DefaultRoute bool `json:"default_route"`
  112. Disabled bool `json:"disabled"`
  113. Running bool `json:"running"`
  114. AssignedIP string `json:"assigned_ip,omitempty"`
  115. PPPDevice string `json:"ppp_device,omitempty"`
  116. LastError string `json:"last_error,omitempty"`
  117. }
  118. // ======================== IPSec Connection / Policy (FortiGate Phase 1 & 2 Style) ========================
  119. type IPSecConfig struct {
  120. Connections []IPSecConnection `json:"connections"`
  121. }
  122. type IPSecStatus struct {
  123. Running bool `json:"running"`
  124. ActiveSAs int `json:"active_sas"`
  125. Connections []IPSecConnection `json:"connections"`
  126. RawStatus string `json:"raw_status"`
  127. }
  128. type IPSecConnection struct {
  129. Name string `json:"name"` // Tunnel name, e.g. "VPN_HQ", "to_branch"
  130. Comments string `json:"comments"` // FortiGate Comments
  131. // Network & Phase 1 (IKE Gateway)
  132. Interface string `json:"interface"` // Local interface or %any
  133. LocalAddrs string `json:"local_addrs"` // "%any" or local IP
  134. RemoteAddrs string `json:"remote_addrs"` // Remote Gateway IP or FQDN
  135. IKEVersion string `json:"ike_version"` // "ikev2" (default) or "ikev1"
  136. AuthMethod string `json:"auth_method"` // "psk"
  137. PresharedKey string `json:"preshared_key"`
  138. LocalID string `json:"local_id,omitempty"`
  139. RemoteID string `json:"remote_id,omitempty"`
  140. IKEProposals string `json:"ike_proposals"` // default: aes256-sha256-modp2048,default
  141. IKEKeylife int `json:"ike_keylife"` // seconds, default 86400
  142. DPD string `json:"dpd"` // "on-demand" (default), "periodic", "disabled"
  143. NATTraversal bool `json:"nat_traversal"` // default true
  144. // Phase 2 (IPsec / Selectors)
  145. Phase2Name string `json:"phase2_name"` // e.g. "VPN_HQ_p2"
  146. ESPProposals string `json:"esp_proposals"` // default: aes256-sha256-modp2048,default
  147. PFS bool `json:"pfs"` // Perfect Forward Secrecy, default true
  148. PFSGroup string `json:"pfs_group"` // e.g. "modp2048" (DH 14), "ecp256" (DH 19)
  149. ESPKeylife int `json:"esp_keylife"` // seconds, default 28800
  150. AutoStart bool `json:"auto_start"` // default true
  151. // Traffic Selectors: Multiple Subnets support!
  152. LocalSubnets []string `json:"local_subnets"` // e.g. ["192.168.10.0/24", "10.0.1.0/24", "172.16.0.0/16"]
  153. RemoteSubnets []string `json:"remote_subnets"` // e.g. ["192.168.20.0/24", "10.0.2.0/24", "172.17.0.0/16"]
  154. LocalSubnet string `json:"local_subnet"` // Backward compatibility
  155. RemoteSubnet string `json:"remote_subnet"` // Backward compatibility
  156. Disabled bool `json:"disabled"`
  157. Running bool `json:"running"` // Active SA installed
  158. Status string `json:"status"` // "ESTABLISHED", "INSTALLED", "DISCONNECTED"
  159. }