fix: use RLock

This commit is contained in:
Derrick Hammer 2024-03-11 17:45:57 -04:00
parent 2bb558f878
commit 1ecbda1a54
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 4 deletions

View File

@ -130,13 +130,13 @@ func (p *WebSocketPeer) EndForAbuse() error {
return nil return nil
} }
func (p *WebSocketPeer) SetId(id *encoding.NodeId) { func (p *WebSocketPeer) SetId(id *encoding.NodeId) {
p.BasePeer.lock.Lock() p.BasePeer.lock.RLock()
defer p.BasePeer.lock.Unlock() defer p.BasePeer.lock.Unlock()
p.id = id p.id = id
} }
func (p *WebSocketPeer) SetChallenge(challenge []byte) { func (p *WebSocketPeer) SetChallenge(challenge []byte) {
p.BasePeer.lock.Lock() p.BasePeer.lock.RLock()
defer p.BasePeer.lock.Unlock() defer p.BasePeer.lock.Unlock()
p.challenge = challenge p.challenge = challenge
} }
@ -146,7 +146,7 @@ func (p *WebSocketPeer) GetChallenge() []byte {
} }
func (p *WebSocketPeer) GetIP() net.Addr { func (p *WebSocketPeer) GetIP() net.Addr {
p.BasePeer.lock.Lock() p.BasePeer.lock.RLock()
defer p.BasePeer.lock.Unlock() defer p.BasePeer.lock.Unlock()
if p.ip != nil { if p.ip != nil {
return p.ip return p.ip
@ -173,7 +173,7 @@ func (b *WebSocketPeer) GetIPString() string {
} }
func (p *WebSocketPeer) Abuser() bool { func (p *WebSocketPeer) Abuser() bool {
p.BasePeer.lock.Lock() p.BasePeer.lock.RLock()
defer p.BasePeer.lock.Unlock() defer p.BasePeer.lock.Unlock()
return p.abuser return p.abuser
} }