Skip to content

Commit 25ed583

Browse files
authored
[management] fix network map dns filter (#4547)
1 parent 644ed4b commit 25ed583

File tree

3 files changed

+2
-38
lines changed

3 files changed

+2
-38
lines changed

management/server/dns.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,9 @@ import (
2020

2121
// DNSConfigCache is a thread-safe cache for DNS configuration components
2222
type DNSConfigCache struct {
23-
CustomZones sync.Map
2423
NameServerGroups sync.Map
2524
}
2625

27-
// GetCustomZone retrieves a cached custom zone
28-
func (c *DNSConfigCache) GetCustomZone(key string) (*proto.CustomZone, bool) {
29-
if c == nil {
30-
return nil, false
31-
}
32-
if value, ok := c.CustomZones.Load(key); ok {
33-
return value.(*proto.CustomZone), true
34-
}
35-
return nil, false
36-
}
37-
38-
// SetCustomZone stores a custom zone in the cache
39-
func (c *DNSConfigCache) SetCustomZone(key string, value *proto.CustomZone) {
40-
if c == nil {
41-
return
42-
}
43-
c.CustomZones.Store(key, value)
44-
}
45-
4626
// GetNameServerGroup retrieves a cached name server group
4727
func (c *DNSConfigCache) GetNameServerGroup(key string) (*proto.NameServerGroup, bool) {
4828
if c == nil {
@@ -212,14 +192,8 @@ func toProtocolDNSConfig(update nbdns.Config, cache *DNSConfigCache) *proto.DNSC
212192
}
213193

214194
for _, zone := range update.CustomZones {
215-
cacheKey := zone.Domain
216-
if cachedZone, exists := cache.GetCustomZone(cacheKey); exists {
217-
protoUpdate.CustomZones = append(protoUpdate.CustomZones, cachedZone)
218-
} else {
219-
protoZone := convertToProtoCustomZone(zone)
220-
cache.SetCustomZone(cacheKey, protoZone)
221-
protoUpdate.CustomZones = append(protoUpdate.CustomZones, protoZone)
222-
}
195+
protoZone := convertToProtoCustomZone(zone)
196+
protoUpdate.CustomZones = append(protoUpdate.CustomZones, protoZone)
223197
}
224198

225199
for _, nsGroup := range update.NameServerGroups {

management/server/dns_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -474,15 +474,6 @@ func TestToProtocolDNSConfigWithCache(t *testing.T) {
474474
t.Errorf("Results should be different for different inputs")
475475
}
476476

477-
// Verify that the cache contains elements from both configs
478-
if _, exists := cache.GetCustomZone("example.com"); !exists {
479-
t.Errorf("Cache should contain custom zone for example.com")
480-
}
481-
482-
if _, exists := cache.GetCustomZone("example.org"); !exists {
483-
t.Errorf("Cache should contain custom zone for example.org")
484-
}
485-
486477
if _, exists := cache.GetNameServerGroup("group1"); !exists {
487478
t.Errorf("Cache should contain name server group 'group1'")
488479
}

management/server/types/account.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ func (a *Account) GetPeerNetworkMap(
300300

301301
if dnsManagementStatus {
302302
var zones []nbdns.CustomZone
303-
304303
if peersCustomZone.Domain != "" {
305304
records := filterZoneRecordsForPeers(peer, peersCustomZone, peersToConnect)
306305
zones = append(zones, nbdns.CustomZone{

0 commit comments

Comments
 (0)