Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add email into access log for shadowsocks and vmess #1767

Merged
merged 1 commit into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions common/log/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type AccessMessage struct {
To interface{}
Status AccessStatus
Reason interface{}
Email string
}

func (m *AccessMessage) String() string {
Expand All @@ -29,5 +30,11 @@ func (m *AccessMessage) String() string {
builder.WriteString(serial.ToString(m.To))
builder.WriteByte(' ')
builder.WriteString(serial.ToString(m.Reason))

if len(m.Email) > 0 {
builder.WriteString("email:")
builder.WriteString(m.Email)
builder.WriteByte(' ')
}
return builder.String()
}
1 change: 1 addition & 0 deletions common/mux/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
}
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.IsValid() {
msg.From = inbound.Source
msg.Email = inbound.User.Email
}
log.Record(msg)
}
Expand Down
3 changes: 3 additions & 0 deletions proxy/shadowsocks/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func (s *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
To: dest,
Status: log.AccessAccepted,
Reason: "",
Email: request.User.Email,
})
}
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx))
Expand All @@ -163,6 +164,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
To: "",
Status: log.AccessRejected,
Reason: err,
Email: request.User.Email,
})
return newError("failed to create request from: ", conn.RemoteAddr()).Base(err)
}
Expand All @@ -180,6 +182,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
To: dest,
Status: log.AccessAccepted,
Reason: "",
Email: request.User.Email,
})
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx))

Expand Down
3 changes: 2 additions & 1 deletion proxy/vmess/inbound/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
reader := &buf.BufferedReader{Reader: buf.NewReader(connection)}
svrSession := encoding.NewServerSession(h.clients, h.sessionHistory)
request, err := svrSession.DecodeRequestHeader(reader)

if err != nil {
if errors.Cause(err) != io.EOF {
log.Record(&log.AccessMessage{
Expand All @@ -245,6 +244,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
To: "",
Status: log.AccessRejected,
Reason: "Insecure encryption",
Email: request.User.Email,
})
return newError("client is using insecure encryption: ", request.Security)
}
Expand All @@ -255,6 +255,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
To: request.Destination(),
Status: log.AccessAccepted,
Reason: "",
Email: request.User.Email,
})
}

Expand Down