Skip to content

Commit

Permalink
settings: fix validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Aug 17, 2024
1 parent 75a99a6 commit cfceecd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion host/settings/announce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestAutoAnnounce(t *testing.T) {
}
defer contracts.Close()

sm, err := settings.NewConfigManager(hostKey, node.Store, node.Chain, node.Syncer, wm, settings.WithLog(log.Named("settings")), settings.WithAnnounceInterval(50))
sm, err := settings.NewConfigManager(hostKey, node.Store, node.Chain, node.Syncer, wm, settings.WithLog(log.Named("settings")), settings.WithAnnounceInterval(50), settings.WithValidateNetAddress(false))
if err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 2 additions & 4 deletions host/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,9 @@ func (m *ConfigManager) UpdateSettings(s Settings) error {
}

// if a netaddress is set, validate it
if strings.TrimSpace(s.NetAddress) != "" {
if strings.TrimSpace(s.NetAddress) != "" && m.validateNetAddress {
if err := validateNetAddress(s.NetAddress); err != nil {
if m.validateNetAddress {
return fmt.Errorf("failed to validate net address: %w", err)
}
return fmt.Errorf("failed to validate net address: %w", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion host/settings/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestSettings(t *testing.T) {
}
defer contracts.Close()

sm, err := settings.NewConfigManager(hostKey, node.Store, node.Chain, node.Syncer, wm, settings.WithLog(log.Named("settings")), settings.WithAnnounceInterval(50))
sm, err := settings.NewConfigManager(hostKey, node.Store, node.Chain, node.Syncer, wm, settings.WithLog(log.Named("settings")), settings.WithAnnounceInterval(50), settings.WithValidateNetAddress(false))
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit cfceecd

Please sign in to comment.