Better protection against duplicate connection ids.

This commit is contained in:
Juliusz Chroboczek committed 2020-05-22 22:38:40 +02:00
1 parent 6005ad9eb4
commit 57163c70a3
1 file changed
+2 -2
+2 -2
View File
@@ -320,7 +320,7 @@ func addUpConn(c *client, id string) (*upConnection, error) {
if c.up == nil { if c.up == nil {
c.up = make(map[string]*upConnection) c.up = make(map[string]*upConnection)
} }
if c.up[id] != nil { if c.up[id] != nil || (c.down != nil && c.down[id] != nil) {
conn.pc.Close() conn.pc.Close()
return nil, errors.New("Adding duplicate connection") return nil, errors.New("Adding duplicate connection")
} }
@@ -697,7 +697,7 @@ func addDownConn(c *client, id string, remote *upConnection) (*downConnection, e
c.mu.Lock() c.mu.Lock()
defer c.mu.Unlock() defer c.mu.Unlock()
if c.down[id] != nil { if c.down[id] != nil || (c.up != nil && c.up[id] != nil) {
conn.pc.Close() conn.pc.Close()
return nil, errors.New("Adding duplicate connection") return nil, errors.New("Adding duplicate connection")
} }