1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-09 09:20:45 +00:00

🔙 Revert "Add traffic stat of every request in access log (#642)" (#644)

This reverts commit af0120e771.
This commit is contained in:
database64128 2021-01-30 20:32:34 +08:00 committed by GitHub
parent af0120e771
commit 484d740800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 23 deletions

View File

@ -154,15 +154,12 @@ func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *tran
if user != nil && len(user.Email) > 0 {
p := d.policy.ForLevel(user.Level)
accessMessage := log.AccessMessageFromContext(ctx)
if p.Stats.UserUplink {
name := "user>>>" + user.Email + ">>>traffic>>>uplink"
if c, _ := stats.GetOrRegisterCounter(d.stats, name); c != nil {
inboundLink.Writer = &SizeStatWriter{
Counter: c,
Writer: inboundLink.Writer,
Record: &accessMessage.BytesSent,
}
}
}
@ -172,7 +169,6 @@ func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *tran
outboundLink.Writer = &SizeStatWriter{
Counter: c,
Writer: outboundLink.Writer,
Record: &accessMessage.BytesReceived,
}
}
}
@ -289,12 +285,12 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
return
}
handler.Dispatch(ctx, link)
if accessMessage := log.AccessMessageFromContext(ctx); accessMessage != nil {
if tag := handler.Tag(); tag != "" {
accessMessage.Detour = tag
}
log.Record(accessMessage)
}
handler.Dispatch(ctx, link)
}

View File

@ -11,15 +11,10 @@ import (
type SizeStatWriter struct {
Counter stats.Counter
Writer buf.Writer
Record *int64
}
func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
bufLen := int64(mb.Len())
if w.Record != nil {
*w.Record += bufLen
}
w.Counter.Add(bufLen)
w.Counter.Add(int64(mb.Len()))
return w.Writer.WriteMultiBuffer(mb)
}

View File

@ -2,7 +2,6 @@ package log
import (
"context"
"fmt"
"strings"
"v2ray.com/core/common/serial"
@ -22,14 +21,12 @@ const (
)
type AccessMessage struct {
From interface{}
To interface{}
Status AccessStatus
Reason interface{}
Email string
Detour string
BytesSent int64
BytesReceived int64
From interface{}
To interface{}
Status AccessStatus
Reason interface{}
Email string
Detour string
}
func (m *AccessMessage) String() string {
@ -56,8 +53,6 @@ func (m *AccessMessage) String() string {
builder.WriteString(m.Email)
}
builder.WriteString(fmt.Sprintf(" bytes_sent: %d bytes_received: %d", m.BytesSent, m.BytesReceived))
return builder.String()
}