VPN connection log: who connected and when
WireGuard has no connect events, only the last handshake and byte counters. awg-ctrl now checks them every 30 s and writes conn_log in users.db: connect at the first handshake, disconnect at the last activity (the last tick the counters moved), with the session length and traffic, plus peer_seen, the last time each peer was online. Open sessions are restored from the database, so a restart adds no duplicates; a down interface is not a disconnect; a peer removed mid-session is closed. Events keep the name, owner and VPN IP as of that moment and live 90 days. Client public IPs are not recorded. GET /api/connlog serves the events and the per-peer last-seen list. The panel fetches it from the selected server at /ui/connlog and fills in master key labels and device names for sen:// peers. A new "Подключения" tab shows the event feed with search and paging, and "who was online when", including those who never connected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013bNGYiDst62wH3ZGTRPFLJ
This commit is contained in:
@@ -37,6 +37,14 @@ func (s *Server) routes() []route {
|
||||
{"awg", ob{{"status", awgSt}, {"peers", st.Peers}, {"module", cfg.AwgModule}, {"tools", cfg.AwgTools}}}}}, nil
|
||||
}),
|
||||
|
||||
R("GET", "/api/connlog", false, a, func(c *rctx) (result, error) {
|
||||
v, err := s.connlog.list(queryInt(c, "limit"), queryInt(c, "before"), c.r.URL.Query().Get("q"))
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return ok(v)
|
||||
}),
|
||||
|
||||
R("POST", "/api/users", true, an, func(c *rctx) (result, error) {
|
||||
name, _ := c.obj().Get2("name").(string)
|
||||
if u, err := s.userGet(name); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user