Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 4443c26

Browse files
committed
Retrieve web relays from configuration
1 parent 408da26 commit 4443c26

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

schema/configuration.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,39 @@ func GetRepublishInterval(cfgBytes []byte) (time.Duration, error) {
415415
return d, nil
416416
}
417417

418+
func GetWebRelays(cfgBytes []byte) ([]string, error) {
419+
var cfgIface interface{}
420+
err := json.Unmarshal(cfgBytes, &cfgIface)
421+
if err != nil {
422+
return nil, MalformedConfigError
423+
}
424+
425+
var webRelays []string
426+
427+
cfg, ok := cfgIface.(map[string]interface{})
428+
if !ok {
429+
return webRelays, MalformedConfigError
430+
}
431+
432+
wrcfg, ok := cfg["WebRelays"]
433+
if !ok {
434+
return webRelays, MalformedConfigError
435+
}
436+
wr, ok := wrcfg.([]interface{})
437+
if !ok {
438+
return webRelays, MalformedConfigError
439+
}
440+
441+
for _, nd := range wr {
442+
ndStr, ok := nd.(string)
443+
if !ok {
444+
return webRelays, MalformedConfigError
445+
}
446+
webRelays = append(webRelays, ndStr)
447+
}
448+
return webRelays, nil
449+
}
450+
418451
func GetDataSharing(cfgBytes []byte) (*DataSharing, error) {
419452
var cfgIface interface{}
420453
err := json.Unmarshal(cfgBytes, &cfgIface)

0 commit comments

Comments
 (0)