types.go 5.9 KB

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