mirror of https://github.com/v2ray/v2ray-core
access log add detour tag
parent
534bb31ef1
commit
9682a3df55
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue