| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package vpn
- type Manager struct {
- PPPoE *PPPoEManager
- WireGuard *WireGuardManager
- PPTP *PPTPManager
- L2TP *L2TPManager
- IPSec *IPSecManager
- }
- func NewManager() *Manager {
- return &Manager{
- PPPoE: NewPPPoEManager(),
- WireGuard: NewWireGuardManager(),
- PPTP: NewPPTPManager(),
- L2TP: NewL2TPManager(),
- IPSec: NewIPSecManager(),
- }
- }
- // 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()
- 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++
- }
- }
- totalActive := activePPPoE + activeWG + activePPTP + activeL2TP + activeIPSec
- 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,
- TotalActiveTunnels: totalActive,
- }
- }
|