package vpn import "debtik/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) } }