access log add detour tag

pull/2531/head
fcying 2019-06-12 13:04:34 +08:00 committed by Nicholas Wang
parent 534bb31ef1
commit 9682a3df55
No known key found for this signature in database
GPG Key ID: F20CA399C9BD9100
2 changed files with 9 additions and 12 deletions

View File

@ -15,6 +15,7 @@ import (
"v2ray.com/core/common/buf" "v2ray.com/core/common/buf"
"v2ray.com/core/common/log" "v2ray.com/core/common/log"
"v2ray.com/core/common/net" "v2ray.com/core/common/net"
"v2ray.com/core/common/log"
"v2ray.com/core/common/protocol" "v2ray.com/core/common/protocol"
"v2ray.com/core/common/session" "v2ray.com/core/common/session"
"v2ray.com/core/features/outbound" "v2ray.com/core/features/outbound"
@ -288,10 +289,9 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
return return
} }
if accessMessage := log.AccessMessageFromContext(ctx); accessMessage != nil { accessMessage := log.AccessMessageFromContext(ctx)
if tag := handler.Tag(); tag != "" { if accessMessage != nil {
accessMessage.Detour = tag accessMessage.Detour = "[" + handler.Tag() + "]"
}
log.Record(accessMessage) log.Record(accessMessage)
} }

View File

@ -3,6 +3,7 @@ package log
import ( import (
"context" "context"
"strings" "strings"
"context"
"v2ray.com/core/common/serial" "v2ray.com/core/common/serial"
) )
@ -25,8 +26,7 @@ type AccessMessage struct {
To interface{} To interface{}
Status AccessStatus Status AccessStatus
Reason interface{} Reason interface{}
Email string Detour interface{}
Detour string
} }
func (m *AccessMessage) String() string { func (m *AccessMessage) String() string {
@ -37,11 +37,8 @@ func (m *AccessMessage) String() string {
builder.WriteByte(' ') builder.WriteByte(' ')
builder.WriteString(serial.ToString(m.To)) builder.WriteString(serial.ToString(m.To))
builder.WriteByte(' ') builder.WriteByte(' ')
if len(m.Detour) > 0 { builder.WriteString(serial.ToString(m.Detour))
builder.WriteByte('[') builder.WriteByte(' ')
builder.WriteString(m.Detour)
builder.WriteString("] ")
}
builder.WriteString(serial.ToString(m.Reason)) builder.WriteString(serial.ToString(m.Reason))
if len(m.Email) > 0 { if len(m.Email) > 0 {