types.go 8.7 KB

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