adding all known Addresses to ipfstryme

This commit is contained in:
qo-op 2020-12-25 17:27:17 +01:00
parent 4e057e37b0
commit c19375e85e
7 changed files with 50 additions and 313 deletions

11
zen/bash_template.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.12.25
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(ipfs id -f='<id>\n')

View File

@ -1,115 +0,0 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.11.30
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
########################################################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! EXIT" && exit 1
########################################################################
[[ ! -f ~/.zen/secret.dunikey ]] && echo "Missing ~/.zen/secret.dunikey. EXIT" && exit 1
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
[[ $G1PUB == "" ]] && echo "ERROR G1PUB empty !! EXIT" && exit 1
########################################################################
# GET NODE disk performance. TODO, publish and use as IPFS repartition
echo "DISK SIZE AVAILABLE & PERFORMANCE TESTING"
[[ -f ~/.ipfs/test.disk ]] && rm -f ~/.ipfs/test.disk
diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
# echo $diskperf
# IPFS LOCAL REPOSITORY for Node Identity
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
# find IPFSTRYME public address
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
for tryme in $(ipfs id | jq -r .Addresses[]);
do
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
done
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
################################
# ADD Cesium+ informations
CESIUMPLUS="https://g1.data.le-sou.org"
# PREPARE title
# Made from Gchange+ profile tittle and city OR user@hostname
title=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq -r '._source.title')
[[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]] && uidna=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
# Put in .$IPFSNODEID INDEX: _g1.uidna & _g1.cesium_name (used by Minetest flavour and others)
[[ $uidna ]] && echo "$uidna" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.uidna
[[ $title ]] && echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.cesium_name
[[ $uidna ]] && [[ "$title" == "null" ]] && title="Station $uidna"
[[ "$title" == "null" ]] && title="Station $USER@$(cat /etc/hostname)"
city=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq -r '._source.city')
[[ "$city" != "null" ]] && title="$title in $city"
# ADD "cesium_geoPoint.lat" AND "cesium_geoPoint.lon" messages in SSB feed
# This way any SSB account is connected to its Cesium+ Geolocalisation.
geopointlat=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq '._source.geoPoint.lat')
geopointlon=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq '._source.geoPoint.lon')
# REFRESH Cesium+ Avatar image
curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq -r '._source.avatar._content' | base64 -d > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.cesium.avatar.png"
# Get nodename
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename ]] && nodename=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename)
if [[ $nodename == "" ]]; then
nodename=$(cat /etc/hostname)
extension=$(echo $nodename | cut -d '.' -f 2)
if [[ $extension == $nodename ]]; then
nodename=$nodename.home
fi
echo "$nodename" > /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename
fi
########################################################################
# DUNITER G1 Wallet balance
export LC_ALL=C.UTF-8 #attipix
export LANG=C.UTF-8 #attipix
# COPY NODE G1SSB ID to IPFS
echo "$G1PUB" > ~/.zen/ipfs/.${IPFSNODEID}/G1SSB/_g1.pubkey
# IPFS Node PUBLISH Adresses so Pub can become bootstrap for ${g1author}
ipfs id | jq -r .Addresses[] > ~/.zen/ipfs/.${IPFSNODEID}/Addresses
# IPFS Node PUBLISH AgentVersion & repo.stat
ipfs id | jq -r .AgentVersion > ~/.zen/ipfs/.${IPFSNODEID}/AgentVersion
ipfs repo stat > ~/.zen/ipfs/.${IPFSNODEID}/repo.stat
echo "$diskperf" > ~/.zen/ipfs/.${IPFSNODEID}/disk.perf
echo $(df ~/.ipfs/ | tail -n 1 | awk '{print $4}') > ~/.zen/ipfs/.${IPFSNODEID}/disk.bytes
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
###
# GET ALL MY CESIUMPLUS FRIENDS AND SEND THEM my IPFS Address
cd ~/.zen/astrXbian/zen/jaklis
# GET LIST of issuer(s) who likes me
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
do
# CHECk if I am liking him either
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
echo "Sending IPFSTRYME message to $liking_me"
[[ $friend_of_mine != null ]] && ./jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
done
cd -
exit 0

