refactor: change abused to abuser
This commit is contained in:
parent
d0d6745d60
commit
1b6925c296
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue