mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
add email into access log for shadowsocks, vmess and mux
This commit is contained in:
parent
de43bc7eb9
commit
dd048bfb29
@ -18,6 +18,7 @@ type AccessMessage struct {
|
|||||||
To interface{}
|
To interface{}
|
||||||
Status AccessStatus
|
Status AccessStatus
|
||||||
Reason interface{}
|
Reason interface{}
|
||||||
|
Email string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *AccessMessage) String() string {
|
func (m *AccessMessage) String() string {
|
||||||
@ -29,5 +30,11 @@ func (m *AccessMessage) String() string {
|
|||||||
builder.WriteString(serial.ToString(m.To))
|
builder.WriteString(serial.ToString(m.To))
|
||||||
builder.WriteByte(' ')
|
builder.WriteByte(' ')
|
||||||
builder.WriteString(serial.ToString(m.Reason))
|
builder.WriteString(serial.ToString(m.Reason))
|
||||||
|
|
||||||
|
if len(m.Email) > 0 {
|
||||||
|
builder.WriteString("email:")
|
||||||
|
builder.WriteString(m.Email)
|
||||||
|
builder.WriteByte(' ')
|
||||||
|
}
|
||||||
return builder.String()
|
return builder.String()
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
|||||||
}
|
}
|
||||||
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.IsValid() {
|
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.IsValid() {
|
||||||
msg.From = inbound.Source
|
msg.From = inbound.Source
|
||||||
|
msg.Email = inbound.User.Email
|
||||||
}
|
}
|
||||||
log.Record(msg)
|
log.Record(msg)
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,7 @@ func (s *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
|
|||||||
To: dest,
|
To: dest,
|
||||||
Status: log.AccessAccepted,
|
Status: log.AccessAccepted,
|
||||||
Reason: "",
|
Reason: "",
|
||||||
|
Email: request.User.Email,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx))
|
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx))
|
||||||
@ -163,6 +164,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
|||||||
To: "",
|
To: "",
|
||||||
Status: log.AccessRejected,
|
Status: log.AccessRejected,
|
||||||
Reason: err,
|
Reason: err,
|
||||||
|
Email: request.User.Email,
|
||||||
})
|
})
|
||||||
return newError("failed to create request from: ", conn.RemoteAddr()).Base(err)
|
return newError("failed to create request from: ", conn.RemoteAddr()).Base(err)
|
||||||
}
|
}
|
||||||
@ -180,6 +182,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
|||||||
To: dest,
|
To: dest,
|
||||||
Status: log.AccessAccepted,
|
Status: log.AccessAccepted,
|
||||||
Reason: "",
|
Reason: "",
|
||||||
|
Email: request.User.Email,
|
||||||
})
|
})
|
||||||
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx))
|
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx))
|
||||||
|
|
||||||
|
@ -225,7 +225,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
|||||||
reader := &buf.BufferedReader{Reader: buf.NewReader(connection)}
|
reader := &buf.BufferedReader{Reader: buf.NewReader(connection)}
|
||||||
svrSession := encoding.NewServerSession(h.clients, h.sessionHistory)
|
svrSession := encoding.NewServerSession(h.clients, h.sessionHistory)
|
||||||
request, err := svrSession.DecodeRequestHeader(reader)
|
request, err := svrSession.DecodeRequestHeader(reader)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Cause(err) != io.EOF {
|
if errors.Cause(err) != io.EOF {
|
||||||
log.Record(&log.AccessMessage{
|
log.Record(&log.AccessMessage{
|
||||||
@ -245,6 +244,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
|||||||
To: "",
|
To: "",
|
||||||
Status: log.AccessRejected,
|
Status: log.AccessRejected,
|
||||||
Reason: "Insecure encryption",
|
Reason: "Insecure encryption",
|
||||||
|
Email: request.User.Email,
|
||||||
})
|
})
|
||||||
return newError("client is using insecure encryption: ", request.Security)
|
return newError("client is using insecure encryption: ", request.Security)
|
||||||
}
|
}
|
||||||
@ -255,6 +255,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
|||||||
To: request.Destination(),
|
To: request.Destination(),
|
||||||
Status: log.AccessAccepted,
|
Status: log.AccessAccepted,
|
||||||
Reason: "",
|
Reason: "",
|
||||||
|
Email: request.User.Email,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user