Skip to content
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

feat: derpmap field in config #1823

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hscontrol/derp/derp.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ func mergeDERPMaps(derpMaps []*tailcfg.DERPMap) *tailcfg.DERPMap {

func GetDERPMap(cfg types.DERPConfig) *tailcfg.DERPMap {
var derpMaps []*tailcfg.DERPMap
if cfg.DERPMap != nil {
derpMaps = append(derpMaps, cfg.DERPMap)
}
Comment on lines +85 to +87
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditional check added to prevent nil dereferencing.

The addition of the conditional check at lines 85-87 is a good practice to ensure that only non-nil DERPMap instances are appended to the derpMaps slice. This change helps in preventing potential runtime errors due to nil dereferencing.

However, it's recommended to add unit tests to verify that this new logic correctly handles scenarios where cfg.DERPMap might be nil or non-nil.

Would you like me to help by writing some unit tests for this new logic?


for _, path := range cfg.Paths {
log.Debug().
Expand Down
1 change: 1 addition & 0 deletions hscontrol/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type DERPConfig struct {
STUNAddr string
URLs []url.URL
Paths []string
DERPMap *tailcfg.DERPMap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New field DERPMap added to DERPConfig struct.

The addition of the DERPMap field at line 182 enhances the configuration capabilities of the DERPConfig struct by allowing direct assignment of a DERP map. This change is beneficial for programmatically setting the DERP map, providing more flexibility compared to the previous methods.

It's recommended to update the project's documentation to include information about this new field and its usage.

Consider updating the documentation to reflect this new configuration option.

AutoUpdate bool
UpdateFrequency time.Duration
IPv4 string
Expand Down
Loading