From 1ecbda1a5422104c701558666d6890c646ed4cbb Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 11 Mar 2024 17:45:57 -0400 Subject: [PATCH] fix: use RLock --- net/ws.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ws.go b/net/ws.go index 913bfc0..5f48a7b 100644 --- a/net/ws.go +++ b/net/ws.go @@ -130,13 +130,13 @@ func (p *WebSocketPeer) EndForAbuse() error { return nil } func (p *WebSocketPeer) SetId(id *encoding.NodeId) { - p.BasePeer.lock.Lock() + p.BasePeer.lock.RLock() defer p.BasePeer.lock.Unlock() p.id = id } func (p *WebSocketPeer) SetChallenge(challenge []byte) { - p.BasePeer.lock.Lock() + p.BasePeer.lock.RLock() defer p.BasePeer.lock.Unlock() p.challenge = challenge } @@ -146,7 +146,7 @@ func (p *WebSocketPeer) GetChallenge() []byte { } func (p *WebSocketPeer) GetIP() net.Addr { - p.BasePeer.lock.Lock() + p.BasePeer.lock.RLock() defer p.BasePeer.lock.Unlock() if p.ip != nil { return p.ip @@ -173,7 +173,7 @@ func (b *WebSocketPeer) GetIPString() string { } func (p *WebSocketPeer) Abuser() bool { - p.BasePeer.lock.Lock() + p.BasePeer.lock.RLock() defer p.BasePeer.lock.Unlock() return p.abuser }