mirror of
https://github.com/luscis/openlan.git
synced 2025-10-07 01:22:51 +08:00
fea: ceci: show total bytes.
This commit is contained in:
@@ -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()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user