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
SetHandshakeDone(status bool)
GetIP() string
Abused() bool
Abuser() bool
}
type BasePeer struct {
@ -127,6 +127,6 @@ func (b *BasePeer) SetHandshakeDone(status bool) {
b.handshaked = status
}
func (b *BasePeer) Abused() bool {
func (b *BasePeer) Abuser() bool {
panic("must implement in child class")
}

View File

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

View File

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