View File

@ -1,118 +0,0 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.12.03
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
# Connect to IPFS peers with bidirectionnal "like" (Cesium+ friends)
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# GET CESIUM FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM
########################################################################'
## TODO : Beware of liking_me FLOOD & Invite $liking_me people to my #Swarm0 (use natools to sign messages?)
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
########################################################################
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
[[ ! $isIPFSRunning ]] && echo "ERROR! ipfs daemon is not running. EXIT" && exit 1
########################################################################
# Force Strict #swarm0 !!?
# ipfs bootstrap rm --all
echo "" > ~/.zen/A_allow_ip.txt
echo "" > ~/.zen/A_liking_me_NO_ipfstryme.txt # contains "friends" with no "ipfstryme" incoming message
liking_me_count=0
friend_of_mine_count=0
########################################################################
# Let's look for Friends and "IPFS swarm connect" with them
########################################################################
cd ~/.zen/astrXbian/zen/jaklis
rm -f ~/.zen/A_allow_ipfsid.txt ~/.zen/A_allow_ip.txt
# 1. Get C+ "liking_me" people list
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
do
# Check if my like is reverse
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
[[ $friend_of_mine != null ]] && echo "Connect to my friend $liking_me" && friend_of_mine_count=$((friend_of_mine_count+1)) && ipfsadd=0 \
&& for peer in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
# 2. Searching "ipfstryme" message from friend_of_mine
do
ip=$(echo "$peer" | awk -F '/' '{print $3}') && [[ $ip == "" ]] && continue || echo "Adding $ip to ~/.zen/A_allow_ip.txt"
# Fill a file with friend of mine ip
echo $ip >> ~/.zen/A_allow_ip.txt
# Get its ipfsnodeid
ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $8}')
echo $ipfsnodeid >> ~/.zen/A_allow_ipfsid.txt
g1id=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py "$ipfsnodeid")
if [[ "$g1id" == "$friend_of_mine" ]]; then
# 3. ADD liking_me friend_of_mine to my swarm & bootstrap
ipfs swarm connect $peer;
ipfs bootstrap add $peer;
ipfsadd=$((ipfsadd+1))
else
echo "ALERT!!! $friend_of_mine spoofing is happening"
fi
done;
if [[ $friend_of_mine != null ]]; then
if [[ $ipfsadd == 0 ]]; then
# Friend of mine with no ipfstryme message (did not install astroport?)
echo "No 'ipfstryme' message... from $liking_me"
echo "$liking_me" >> ~/.zen/A_liking_me_NO_ipfstryme.txt
else
# REMOVING DUPLICATES OLD ipfstryme MESSAGES
nbmessage=0
for messageid in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
do
nbmessage=$((nbmessage+1))
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $liking_me" && ./jaklis.py delete -i $messageid
done
fi
fi
# Automatic level_1 like from oasis.astroport.com (TODO add other default bootstrap)
# TODO get $g1pub from ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey ??
# [[ $friend_of_mine == null && $G1PUB == "2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS" ]] && ./jaklis.py like -p $g1pub -s 1
echo "__________________________________________"
liking_me_count=$((liking_me_count+1))
done
echo "####################################################
I have $friend_of_mine_count friends amoung $liking_me_count liking me people
__________________________________________
My actual #SWARM0"
ipfs swarm peers
echo "__________________________________________"
echo
## Could send message to friends with 'ipfstryme' message
for line in $(cat ~/.zen/A_liking_me_NO_ipfstryme.txt | uniq); do
echo "Liking each other, but no ipfstryme received..."
echo "cd ~/.zen/astrXbian/zen/jaklis"
echo "./jaklis.py send -d $line -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
done
cd -

View File

