refactor: change GetIP to GetIPString
This commit is contained in:
parent
48ef3e3a2a
commit
5f5b522e68
|
@ -44,7 +44,7 @@ type Peer interface {
|
||||||
ConnectionURIs() []*url.URL
|
ConnectionURIs() []*url.URL
|
||||||
IsHandshakeDone() bool
|
IsHandshakeDone() bool
|
||||||
SetHandshakeDone(status bool)
|
SetHandshakeDone(status bool)
|
||||||
GetIP() string
|
GetIPString() string
|
||||||
Abuser() bool
|
Abuser() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func (b *BasePeer) End() error {
|
||||||
func (b *BasePeer) EndForAbuse() error {
|
func (b *BasePeer) EndForAbuse() error {
|
||||||
panic("must implement in child class")
|
panic("must implement in child class")
|
||||||
}
|
}
|
||||||
func (b *BasePeer) GetIP() string {
|
func (b *BasePeer) GetIPString() string {
|
||||||
panic("must implement in child class")
|
panic("must implement in child class")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ func (p *WebSocketPeer) GetChallenge() []byte {
|
||||||
return p.challenge
|
return p.challenge
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *WebSocketPeer) GetIP() string {
|
func (b *WebSocketPeer) GetIPString() string {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
netConn := websocket.NetConn(ctx, b.socket, websocket.MessageBinary)
|
netConn := websocket.NetConn(ctx, b.socket, websocket.MessageBinary)
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ func (p *P2PServiceDefault) ConnectToNode(connectionUris []*url.URL, retry uint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fromPeerIP := fromPeer.GetIP()
|
fromPeerIP := fromPeer.GetIPString()
|
||||||
|
|
||||||
if !p.incomingIPBlocklist.Contains(fromPeerIP) {
|
if !p.incomingIPBlocklist.Contains(fromPeerIP) {
|
||||||
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
||||||
|
@ -282,7 +282,7 @@ func (p *P2PServiceDefault) ConnectToNode(connectionUris []*url.URL, retry uint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fromPeerIP := fromPeer.GetIP()
|
fromPeerIP := fromPeer.GetIPString()
|
||||||
if !p.incomingIPBlocklist.Contains(fromPeerIP) {
|
if !p.incomingIPBlocklist.Contains(fromPeerIP) {
|
||||||
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
||||||
blocked = true
|
blocked = true
|
||||||
|
@ -371,7 +371,7 @@ func (p *P2PServiceDefault) OnNewPeer(peer net.Peer, verifyId bool) error {
|
||||||
pid = "unknown"
|
pid = "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
pip := peer.GetIP()
|
pip := peer.GetIPString()
|
||||||
|
|
||||||
if p.incomingIPBlocklist.Contains(pid) {
|
if p.incomingIPBlocklist.Contains(pid) {
|
||||||
p.Logger().Error("peer is on identity blocklist", zap.String("peer", pid))
|
p.Logger().Error("peer is on identity blocklist", zap.String("peer", pid))
|
||||||
|
|
Loading…
Reference in New Issue