mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-27 05:52:29 +08:00
feat: add log
This commit is contained in:
parent
91865f0a31
commit
bcf397c1f9
@ -66,12 +66,16 @@ func (c *UserConnContext) Value(key any) any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnContext {
|
func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnContext {
|
||||||
|
remoteAddr := req.RemoteAddr
|
||||||
|
if forwarded := req.Header.Get("X-Forwarded-For"); forwarded != "" {
|
||||||
|
remoteAddr += "_" + forwarded
|
||||||
|
}
|
||||||
return &UserConnContext{
|
return &UserConnContext{
|
||||||
RespWriter: respWriter,
|
RespWriter: respWriter,
|
||||||
Req: req,
|
Req: req,
|
||||||
Path: req.URL.Path,
|
Path: req.URL.Path,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
RemoteAddr: req.RemoteAddr,
|
RemoteAddr: remoteAddr,
|
||||||
ConnID: encrypt.Md5(req.RemoteAddr + "_" + strconv.Itoa(int(timeutil.GetCurrentTimestampByMill()))),
|
ConnID: encrypt.Md5(req.RemoteAddr + "_" + strconv.Itoa(int(timeutil.GetCurrentTimestampByMill()))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -425,6 +425,7 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.ZDebug(connContext, "new conn", "token", connContext.GetToken())
|
||||||
// Create a WebSocket long connection object
|
// Create a WebSocket long connection object
|
||||||
wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize)
|
wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize)
|
||||||
if err := wsLongConn.GenerateLongConn(w, r); err != nil {
|
if err := wsLongConn.GenerateLongConn(w, r); err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user