From bb1b43958ac7a2f538535b9288a79c8d5fba31bf Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 10 Mar 2024 09:09:29 -0400 Subject: [PATCH] refactor: use clientIP and pass in a wrapped net.IPAddr --- service/default/http.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/service/default/http.go b/service/default/http.go index b44ac26..b2fa8ab 100644 --- a/service/default/http.go +++ b/service/default/http.go @@ -85,8 +85,6 @@ func (h *HTTPServiceDefault) p2pHandler(ctx jape.Context) { return } - ip := peer.GetIP() - // Check for reverse proxy headers realIP := ctx.Request.Header.Get("X-Real-IP") forwardedFor := ctx.Request.Header.Get("X-Forwarded-For") @@ -117,7 +115,7 @@ func (h *HTTPServiceDefault) p2pHandler(ctx jape.Context) { } } - if blockConnection(ip) { + if blockConnection(peer.GetIP()) { err := peer.End() if err != nil { h.Logger().Error("error ending peer", zap.Error(err)) @@ -125,8 +123,8 @@ func (h *HTTPServiceDefault) p2pHandler(ctx jape.Context) { return } - if ip != nil { - peer.SetIP(ip) + if clientIP != nil { + peer.SetIP(&net.IPAddr{IP: clientIP}) } h.Services().P2P().ConnectionTracker().Add(1)