Skip to content

Commit 0670d3f

Browse files
committed
fix(p2p): parse maddr correctly
Previously in case of not specifying a value it would pass a slice of 1 empty element Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 163ca74 commit 0670d3f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

core/p2p/p2p.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,20 @@ func newNodeOpts(token string) ([]node.Option, error) {
386386
// TODO: move this up, expose more config options when creating a node
387387
noDHT := os.Getenv("LOCALAI_P2P_DISABLE_DHT") == "true"
388388
noLimits := os.Getenv("LOCALAI_P2P_ENABLE_LIMITS") == "true"
389-
listenMaddrs := strings.Split(os.Getenv("LOCALAI_P2P_LISTEN_MADDRS"), ",")
390-
bootstrapPeers := strings.Split(os.Getenv("LOCALAI_P2P_BOOTSTRAP_PEERS_MADDRS"), ",")
389+
390+
var listenMaddrs []string
391+
var bootstrapPeers []string
392+
393+
laddrs := os.Getenv("LOCALAI_P2P_LISTEN_MADDRS")
394+
if laddrs != "" {
395+
listenMaddrs = strings.Split(laddrs, ",")
396+
}
397+
398+
bootmaddr := os.Getenv("LOCALAI_P2P_BOOTSTRAP_PEERS_MADDRS")
399+
if bootmaddr != "" {
400+
bootstrapPeers = strings.Split(bootmaddr, ",")
401+
}
402+
391403
dhtAnnounceMaddrs := stringsToMultiAddr(strings.Split(os.Getenv("LOCALAI_P2P_DHT_ANNOUNCE_MADDRS"), ","))
392404

393405
libp2ploglevel := os.Getenv("LOCALAI_P2P_LIB_LOGLEVEL")

0 commit comments

Comments
 (0)