Skip to content

Commit

Permalink
Merge pull request #51 from JackalLabs/marston/ipfs-fix
Browse files Browse the repository at this point in the history
More ipfs tweaks
  • Loading branch information
TheMarstonConnell authored Jun 29, 2024
2 parents 3028a38 + d991fb2 commit ee4eee5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ipfs/ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@ func MakeIPFS(ctx context.Context, db *badger.DB, port int, customDomain string)
return nil, err
}

listen, _ := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port))
m := []multiaddr.Multiaddr{listen}
listen, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port))
if err != nil {
return nil, fmt.Errorf("failed to make ipv4 ipfs address | %w", err)
}
listen6, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip6/::/tcp/%d", port))
if err != nil {
return nil, fmt.Errorf("failed to make ipv6 ipfs address | %w", err)
}

m := []multiaddr.Multiaddr{listen, listen6}

if !strings.Contains(customDomain, "example.com") && len(customDomain) > 2 {
if !strings.HasPrefix(customDomain, "/") {
customDomain = fmt.Sprintf("/%s", customDomain)
}
domainListener, err := multiaddr.NewMultiaddr(customDomain)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to make domain based ipfs address | %w", err)
}
m = append(m, domainListener)
}
Expand Down

0 comments on commit ee4eee5

Please sign in to comment.