types.go 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. TotalPPPSessions int `json:"total_ppp_sessions"`
  18. PPPoEServerRunning bool `json:"pppoe_server_running"`
  19. PPTPServerRunning bool `json:"pptp_server_running"`
  20. L2TPServerRunning bool `json:"l2tp_server_running"`
  21. IPSecServerRunning bool `json:"ipsec_server_running"`
  22. TotalActiveTunnels int `json:"total_active_tunnels"`
  23. }
  24. // ======================== PPPoE Client (MikroTik style) ========================
  25. type PPPoEInstance struct {
  26. Name string `json:"name"` // e.g. "pppoe-out1", "pppoe-wan2"
  27. Interface string `json:"interface"` // Physical or VLAN interface, e.g. "eth0", "eth0.100"
  28. Username string `json:"username"`
  29. Password string `json:"password"`
  30. ServiceName string `json:"service_name,omitempty"`
  31. MTU int `json:"mtu"` // default 1492
  32. DefaultRoute bool `json:"default_route"`
  33. AutoReconnect bool `json:"auto_reconnect"`
  34. Disabled bool `json:"disabled"`
  35. Running bool `json:"running"` // MikroTik 'R' flag
  36. AssignedIP string `json:"assigned_ip,omitempty"`
  37. PPPDevice string `json:"ppp_device,omitempty"` // e.g. "ppp0"
  38. Uptime string `json:"uptime,omitempty"`
  39. LastError string `json:"last_error,omitempty"`
  40. }
  41. // ======================== WireGuard (MikroTik style) ========================
  42. type WireGuardPeer struct {
  43. Interface string `json:"interface"` // Name of parent WG interface (e.g. "wg0")
  44. Name string `json:"name"` // Friendly label (e.g. "Peer-Office", "Laptop")
  45. Comment string `json:"comment,omitempty"`
  46. PublicKey string `json:"public_key"`
  47. AllowedIPs []string `json:"allowed_ips"`
  48. EndpointAddress string `json:"endpoint_address,omitempty"`
  49. EndpointPort int `json:"endpoint_port,omitempty"`
  50. PersistentKeepalive int `json:"persistent_keepalive,omitempty"`
  51. PresharedKey string `json:"preshared_key,omitempty"`
  52. Disabled bool `json:"disabled"`
  53. LatestHandshake string `json:"latest_handshake,omitempty"`
  54. TransferRxBytes uint64 `json:"transfer_rx_bytes,omitempty"`
  55. TransferTxBytes uint64 `json:"transfer_tx_bytes,omitempty"`
  56. TransferRxHuman string `json:"transfer_rx_human,omitempty"`
  57. TransferTxHuman string `json:"transfer_tx_human,omitempty"`
  58. }
  59. type WireGuardInterface struct {
  60. Name string `json:"name"` // e.g. "wg0", "wg-office", "wg-site2site"
  61. ListenPort int `json:"listen_port"` // UDP port e.g. 51820
  62. PrivateKey string `json:"private_key"`
  63. PublicKey string `json:"public_key"`
  64. Address string `json:"address"` // e.g. "10.10.0.1/24"
  65. MTU int `json:"mtu"` // default 1420
  66. Comment string `json:"comment,omitempty"`
  67. Disabled bool `json:"disabled"`
  68. Running bool `json:"running"` // MikroTik 'R' flag
  69. PeersCount int `json:"peers_count"`
  70. Peers []WireGuardPeer `json:"peers"`
  71. LastError string `json:"last_error,omitempty"`
  72. }
  73. type SaveWireGuardInterfaceRequest struct {
  74. WireGuardInterface
  75. OrigName string `json:"orig_name,omitempty"`
  76. }
  77. type SaveWireGuardPeerRequest struct {
  78. WireGuardPeer
  79. OrigInterface string `json:"orig_interface,omitempty"`
  80. OrigPublicKey string `json:"orig_public_key,omitempty"`
  81. }
  82. // ======================== PPTP Client (MikroTik style) ========================
  83. type PPTPInstance struct {
  84. Name string `json:"name"` // e.g. "pptp-out1"
  85. ConnectTo string `json:"connect_to"` // Server IP / hostname
  86. Username string `json:"username"`
  87. Password string `json:"password"`
  88. RequireMPPE bool `json:"require_mppe"`
  89. DefaultRoute bool `json:"default_route"`
  90. AutoReconnect bool `json:"auto_reconnect"`
  91. Disabled bool `json:"disabled"`
  92. Running bool `json:"running"`
  93. AssignedIP string `json:"assigned_ip,omitempty"`
  94. PPPDevice string `json:"ppp_device,omitempty"`
  95. LastError string `json:"last_error,omitempty"`
  96. }
  97. // ======================== L2TP Client (MikroTik style) ========================
  98. type L2TPInstance struct {
  99. Name string `json:"name"` // e.g. "l2tp-out1"
  100. ConnectTo string `json:"connect_to"` // Server IP / hostname
  101. Username string `json:"username"`
  102. Password string `json:"password"`
  103. IPsecSecret string `json:"ipsec_secret,omitempty"` // For L2TP/IPsec
  104. DefaultRoute bool `json:"default_route"`
  105. Disabled bool `json:"disabled"`
  106. Running bool `json:"running"`
  107. AssignedIP string `json:"assigned_ip,omitempty"`
  108. PPPDevice string `json:"ppp_device,omitempty"`
  109. LastError string `json:"last_error,omitempty"`
  110. }
  111. // ======================== IPSec Connection / Policy (MikroTik style) ========================
  112. type IPSecConfig struct {
  113. Connections []IPSecConnection `json:"connections"`
  114. }
  115. type IPSecStatus struct {
  116. Running bool `json:"running"`
  117. ActiveSAs int `json:"active_sas"`
  118. Connections []IPSecConnection `json:"connections"`
  119. RawStatus string `json:"raw_status"`
  120. }
  121. type IPSecConnection struct {
  122. Name string `json:"name"` // e.g. "ipsec-peer1", "site-to-site"
  123. LocalAddrs string `json:"local_addrs"` // "%any" or local IP
  124. RemoteAddrs string `json:"remote_addrs"` // Remote Gateway IP or FQDN
  125. LocalSubnet string `json:"local_subnet"` // e.g. "192.168.10.0/24"
  126. RemoteSubnet string `json:"remote_subnet"` // e.g. "192.168.20.0/24"
  127. PresharedKey string `json:"preshared_key"`
  128. IKEProposals string `json:"ike_proposals"` // default: aes256-sha256-modp2048
  129. ESPProposals string `json:"esp_proposals"` // default: aes256-sha256-modp2048
  130. AutoStart bool `json:"auto_start"`
  131. Disabled bool `json:"disabled"`
  132. Running bool `json:"running"` // Active SA installed
  133. Status string `json:"status"` // "ESTABLISHED", "INSTALLED", "DISCONNECTED"
  134. }