-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[management] move network map logic into new design #4774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 21 commits
03b599a
1d25cf8
092fc24
da1ffe4
febde70
ee45532
51ad8d7
e6aa119
d35f904
71684e4
addb4df
bfc84c0
abb8782
04209c5
41744aa
1908cfa
705fd84
f2bb181
83b8216
0294c04
a31e293
a0b7a8f
46f0e6c
596820b
40808a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||
| package cache | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||
| "sync" | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| "github.com/netbirdio/netbird/shared/management/proto" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // DNSConfigCache is a thread-safe cache for DNS configuration components | ||||||||||||||||||||||||||||||||||||||||||
| type DNSConfigCache struct { | ||||||||||||||||||||||||||||||||||||||||||
| NameServerGroups sync.Map | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // GetNameServerGroup retrieves a cached name server group | ||||||||||||||||||||||||||||||||||||||||||
| func (c *DNSConfigCache) GetNameServerGroup(key string) (*proto.NameServerGroup, bool) { | ||||||||||||||||||||||||||||||||||||||||||
| if c == nil { | ||||||||||||||||||||||||||||||||||||||||||
| return nil, false | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| if value, ok := c.NameServerGroups.Load(key); ok { | ||||||||||||||||||||||||||||||||||||||||||
| return value.(*proto.NameServerGroup), true | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| return nil, false | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unchecked type assertion could panic. Line 20 performs an unchecked type assertion Apply this diff to add a type check: func (c *DNSConfigCache) GetNameServerGroup(key string) (*proto.NameServerGroup, bool) {
if c == nil {
return nil, false
}
if value, ok := c.NameServerGroups.Load(key); ok {
- return value.(*proto.NameServerGroup), true
+ if nsg, ok := value.(*proto.NameServerGroup); ok {
+ return nsg, true
+ }
}
return nil, false
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // SetNameServerGroup stores a name server group in the cache | ||||||||||||||||||||||||||||||||||||||||||
| func (c *DNSConfigCache) SetNameServerGroup(key string, value *proto.NameServerGroup) { | ||||||||||||||||||||||||||||||||||||||||||
| if c == nil { | ||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| c.NameServerGroups.Store(key, value) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify
go.uber.org/mockv0.5.0 is current and appropriate for the refactoring.Promoting
go.uber.org/mockto a direct dependency aligns with the PR's new controller-based mocking infrastructure. However, ensure this version is maintained, compatible with your test suite, and free from known issues.🌐 Web query:
💡 Result:
Short answer: No — v0.5.0 is not the most recent release. There have been patch releases (e.g. v0.5.2 on 2025‑04‑28) and further activity; the project is actively maintained and supports the two most recent Go releases. [1][2][5]
Security/compatibility summary:
Recommendations:
go list -m -versions go.uber.org/mockor check the repo releases and then update your go.mod to that version.Sources:
[1] uber-go/mock (GitHub repo).
[2] Release notes / v0.5.2 (published 2025‑04‑28).
[3] Snyk package advisory for github.com/uber-go/mock (no direct vulnerabilities).
[4] uber-go/mock GitHub issues (open compatibility/bug reports).
[5] pkg.go.dev entry for go.uber.org/mock (module details, supported Go versions).
Update
go.uber.org/mockto v0.5.2 or the latest stable version.v0.5.0 is not the current stable version; newer releases (e.g., v0.5.2 released 2025‑04‑28) are available. Recent patch releases address functional bugs and compatibility issues with Go generics and type aliases. Given this PR's major refactoring with new mocking infrastructure, update to the latest patch release to ensure compatibility and avoid known issues.
🤖 Prompt for AI Agents