MCPcopy Create free account
hub / github.com/PasarGuard/node / GetUserOnlineIpListStats

Method GetUserOnlineIpListStats

backend/wireguard/stats.go:122–151  ·  view source on GitHub ↗
(ctx context.Context, email string)

Source from the content-addressed store, hash-verified

120}
121
122func (wg *WireGuard) GetUserOnlineIpListStats(ctx context.Context, email string) (*common.StatsOnlineIpListResponse, error) {
123 wg.mu.RLock()
124 state := wg.state
125 wg.mu.RUnlock()
126
127 if state != lifecycleRunning {
128 return nil, errWireGuardNotStarted
129 }
130
131 response := &common.StatsOnlineIpListResponse{
132 Name: email,
133 Ips: make(map[string]int64),
134 }
135
136 // Get user's public key directly from PeerStore
137 var keys []string
138 if peer := wg.peerStore.GetByEmail(email); peer != nil {
139 keys = []string{peer.PublicKey.String()}
140 }
141 if len(keys) == 0 {
142 return response, nil
143 }
144
145 endpointActivity := wg.statsTracker.EndpointActivity(keys)
146 for endpointIP, ts := range endpointActivity {
147 response.Ips[endpointIP] = ts
148 }
149
150 return response, nil
151}
152
153// GetSysStats returns system stats for the WireGuard backend
154func (wg *WireGuard) GetSysStats(ctx context.Context) (*common.BackendStatsResponse, error) {

Callers

nothing calls this directly

Calls 3

GetByEmailMethod · 0.80
EndpointActivityMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected