TUN-2921: Rework address selection logic to avoid corner cases

This commit is contained in:
Igor Postelnik
2020-04-27 14:25:37 -05:00
parent c782716e49
commit 976eb24883
6 changed files with 57 additions and 13 deletions

View File

@@ -2,6 +2,8 @@ package allregions
import (
"net"
"github.com/sirupsen/logrus"
)
// Region contains cloudflared edge addresses. The edge is partitioned into several regions for
@@ -56,6 +58,10 @@ func (r Region) GetUnusedIP(excluding *net.TCPAddr) *net.TCPAddr {
// Use the address, assigning it to a proxy connection.
func (r Region) Use(addr *net.TCPAddr, connID int) {
if addr == nil {
logrus.Errorf("Attempted to use nil address for connection %d", connID)
return
}
r.connFor[addr] = InUse(connID)
}