mirror of
https://github.com/wweir/sower.git
synced 2026-10-20 00:15:34 +00:00
feat(admin): track and filter traffic by client IP
The console now records the client source IP for every connection and DNS query, shows the top clients, and can filter the domain list by one: - WrapConn captures conn.RemoteAddr into the counting conn; RecordDNS takes the client IP from the DNS ResponseWriter. Domain stats keep a per-client breakdown alongside the per-source one. - /api/traffic?client=<ip> restricts domains to that client and reports the client's conns/bytes/lastSeen; it composes with ?source=. - The snapshot now carries clients: top 50 per-IP aggregates (conns, bytes up/down, last seen) for display. - Traffic page shows a client chip row (全部客户端 + IPs with counts); clicking one filters, tooltips show byte totals. Verified live: ?client=192.168.1.1 lists that device's domains with its counts; ?source=dns&client=... composes correctly.
This commit is contained in:
+1
-1
@@ -84,7 +84,7 @@ type dnsStatsHandler struct {
|
||||
|
||||
func (h dnsStatsHandler) ServeDNS(w dns.ResponseWriter, req *dns.Msg) {
|
||||
if len(req.Question) == 1 {
|
||||
h.stats.RecordDNS(req.Question[0].Name)
|
||||
h.stats.RecordDNS(req.Question[0].Name, admin.ClientIPOf(w.RemoteAddr()))
|
||||
}
|
||||
h.Handler.ServeDNS(w, req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user