|
@@ -190,7 +190,7 @@ type RemoteList struct {
|
|
// The full list of vpn addresses assigned to this host
|
|
// The full list of vpn addresses assigned to this host
|
|
vpnAddrs []netip.Addr
|
|
vpnAddrs []netip.Addr
|
|
|
|
|
|
- // A deduplicated set of addresses. Any accessor should lock beforehand.
|
|
|
|
|
|
+ // A deduplicated set of underlay addresses. Any accessor should lock beforehand.
|
|
addrs []netip.AddrPort
|
|
addrs []netip.AddrPort
|
|
|
|
|
|
// A set of relay addresses. VpnIp addresses that the remote identified as relays.
|
|
// A set of relay addresses. VpnIp addresses that the remote identified as relays.
|
|
@@ -201,8 +201,10 @@ type RemoteList struct {
|
|
// For learned addresses, this is the vpnIp that sent the packet
|
|
// For learned addresses, this is the vpnIp that sent the packet
|
|
cache map[netip.Addr]*cache
|
|
cache map[netip.Addr]*cache
|
|
|
|
|
|
- hr *hostnamesResults
|
|
|
|
- shouldAdd func(netip.Addr) bool
|
|
|
|
|
|
+ hr *hostnamesResults
|
|
|
|
+
|
|
|
|
+ // shouldAdd is a nillable function that decides if x should be added to addrs.
|
|
|
|
+ shouldAdd func(vpnAddrs []netip.Addr, x netip.Addr) bool
|
|
|
|
|
|
// This is a list of remotes that we have tried to handshake with and have returned from the wrong vpn ip.
|
|
// This is a list of remotes that we have tried to handshake with and have returned from the wrong vpn ip.
|
|
// They should not be tried again during a handshake
|
|
// They should not be tried again during a handshake
|
|
@@ -213,7 +215,7 @@ type RemoteList struct {
|
|
}
|
|
}
|
|
|
|
|
|
// NewRemoteList creates a new empty RemoteList
|
|
// NewRemoteList creates a new empty RemoteList
|
|
-func NewRemoteList(vpnAddrs []netip.Addr, shouldAdd func(netip.Addr) bool) *RemoteList {
|
|
|
|
|
|
+func NewRemoteList(vpnAddrs []netip.Addr, shouldAdd func([]netip.Addr, netip.Addr) bool) *RemoteList {
|
|
r := &RemoteList{
|
|
r := &RemoteList{
|
|
vpnAddrs: make([]netip.Addr, len(vpnAddrs)),
|
|
vpnAddrs: make([]netip.Addr, len(vpnAddrs)),
|
|
addrs: make([]netip.AddrPort, 0),
|
|
addrs: make([]netip.AddrPort, 0),
|
|
@@ -368,6 +370,15 @@ func (r *RemoteList) CopyBlockedRemotes() []netip.AddrPort {
|
|
return c
|
|
return c
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// RefreshFromHandshake locks and updates the RemoteList to account for data learned upon a completed handshake
|
|
|
|
+func (r *RemoteList) RefreshFromHandshake(vpnAddrs []netip.Addr) {
|
|
|
|
+ r.Lock()
|
|
|
|
+ r.badRemotes = nil
|
|
|
|
+ r.vpnAddrs = make([]netip.Addr, len(vpnAddrs))
|
|
|
|
+ copy(r.vpnAddrs, vpnAddrs)
|
|
|
|
+ r.Unlock()
|
|
|
|
+}
|
|
|
|
+
|
|
// ResetBlockedRemotes locks and clears the blocked remotes list
|
|
// ResetBlockedRemotes locks and clears the blocked remotes list
|
|
func (r *RemoteList) ResetBlockedRemotes() {
|
|
func (r *RemoteList) ResetBlockedRemotes() {
|
|
r.Lock()
|
|
r.Lock()
|
|
@@ -577,7 +588,7 @@ func (r *RemoteList) unlockedCollect() {
|
|
|
|
|
|
dnsAddrs := r.hr.GetAddrs()
|
|
dnsAddrs := r.hr.GetAddrs()
|
|
for _, addr := range dnsAddrs {
|
|
for _, addr := range dnsAddrs {
|
|
- if r.shouldAdd == nil || r.shouldAdd(addr.Addr()) {
|
|
|
|
|
|
+ if r.shouldAdd == nil || r.shouldAdd(r.vpnAddrs, addr.Addr()) {
|
|
if !r.unlockedIsBad(addr) {
|
|
if !r.unlockedIsBad(addr) {
|
|
addrs = append(addrs, addr)
|
|
addrs = append(addrs, addr)
|
|
}
|
|
}
|