From c0a2bafe789e7d219744ab4fba2c9770bd299ac2 Mon Sep 17 00:00:00 2001 From: marston Date: Thu, 27 Jun 2024 17:04:58 -0400 Subject: [PATCH] adding ipv6 --- ipfs/ipfs.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ipfs/ipfs.go b/ipfs/ipfs.go index 8cfeb10..609857c 100644 --- a/ipfs/ipfs.go +++ b/ipfs/ipfs.go @@ -24,8 +24,16 @@ 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, "/") { @@ -33,7 +41,7 @@ func MakeIPFS(ctx context.Context, db *badger.DB, port int, customDomain string) } 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) }