| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- package vpn
- import "proxmox-router/internal/aerotun"
- type Manager struct {
- PPPoE *PPPoEManager
- WireGuard *WireGuardManager
- PPTP *PPTPManager
- L2TP *L2TPManager
- IPSec *IPSecManager
- EoIP *EoIPManager
- PPPServer *PPPServerManager
- AeroTUN *aerotun.Manager
- }
- func NewManager() *Manager {
- pppServer := NewPPPServerManager()
- l2tpMgr := NewL2TPManager()
- l2tpMgr.SetPPPServer(pppServer)
- pptpMgr := NewPPTPManager()
- pptpMgr.SetPPPServer(pppServer)
- return &Manager{
- PPPoE: NewPPPoEManager(),
- WireGuard: NewWireGuardManager(),
- PPTP: pptpMgr,
- L2TP: l2tpMgr,
- IPSec: NewIPSecManager(),
- EoIP: NewEoIPManager(),
- PPPServer: pppServer,
- AeroTUN: aerotun.NewManager(),
- }
- }
- // GetOverallStatus returns a summary of all active instances across all protocols.
- func (m *Manager) GetOverallStatus() OverallVPNStatus {
- pppoeList := m.PPPoE.List()
- wgIfaces := m.WireGuard.ListInterfaces()
- wgPeers := m.WireGuard.ListPeers("")
- pptpList := m.PPTP.List()
- l2tpList := m.L2TP.List()
- ipsecList := m.IPSec.List()
- eoipList := m.EoIP.List()
- activePPPoE := 0
- for _, p := range pppoeList {
- if p.Running {
- activePPPoE++
- }
- }
- activeWG := 0
- for _, w := range wgIfaces {
- if w.Running {
- activeWG++
- }
- }
- activePPTP := 0
- for _, p := range pptpList {
- if p.Running {
- activePPTP++
- }
- }
- activeL2TP := 0
- for _, l := range l2tpList {
- if l.Running {
- activeL2TP++
- }
- }
- activeIPSec := 0
- for _, i := range ipsecList {
- if i.Running {
- activeIPSec++
- }
- }
- activeEoIP := 0
- for _, e := range eoipList {
- if e.Running {
- activeEoIP++
- }
- }
- aeroStats := m.AeroTUN.GetSummaryStats()
- pppoeSrv := m.PPPServer.GetPPPoEServer()
- pptpSrv := m.PPPServer.GetPPTPServer()
- l2tpSrv := m.PPPServer.GetL2TPServer()
- ipsecSrv := m.PPPServer.GetIPSecServer()
- pppSessions := len(m.PPPServer.ListActiveSessions())
- totalActive := activePPPoE + activeWG + activePPTP + activeL2TP + activeIPSec + activeEoIP + aeroStats.ActiveTunnels + pppSessions
- return OverallVPNStatus{
- TotalPPPoE: len(pppoeList),
- ActivePPPoE: activePPPoE,
- TotalWireGuard: len(wgIfaces),
- ActiveWireGuard: activeWG,
- TotalWireGuardPeers: len(wgPeers),
- TotalPPTP: len(pptpList),
- ActivePPTP: activePPTP,
- TotalL2TP: len(l2tpList),
- ActiveL2TP: activeL2TP,
- TotalIPSec: len(ipsecList),
- ActiveIPSec: activeIPSec,
- TotalEoIP: len(eoipList),
- ActiveEoIP: activeEoIP,
- TotalAeroTUN: aeroStats.TotalTunnels,
- ActiveAeroTUN: aeroStats.ActiveTunnels,
- AeroTUNSavedBytes: aeroStats.TotalSavedBytes,
- AeroTUNRatio: aeroStats.AverageRatio,
- TotalPPPSessions: pppSessions,
- PPPoEServerRunning: pppoeSrv.Running,
- PPTPServerRunning: pptpSrv.Running,
- L2TPServerRunning: l2tpSrv.Running,
- IPSecServerRunning: ipsecSrv.Running,
- TotalActiveTunnels: totalActive,
- }
- }
- // RenameInterface updates VPN client interface references when an interface is renamed.
- func (m *Manager) RenameInterface(oldName, newName string) {
- if m.PPPoE != nil {
- m.PPPoE.RenameInterface(oldName, newName)
- }
- }
|