Skip to content

Commit

Permalink
logging connection informations
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Sep 27, 2023
1 parent dc3f542 commit dbb26f9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func (s *Server) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
ticker := time.NewTicker(pingPeriod)
stop := make(chan struct{})

s.Log.Infof("connected from %s", conn.RemoteAddr().String())

// NIP-42 challenge
challenge := make([]byte, 8)
rand.Read(challenge)
Expand Down Expand Up @@ -85,6 +87,7 @@ func (s *Server) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
removeListener(ws)
}
s.clientsMu.Unlock()
s.Log.Infof("diconnected from %s", conn.RemoteAddr().String())
}()

conn.SetReadLimit(maxMessageSize)
Expand Down Expand Up @@ -387,6 +390,7 @@ func (s *Server) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
s.Log.Errorf("error writing ping: %v; closing websocket", err)
return
}
s.Log.Infof("pinging for %s", conn.RemoteAddr().String())
case <-stop:
return
}
Expand Down

0 comments on commit dbb26f9

Please sign in to comment.