Improve logging
This commit is contained in:
parent
60dc513813
commit
64784b6b37
18
listener.go
18
listener.go
|
@ -79,7 +79,7 @@ func (l Listener) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
|||
// Sanity checks:
|
||||
// - method is HTTP GET
|
||||
// - has request URI
|
||||
// - has Host header -> no!
|
||||
// - has Host header -> no! this check should be omitted
|
||||
// - has Connection: Upgrade
|
||||
// - has Upgrade: websocket
|
||||
// - has Sec-WebSocket-Version: 13
|
||||
|
@ -125,18 +125,18 @@ func (l Listener) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
// Todo: remove all that debug spam
|
||||
log.DEBUG.To(logger).Msg("In the websocket handler - yay!")
|
||||
for k, v := range req.Header {
|
||||
log.INFO.To(logger).Msg(" %v: %v", k, v[0])
|
||||
}
|
||||
log.TRACE.To(logger).If(func(msg log.Fn) {
|
||||
msg("Dumping HTTP headers:")
|
||||
for k, v := range req.Header {
|
||||
msg(" %v: %v", k, v[0])
|
||||
}
|
||||
})
|
||||
|
||||
wsKey := head.Get("Sec-Websocket-Key")
|
||||
wsKey += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
||||
shakey := sha1.Sum([]byte(wsKey))
|
||||
wsKey = base64.StdEncoding.EncodeToString(shakey[:])
|
||||
|
||||
log.INFO.To(logger).Msg("Generated WebSocket-Accept: ", wsKey)
|
||||
log.DEBUG.To(logger).Msg("Generated WebSocket-Accept: %v", wsKey)
|
||||
// NOPE: we need to hijack the connection and send it manually!
|
||||
//resp.Header().Set("Upgrade", "websocket")
|
||||
//resp.Header().Set("Connection", "Upgrade")
|
||||
|
@ -164,7 +164,7 @@ func (l Listener) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
|||
// the client must not've sent any data before the handshake is complete
|
||||
if brw.Reader.Buffered() > 0 {
|
||||
conn.Close()
|
||||
log.ERROR.To(logger).Msg("client send before handshake!")
|
||||
log.ERROR.To(logger).Msg("client sent data before handshake!")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user