refactor: use clientIP and pass in a wrapped net.IPAddr
This commit is contained in:
parent
195abfdf20
commit
bb1b43958a
|
@ -85,8 +85,6 @@ func (h *HTTPServiceDefault) p2pHandler(ctx jape.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ip := peer.GetIP()
|
|
||||||
|
|
||||||
// Check for reverse proxy headers
|
// Check for reverse proxy headers
|
||||||
realIP := ctx.Request.Header.Get("X-Real-IP")
|
realIP := ctx.Request.Header.Get("X-Real-IP")
|
||||||
forwardedFor := ctx.Request.Header.Get("X-Forwarded-For")
|
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()
|
err := peer.End()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.Logger().Error("error ending peer", zap.Error(err))
|
h.Logger().Error("error ending peer", zap.Error(err))
|
||||||
|
@ -125,8 +123,8 @@ func (h *HTTPServiceDefault) p2pHandler(ctx jape.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ip != nil {
|
if clientIP != nil {
|
||||||
peer.SetIP(ip)
|
peer.SetIP(&net.IPAddr{IP: clientIP})
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Services().P2P().ConnectionTracker().Add(1)
|
h.Services().P2P().ConnectionTracker().Add(1)
|
||||||
|
|
Loading…
Reference in New Issue