@ -30,12 +30,6 @@ diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
# find IPFSTRYME public address
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
for tryme in $(ipfs id | jq -r .Addresses[]);
do
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
done
~/.zen/astrXbian/zen/tools/add_externIP_to_ipfstryme.sh
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
@ -103,16 +97,15 @@ NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
###
# GET ALL MY GCHANGE FRIENDS AND SEND THEM my IPFS Address
cd ~/.zen/astrXbian/zen/jaklis
# GET LIST of issuer(s) who likes me
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
for liking_me in $(~/.zen/astrXbian/zen/jaklis/jaklis.py like | jq -r '.likes[].issuer');
do
# CHECk if I am liking him either
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
friend_of_mine=$(~/.zen/astrXbian/zen/jaklis/jaklis.py like -p $liking_me | jq -r '.yours');
echo "Sending IPFSTRYME message to $liking_me"
[[ $friend_of_mine != null ]] && ./jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
[[ $friend_of_mine != null ]] && ~/.zen/astrXbian/zen/jaklis/jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
done
echo 'SEND ipfstryme to A_boostrap_nodes.txt listed PUBs' # Add your bootstrap Pub here
for g1node in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do
@ -122,7 +115,7 @@ if [[ $g1node != "" ]]; then
~/.zen/astrXbian/zen/jaklis/jaklis.py send -d $g1node -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
fi
done
cd -
# SHOW RESULT
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr

View File

