refactor: change abused to abuser

This commit is contained in:
Derrick Hammer 2024-01-15 13:50:04 -05:00
parent d0d6745d60
commit 1b6925c296
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 8 additions and 8 deletions

View File

@ -47,7 +47,7 @@ type Peer interface {
IsHandshakeDone() bool IsHandshakeDone() bool
SetHandshakeDone(status bool) SetHandshakeDone(status bool)
GetIP() string GetIP() string
Abused() bool Abuser() bool
} }
type BasePeer struct { type BasePeer struct {
@ -127,6 +127,6 @@ func (b *BasePeer) SetHandshakeDone(status bool) {
b.handshaked = status b.handshaked = status
} }
func (b *BasePeer) Abused() bool { func (b *BasePeer) Abuser() bool {
panic("must implement in child class") panic("must implement in child class")
} }

View File

@ -16,7 +16,7 @@ var (
type WebSocketPeer struct { type WebSocketPeer struct {
BasePeer BasePeer
socket *websocket.Conn socket *websocket.Conn
abused bool abuser bool
} }
func (p *WebSocketPeer) Connect(uri *url.URL) (interface{}, error) { func (p *WebSocketPeer) Connect(uri *url.URL) (interface{}, error) {
@ -105,7 +105,7 @@ func (p *WebSocketPeer) End() error {
return nil return nil
} }
func (p *WebSocketPeer) EndForAbuse() error { func (p *WebSocketPeer) EndForAbuse() error {
p.abused = true p.abuser = true
err := p.socket.Close(websocket.StatusPolicyViolation, "") err := p.socket.Close(websocket.StatusPolicyViolation, "")
if err != nil { if err != nil {
return err return err
@ -135,6 +135,6 @@ func (b *WebSocketPeer) GetIP() string {
return ipAddr return ipAddr
} }
func (p *WebSocketPeer) Abused() bool { func (p *WebSocketPeer) Abuser() bool {
return p.abused return p.abuser
} }

View File

@ -329,7 +329,7 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool, fromPee
go func() { go func() {
err := p.OnNewPeer(peer, true) err := p.OnNewPeer(peer, true)
if err != nil && !peer.Abused() { if err != nil && !peer.Abuser() {
p.logger.Error("peer error", zap.Error(err)) p.logger.Error("peer error", zap.Error(err))
} }
p.Node().ConnectionTracker().Done() p.Node().ConnectionTracker().Done()
@ -424,7 +424,7 @@ func (p *P2PImpl) OnNewPeerListen(peer net.Peer, verifyId bool) {
}) })
onError := net.ErrorCallback(func(args ...interface{}) { onError := net.ErrorCallback(func(args ...interface{}) {
if !peer.Abused() { if !peer.Abuser() {
p.logger.Error("peer error", zap.Any("args", args)) p.logger.Error("peer error", zap.Any("args", args))
} }
}) })