fea: ceci: show total bytes.
Some checks failed
Coverage CI / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
Ubuntu CI / build (push) Has been cancelled

This commit is contained in:
Daniel Ding
2025-01-20 10:47:29 +08:00
parent a8f1cd1545
commit 16f9973502

View File

@@ -380,8 +380,10 @@ func (t *HttpProxy) doRecord(r *http.Request, bytes int64) {
record, ok := t.requests[r.URL.Host] record, ok := t.requests[r.URL.Host]
if !ok { if !ok {
record = &HttpRecord{} record = &HttpRecord{
t.requests[r.URL.Host] = record Domain: r.URL.Host,
}
t.requests[record.Domain] = record
} }
record.Update(bytes) record.Update(bytes)
} }
@@ -505,6 +507,9 @@ var httpTmpl = map[string]string{
<tr> <tr>
<td>Total:</td><td>{{ .Total }}</td> <td>Total:</td><td>{{ .Total }}</td>
</tr> </tr>
<tr>
<td>Bytes:</td><td>{{ .Bytes }}</td>
</tr>
<tr> <tr>
<td>Configuration:</td><td><a href="/api/config">display</a></td> <td>Configuration:</td><td><a href="/api/config">display</a></td>
</tr> </tr>
@@ -545,19 +550,15 @@ func (t *HttpProxy) GetStats(w http.ResponseWriter, r *http.Request) {
data := &struct { data := &struct {
StartAt string StartAt string
Total int Total int
Bytes int64
Requests []*HttpRecord Requests []*HttpRecord
}{ }{
Total: len(t.requests), Total: len(t.requests),
StartAt: t.startat.Local().String(), StartAt: t.startat.Local().String(),
} }
for name, record := range t.requests { for _, record := range t.requests {
data.Requests = append(data.Requests, &HttpRecord{ data.Requests = append(data.Requests, record)
Domain: name, data.Bytes += record.Bytes
Count: record.Count,
LastAt: record.LastAt,
CreateAt: record.CreateAt,
Bytes: record.Bytes,
})
} }
t.lock.RUnlock() t.lock.RUnlock()