@ -19,10 +19,8 @@ ME="${0##*/}"
# ex: ./'$ME'
# GET GCHANGE FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM
########################################################################'
## TODO : Beware of liking_me FLOOD & Invite $liking_me people to my #Swarm0
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
########################################################################
@ -35,38 +33,36 @@ isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|gr
# Force Strict #swarm0 !!?
# ipfs bootstrap rm --all
echo "" > ~/.zen/A_allow_ip.txt
echo "" > ~/.zen/A_allow_ipfsid.txt
echo "" > ~/.zen/A_liking_me_NO_ipfstryme.txt # contains "friends" with no "ipfstryme" incoming message
liking_me_count=0
friend_of_mine_count=0
########################################################################
# Let's look for Friends and "IPFS swarm connect" with them
########################################################################
cd ~/.zen/astrXbian/zen/jaklis
rm -f ~/.zen/A_allow_ipfsid.txt ~/.zen/A_allow_ip.txt
# 1. Get Gchange "liking_me" people list
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
for liking_me in $(~/.zen/astrXbian/zen/jaklis/jaklis.py like | jq -r '.likes[].issuer');
do
# Check if my like is reverse
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
friend_of_mine=$(~/.zen/astrXbian/zen/jaklis/jaklis.py like -p $liking_me | jq -r '.yours.pseudo'); # contains my XZUID
[[ $friend_of_mine != null ]] && echo "Connect to my friend $liking_me" && friend_of_mine_count=$((friend_of_mine_count+1)) && ipfsadd=0 \
&& for peer in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
&& for peerline in $(~/.zen/astrXbian/zen/jaklis/jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
# 2. Searching "ipfstryme" message from friend_of_mine
do
ip=$(echo "$peer" | awk -F '/' '{print $3}') && [[ $ip == "" ]] && continue || echo "Adding $ip to ~/.zen/A_allow_ip.txt"
ip=$(echo "$peerline" | awk -F '/' '{print $3}') && [[ $ip == "" ]] && continue || echo "Adding $ip to ~/.zen/A_allow_ip.txt"
# Fill a file with friend of mine ip
echo $ip >> ~/.zen/A_allow_ip.txt
# Get its ipfsnodeid
ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $7}')
ipfsnodeid=$(echo "$peerline" | awk -F '/' '{print $7}')
echo $ipfsnodeid >> ~/.zen/A_allow_ipfsid.txt
g1id=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py "$ipfsnodeid")
if [[ "$g1id" == "$friend_of_mine" ]]; then
# 3. ADD liking_me friend_of_mine to my swarm & bootstrap
ipfs swarm connect $peer;
ipfs bootstrap add $peer;
ipfs swarm connect $peerline;
ipfs bootstrap add $peerline;
ipfsadd=$((ipfsadd+1))
else
@ -84,21 +80,16 @@ do
else
# REMOVING DUPLICATES OLD ipfstryme MESSAGES
nbmessage=0
for messageid in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
for messageid in $(~/.zen/astrXbian/zen/jaklis/jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
do
nbmessage=$((nbmessage+1))
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $liking_me" && ./jaklis.py delete -i $messageid
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $liking_me" && ~/.zen/astrXbian/zen/jaklis/jaklis.py delete -i $messageid
done
fi
fi
# Automatic level_1 like from oasis.astroport.com (TODO add other default bootstrap)
# TODO get $g1pub from ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey ??
# [[ $friend_of_mine == null && $G1PUB == "2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS" ]] && ./jaklis.py like -p $g1pub -s 1
echo "__________________________________________"
liking_me_count=$((liking_me_count+1))
done
@ -116,4 +107,3 @@ for line in $(cat ~/.zen/A_liking_me_NO_ipfstryme.txt | uniq); do
echo "./jaklis.py send -d $line -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
done
cd -

View File

@ -1,44 +0,0 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.18
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
########################################################################
# \\///
# qo-op
#############
##########################
#######################################
####################################################
########################################################################
########################################################################
# check /tmp/cmd_received_$SOURCEH and /tmp/cmd_SPAM_$SOURCEH within 1mn
# Remove older than a minute received COMMAND
find /tmp -cmin +1 -type f -name "cmd_received_*" -exec rm -f '{}' \; 2>/dev/null
# Filter Acknowlegement
if [[ "$CMD" != "ACK" && "$CMD" != "DELIVERED" && "$CMD" != "PENDING" ]]; then
# Still less than a minute with same $SOURCEH
if [[ -f "/tmp/cmd_received_$SOURCEH" ]]; then
# Create SPAM file => Stop answering
if [[ ! -f "/tmp/cmd_SPAM_$SOURCEH" ]]; then
echo $(date) > "/tmp/cmd_SPAM_$SOURCEH"
fi
return 1
fi
echo "$COMMAND" > "/tmp/cmd_received_$SOURCEH"
# Remove SPAM flag older than one day
find /tmp -ctime +1 -type f -name "cmd_SPAM_*" -exec rm -f '{}' \; 2>/dev/null
else
# THIS IS AN AKNOWLEGEMENT
return 1
fi
# Remove SPAM flag older than one day
find /tmp -ctime +1 -type f -name "cmd_SPAM_*" -exec rm -f '{}' \; 2>/dev/null
return 0

View File

@ -11,12 +11,32 @@ ME="${0##*/}"
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(ipfs id -f='<id>\n')
EXTERNIP=$(curl -s http://whatismyip.akamai.com/)
#EXTERNIP=$(curl -s http://whatismyip.akamai.com/)
########################################################################
echo "ADD $EXTERNIP to /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr"
echo "ADDING KNOWN Adresses to /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr"
########################################################################
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}
echo "/ip4/$EXTERNIP/udp/4001/astro/p2p/${IPFSNODEID}" >> /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr
# echo "/ip4/$EXTERNIP/udp/4001/astro/p2p/${IPFSNODEID}" >> /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr
# Doesn't have the right NATed port, so pretty useless...
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
for tryme in $(ipfs id | jq -r .Addresses[]);
do
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "ME = $tryme"
done
# Now adding "ipfs swarm peers" to ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
for tryme in $(ipfs swarm peers);
do
echo "___________________________________________"
echo "$tryme"
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "___________________________________________ADDING"
done
# UNIQ TOUT CA
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr | uniq > /tmp/tryme.addr
cp -f /tmp/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
rm -f /tmp/tryme.addr
exit 0