mirror of
https://github.com/aljazceru/haven.git
synced 2026-02-11 00:24:19 +01:00
feat(config): update relay list parsing
Update getRelayListFromEnvOrFile function to prioritize file over environment variable. Improve relay list parsing to handle both 'wss://' and 'ws://' prefixes.
This commit is contained in:
17
config.go
17
config.go
@@ -54,15 +54,16 @@ type AwsConfig struct {
|
||||
|
||||
func getRelayListFromEnvOrFile(envKey, fileKey string) []string {
|
||||
envValue := getEnv(envKey)
|
||||
if envValue != "" {
|
||||
return getRelayList(envValue)
|
||||
}
|
||||
|
||||
filePath := getEnv(fileKey)
|
||||
|
||||
if filePath != "" {
|
||||
return getRelayListFromFile(filePath)
|
||||
}
|
||||
|
||||
if envValue != "" {
|
||||
return getRelayList(envValue)
|
||||
}
|
||||
|
||||
return []string{}
|
||||
}
|
||||
|
||||
@@ -127,7 +128,13 @@ func getRelayListFromFile(filePath string) []string {
|
||||
}
|
||||
|
||||
for i, relay := range relayList {
|
||||
relayList[i] = "wss://" + strings.TrimSpace(relay)
|
||||
relay = strings.TrimSpace(relay)
|
||||
if strings.HasPrefix(relay, "wss://") {
|
||||
relay = strings.TrimPrefix(relay, "wss://")
|
||||
} else if strings.HasPrefix(relay, "ws://") {
|
||||
relay = strings.TrimPrefix(relay, "ws://")
|
||||
}
|
||||
relayList[i] = relay
|
||||
}
|
||||
return relayList
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user