removes NOT friends from IPFS swarm

This commit is contained in:
qo-op 2020-04-29 19:55:45 +02:00
parent dd70bc62ef
commit 3979cd6b0a
5 changed files with 35 additions and 15 deletions

View File

@ -6,9 +6,18 @@ It contains per channel/wallets credentials and properties (each unique).
SSB is the source of the gossip ipfs swarm structure SSB is the source of the gossip ipfs swarm structure
Blob can accept commands from the differents channels it manages. Blob can accept commands from the differents channels it manages.
Channels are populated/monitored through to ~/.zen/ipfs_swarm
IMPORTANT TODO!! IMPORTANT TODO!!
timeout.sh CPU problem to investigate - timeout.sh CPU problem to investigate
# MOVE swarm.key (once cron_MINUTE.sh is activated should be OK)
mv ~/.ipfs/swarm.key ~/.ipfs/swarm.key.old
sudo systemctl restart ipfs
# Restart ssb-server
# kill -9 $(ps auxf --sort=+utime | grep -w ssb-server| grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
# IPFS FILESYSTEM STRUCTURE # IPFS FILESYSTEM STRUCTURE

View File

@ -38,22 +38,27 @@ echo '
Get ipfs addresses from SSB friends and add to bootstrap & swarm peers' Get ipfs addresses from SSB friends and add to bootstrap & swarm peers'
# GET /tmp/ssb-friends.json to choose SWARM peers # GET /tmp/ssb-friends.txt
self=$(sbotc whoami | jq -r .id) self=$(sbotc whoami | jq -r .id)
sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"contact"}}}}]}' | jq -r '.value?.content?.contact' > /tmp/ssb-friends.json || rm -f /tmp/ssb-friends.json sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"contact"}}}}]}' | jq -r '.value?.content?.contact' > /tmp/ssb-friends.txt || rm -f /tmp/ssb-friends.txt
# GET /tmp/ssb-NOTfriends.txt
FEED_ID="$(sbotc whoami | jq .id -r)"
sbotc links "{\"source\": \"${FEED_ID}\", \"rel\": \"contact\", \"values\": true, \"reverse\": true}" | jq -c . | grep 'blocking":true' | jq -r .dest > /tmp/ssb-NOTfriends.txt
# SSB FRIENDS ARE "swarm connected" ########################################################################
for SSBFRIEND in $(cat /tmp/ssb-friends.json); do # Let's look if our SSB Friends ARE "IPFS swarm connected"
# ########################################################################
### GET SSB "ipfstryme" message type !!! for SSBFRIEND in $(cat /tmp/ssb-friends.txt); do
### GET SSB "ipfstryme" message type !!! Astroport Node should have publish it during "ssb_INIT.sh"
TRYME=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"ipfstryme"}}}}]}' | jq -r .value?.content?.text | tail -n 1) TRYME=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"ipfstryme"}}}}]}' | jq -r .value?.content?.text | tail -n 1)
## REMOVE NOTfriends from IPFS swarm
[[ $(grep -Rwl "$SSBFRIEND" /tmp/ssb-NOTfriends.txt) ]] && ipfs swarm disconnect $TRYME && ipfs bootstrap rm $TRYME && continue
## ADD Friend to our IPFS swarm
[[ $TRYME ]] && ipfs swarm connect $TRYME && ipfs bootstrap add $TRYME [[ $TRYME ]] && ipfs swarm connect $TRYME && ipfs bootstrap add $TRYME
# Modify ipfs swarm peers and bootstrap related to ssb friends
done done
# All memorized IPFS Nodes are swarm connected (again?)
#for IPFSNODEADDR in $(cat ~/.zen/ipfs_swarm/.Qm*/tryme.addr); do
# ipfs swarm connect $IPFSNODEADDR
# Renew ipfs_swarm knows ...
#done

View File

@ -18,7 +18,7 @@ from sys import argv
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
# path to save to # path to save to
path = "./.secret.dunikey" path = "/tmp/secret.dunikey"
key = SigningKey.from_credentials(argv[1], argv[2], None) key = SigningKey.from_credentials(argv[1], argv[2], None)
key.save_pubsec_file(path) key.save_pubsec_file(path)

View File

@ -73,7 +73,7 @@ fi
# CREATE ~/.ssb/secret.dunikey # CREATE ~/.ssb/secret.dunikey
python3 $MY_PATH/key_create_dunikey.py "$salt" "$pepper" python3 $MY_PATH/key_create_dunikey.py "$salt" "$pepper"
mv $MY_PATH/.secret.dunikey ~/.ssb/secret.dunikey mv /tmp/secret.dunikey ~/.ssb/secret.dunikey
# CREATE SSB secret # CREATE SSB secret
g1pub=$(cat ~/.ssb/secret.dunikey | grep "pub" | cut -d ' ' -f 2) g1pub=$(cat ~/.ssb/secret.dunikey | grep "pub" | cut -d ' ' -f 2)

View File

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
# Author @f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519
invite="${1?invite}" invite="${1?invite}"
code="${invite##*~}" code="${invite##*~}"
@ -12,9 +13,14 @@ out="$(sbotc -s "$host" -p "$port" -k "$feed" -K "$code" -t async invite.use {}
if echo "$out" | grep -q 'feed to follow is missing' if echo "$out" | grep -q 'feed to follow is missing'
then then
echo success echo success
elif echo "$out" | grep -q 'method:invite,use is not in list of allowed methods'
then
echo invalid/expired
exit 1
else else
echo fail echo fail
echo "$out" echo "$out"
echo trying another method:
sbotc -s "$host" -p "$port" -k "$feed" -K "$code" -t source blobs.get '' sbotc -s "$host" -p "$port" -k "$feed" -K "$code" -t source blobs.get ''
exit 1 exit 1
fi fi