Skip to content

Commit c66acfd

Browse files
committed
merge relays with config relays
1 parent 7a381b0 commit c66acfd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cli/config.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,27 @@ func LoadConfigFile(configPath string) (*ConfigResult, error) {
7878
}, nil
7979
}
8080

81-
// MergeRelayConfigs merges relays passed via --relays to config file settings.
81+
// MergeRelayConfigs merges relays passed via --relays with config file settings.
8282
// this allows the users to still use --relays if they dont want to provide a config file
8383
func MergeRelayConfigs(relays []types.RelayEntry, configMap map[string]types.RelayConfig) []types.RelayConfig {
84-
configs := make([]types.RelayConfig, 0, len(relays))
84+
configs := make([]types.RelayConfig, 0)
85+
processedURLs := make(map[string]bool)
8586

8687
for _, entry := range relays {
87-
if config, exists := configMap[entry.String()]; exists {
88+
urlStr := entry.String()
89+
if config, exists := configMap[urlStr]; exists {
8890
config.RelayEntry = entry
8991
configs = append(configs, config)
9092
} else {
9193
configs = append(configs, types.NewRelayConfig(entry))
9294
}
95+
processedURLs[urlStr] = true
9396
}
9497

98+
for urlStr, config := range configMap {
99+
if !processedURLs[urlStr] {
100+
configs = append(configs, config)
101+
}
102+
}
95103
return configs
96104
}

0 commit comments

Comments
 (0)