Skip to content

Commit

Permalink
fix(p2p): parse maddr correctly
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mudler committed Nov 21, 2024
1 parent 163ca74 commit 0670d3f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,20 @@ func newNodeOpts(token string) ([]node.Option, error) {
// TODO: move this up, expose more config options when creating a node
noDHT := os.Getenv("LOCALAI_P2P_DISABLE_DHT") == "true"
noLimits := os.Getenv("LOCALAI_P2P_ENABLE_LIMITS") == "true"
listenMaddrs := strings.Split(os.Getenv("LOCALAI_P2P_LISTEN_MADDRS"), ",")
bootstrapPeers := strings.Split(os.Getenv("LOCALAI_P2P_BOOTSTRAP_PEERS_MADDRS"), ",")

var listenMaddrs []string
var bootstrapPeers []string

laddrs := os.Getenv("LOCALAI_P2P_LISTEN_MADDRS")
if laddrs != "" {
listenMaddrs = strings.Split(laddrs, ",")
}

bootmaddr := os.Getenv("LOCALAI_P2P_BOOTSTRAP_PEERS_MADDRS")
if bootmaddr != "" {
bootstrapPeers = strings.Split(bootmaddr, ",")
}

dhtAnnounceMaddrs := stringsToMultiAddr(strings.Split(os.Getenv("LOCALAI_P2P_DHT_ANNOUNCE_MADDRS"), ","))

libp2ploglevel := os.Getenv("LOCALAI_P2P_LIB_LOGLEVEL")
Expand Down

0 comments on commit 0670d3f

Please sign in to comment.