(ctx context.Context, email string)
| 120 | } |
| 121 | |
| 122 | func (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 |
| 154 | func (wg *WireGuard) GetSysStats(ctx context.Context) (*common.BackendStatsResponse, error) { |
nothing calls this directly
no test coverage detected