mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-22 12:58:37 +00:00
appc: fix DomainRoutes copy
The non-referential copy destination doesn't extend the map contents, but also the read of a non-key is returning a zero value not bound to the map contents in any way. Updates tailscale/corp#15657 Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
parent
b8ac3c5191
commit
245ddb157b
@ -113,7 +113,7 @@ func (e *AppConnector) DomainRoutes() map[string][]netip.Addr {
|
|||||||
|
|
||||||
drCopy := make(map[string][]netip.Addr)
|
drCopy := make(map[string][]netip.Addr)
|
||||||
for k, v := range e.domains {
|
for k, v := range e.domains {
|
||||||
copy(drCopy[k], v)
|
drCopy[k] = append(drCopy[k], v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return drCopy
|
return drCopy
|
||||||
|
@ -5,6 +5,7 @@ package appc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"reflect"
|
||||||
"slices"
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -35,6 +36,21 @@ func TestUpdateDomains(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDomainRoutes(t *testing.T) {
|
||||||
|
rc := &routeCollector{}
|
||||||
|
a := NewAppConnector(t.Logf, rc)
|
||||||
|
a.UpdateDomains([]string{"example.com"})
|
||||||
|
a.ObserveDNSResponse(dnsResponse("example.com.", "192.0.0.8"))
|
||||||
|
|
||||||
|
want := map[string][]netip.Addr{
|
||||||
|
"example.com": {netip.MustParseAddr("192.0.0.8")},
|
||||||
|
}
|
||||||
|
|
||||||
|
if got := a.DomainRoutes(); !reflect.DeepEqual(got, want) {
|
||||||
|
t.Fatalf("DomainRoutes: got %v, want %v", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestObserveDNSResponse(t *testing.T) {
|
func TestObserveDNSResponse(t *testing.T) {
|
||||||
rc := &routeCollector{}
|
rc := &routeCollector{}
|
||||||
a := NewAppConnector(t.Logf, rc)
|
a := NewAppConnector(t.Logf, rc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user