#!/bin/bash
    if [[ ! $(ipfs p2p ls | grep x/strfry-12D3KooWHTSu2e7shxtoNmCkLV1Nax1MDtnaJfwBng8tSX9DKtxu) ]]; then
        ipfs --timeout=10s ping -n 4 /p2p/12D3KooWHTSu2e7shxtoNmCkLV1Nax1MDtnaJfwBng8tSX9DKtxu
        [[ $? == 0 ]] \
            && ipfs p2p forward /x/strfry-12D3KooWHTSu2e7shxtoNmCkLV1Nax1MDtnaJfwBng8tSX9DKtxu /ip4/127.0.0.1/tcp/9999 /p2p/12D3KooWHTSu2e7shxtoNmCkLV1Nax1MDtnaJfwBng8tSX9DKtxu \
            && echo "STRFRY RELAY PORT FOR 12D3KooWHTSu2e7shxtoNmCkLV1Nax1MDtnaJfwBng8tSX9DKtxu" \
            && echo "WebSocket URL: ws://127.0.0.1:9999" \
            && echo "NOSTR Relay accessible via IPFS P2P tunnel on local port 9999" \
            && echo "Local relay: ws://127.0.0.1:9999" \
            || echo "CONTACT IPFSNODEID FAILED - ERROR -"
    else
            echo "Tunnel /x/strfry already active..."
            echo "ipfs p2p close -p /x/strfry-12D3KooWHTSu2e7shxtoNmCkLV1Nax1MDtnaJfwBng8tSX9DKtxu"
    fi
    
