This commit is contained in:
qo-op 2020-06-05 17:21:52 +02:00
parent 9fe206e66a
commit 5568d586a8
3 changed files with 73 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

36
zen/port_SSH_one2one.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# Activate SUPPORT MODE: open ssh over IPFS
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
########################################################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
WHOAMI=$(sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
[[ "$YOU" == "" || "$IPFSNODEID" == "" || "$WHOAMI" == "" ]] && echo "ERROR : $er " && exit 1
########################################################################
# TODO ESTABLISH A PORT FORWARD STRATEGY (depending on Node Flavour)
# Arrange local port forwarded to swarm
# GET _uidna (means g1sms/init.sh been run)
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]] && UIDNA=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
if [[ "$IPFSNODEID" == "QmVywXoBSz7JZ5vunYYVwi72SdTizvFt7k7qd3ooyYHvHA" ]]; then
# G1Pub : QmVywXoBSz7JZ5vunYYVwi72SdTizvFt7k7qd3ooyYHvHA
# I am a g1sms NODE, pushing my web interface
ipfs p2p listen /x/g1pub-ssh /ip4/127.0.0.1/tcp/22
# ipfs p2p close -p /x/g1pub-ssh
fi
if [[ "$IPFSNODEID" == "QmVywXoBSz7JZ5vunYYVwi72SdTizvFt7k7qd3ooyYHvHA" ]]; then
# G1Pub : QmVywXoBSz7JZ5vunYYVwi72SdTizvFt7k7qd3ooyYHvHA
# I am a g1sms NODE, pushing my web interface
ipfs p2p listen /x/g1pub-ssh /ip4/127.0.0.1/tcp/22
fi

View File

@ -0,0 +1,37 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# Activate SUPPORT MODE: open ssh over IPFS
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
########################################################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
WHOAMI=$(sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
[[ "$YOU" == "" || "$IPFSNODEID" == "" || "$WHOAMI" == "" ]] && echo "ERROR : $er " && exit 1
########################################################################
# TODO ESTABLISH A PORT FORWARD STRATEGY (depending on Node Flavour)
# Arrange local port forwarded to swarm
# GET _uidna (means g1sms/init.sh been run)
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]] && UIDNA=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
if [[ $(which gammu) ]]; then
# I am a g1sms NODE, pushing my web interface
ipfs p2p listen /x/g1sms /ip4/127.0.0.1/tcp/10099
else
# Looking for g1sms NODE in my swarm
SMSNODE=$(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/G1SSB/_g1sms | shuf -n 1 | cut -d '/' -f 6 | cut -d '.' -f 2)
# Wait for DHT to propagate.... before getting eventual /x/g1sms forward
[[ $SMSNODE ]] && sleep $((1 + RANDOM % 10)) && ipfs p2p forward /x/g1sms /ip4/127.0.0.1/tcp/10097 /p2p/$SMSNODE
fi
# ipfs p2p close --all
# ipfs p2p listen /x/ssh-$UIDNA /ip4/127.0.0.1/tcp/22
# ipfs p2p listen /x/http-$UIDNA /ip4/127.0.0.1/tcp/80
# ipfs p2p listen /x/https-$UIDNA /ip4/127.0.0.1/tcp/443
ipfs p2p ls