Add tino scripts. See http://zzz.i2p/topics/960 for details.
This commit is contained in:
28
tino-ping/i2p-debug.sh
Normal file
28
tino-ping/i2p-debug.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DEST="$1"
|
||||||
|
BUG="`tr -d 'A-Za-z0-9-.' <<<"$DEST"`"
|
||||||
|
|
||||||
|
echo "`date -u +%Y%m%d-%H%M%S` $DEST" >> "`dirname "$0"`/ping.log"
|
||||||
|
|
||||||
|
if [ -n "$BUG" ] || [ -z "$DEST" ]
|
||||||
|
then
|
||||||
|
echo "Invalid destination: '$DEST'"
|
||||||
|
echo "Illegal characters: '$BUG'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CR="`echo -e '\r'`"
|
||||||
|
|
||||||
|
(
|
||||||
|
echo "GET / HTTP/1.0$CR"
|
||||||
|
echo "Host: $DEST$CR"
|
||||||
|
echo "X-Probed-Via: test.tino.i2p$CR"
|
||||||
|
echo "$CR"
|
||||||
|
sleep 200
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
socat -v -d -d -d -t10 - socks4a:127.0.0.1:"$DEST":80,socksport=7680 2>&1 >/dev/null
|
||||||
|
kill $$
|
||||||
|
)
|
||||||
|
|
49
tino-ping/i2p-ping.sh
Normal file
49
tino-ping/i2p-ping.sh
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DEST="$1"
|
||||||
|
BUG="`tr -d 'A-Za-z0-9-.' <<<"$DEST"`"
|
||||||
|
|
||||||
|
echo "`date +%Y%m%d-%H%M%S` $DEST" >> "`dirname "$0"`/debug.log"
|
||||||
|
|
||||||
|
if [ -n "$BUG" ] || [ -z "$DEST" -a 0 != $# ]
|
||||||
|
then
|
||||||
|
echo "Invalid destination: '$DEST'"
|
||||||
|
echo "Illegal characters: '$BUG'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$HOME/i2p" || exit
|
||||||
|
|
||||||
|
pinger()
|
||||||
|
{
|
||||||
|
exec java -cp ./lib/i2ptunnel.jar:./lib/mstreaming.jar:./lib/streaming.jar:./lib/i2p.jar net.i2p.i2ptunnel.I2PTunnel -cli "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "$DEST" ]
|
||||||
|
then
|
||||||
|
# We have to use a coproc, as we need the PID to kill the process in case something fails
|
||||||
|
coproc PING { pinger; }
|
||||||
|
KILLPID=$!
|
||||||
|
trap 'kill $KILLPID' 0
|
||||||
|
|
||||||
|
o=${PING[0]}
|
||||||
|
i=${PING[1]}
|
||||||
|
|
||||||
|
echo "ping -n 10 -t 30000 $DEST" >&$i
|
||||||
|
|
||||||
|
while read -rt60 line <&$o
|
||||||
|
do
|
||||||
|
echo "`date -u +%Y%m%d-%H%M%S` $line"
|
||||||
|
case "$line" in
|
||||||
|
*Pinger\ closed*)
|
||||||
|
echo quit >&$i
|
||||||
|
exit 0;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[TIMEOUT]"
|
||||||
|
# Coproc will be killed
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
pinger
|
||||||
|
fi
|
79
tino-ping/i2p-test.sh
Normal file
79
tino-ping/i2p-test.sh
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Peer name: $SOCKLINGER_PEER
|
||||||
|
#Sock name: $SOCKLINGER_SOCK
|
||||||
|
|
||||||
|
CR="`echo -e '\r'`"
|
||||||
|
|
||||||
|
run()
|
||||||
|
{
|
||||||
|
echo ''
|
||||||
|
echo "Output of: $3"
|
||||||
|
echo ''
|
||||||
|
"`dirname "$0"`/i2p-$1.sh" "${2% *}" 2>&1
|
||||||
|
echo '[END]'
|
||||||
|
}
|
||||||
|
|
||||||
|
rundebug()
|
||||||
|
{
|
||||||
|
run debug "$1" "socat -v -d -d -d -t10 - socks4a:127.0.0.1:${1% *}:80,socksport=PORT_OF_SOCKS_CLIENT_TUNNEL"
|
||||||
|
}
|
||||||
|
|
||||||
|
runping()
|
||||||
|
{
|
||||||
|
run ping "$1" "sort of: java net.i2p.i2ptunnel.I2PTunnel -cli <<< 'ping ${1% *}'"
|
||||||
|
}
|
||||||
|
|
||||||
|
run=
|
||||||
|
first=
|
||||||
|
|
||||||
|
read -r first
|
||||||
|
|
||||||
|
case "$first" in
|
||||||
|
'GET /?debug='*) run=debug; param="${first#GET /?debug=}";;
|
||||||
|
'GET /?ping='*) run=ping; param="${first#GET /?ping=}";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
got="Current time: `date -u +'%Y-%m-%d %H:%M:%S'` UTC
|
||||||
|
Connect nr: $SOCKLINGER_NR
|
||||||
|
Feature:
|
||||||
|
Debug DEST: http://test.tino.i2p/?debug=DEST
|
||||||
|
Example URL: http://test.tino.i2p/?debug=test.tino.i2p
|
||||||
|
Ping DEST: http://test.tino.i2p/?ping=DEST
|
||||||
|
Example URL: http://test.tino.i2p/?ping=test.tino.i2p
|
||||||
|
"
|
||||||
|
|
||||||
|
[ -z "$*" ] ||
|
||||||
|
got="$got
|
||||||
|
$*
|
||||||
|
"
|
||||||
|
got="$got
|
||||||
|
Your HTTP header was:
|
||||||
|
|
||||||
|
$first"
|
||||||
|
|
||||||
|
while read -r line
|
||||||
|
do
|
||||||
|
got="$got
|
||||||
|
$line"
|
||||||
|
[ . != ".${line%$CR}" ] || break
|
||||||
|
done
|
||||||
|
echo "HTTP/1.0 200 OK$CR"
|
||||||
|
|
||||||
|
if [ -z "$run" ]
|
||||||
|
then
|
||||||
|
got="$got
|
||||||
|
|
||||||
|
[END]"
|
||||||
|
echo "Content-Length: ${#got}$CR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Content-Type: text/plain$CR"
|
||||||
|
echo "Connection: close$CR"
|
||||||
|
echo "Pragma: no-cache$CR"
|
||||||
|
echo "Expires: 0$CR"
|
||||||
|
echo "Cache-control: no-store,no-cache,max-age=0,must-revalidate$CR"
|
||||||
|
echo "$CR"
|
||||||
|
echo -n "$got"
|
||||||
|
|
||||||
|
[ -n "$run" ] && run$run "$param"
|
||||||
|
|
Reference in New Issue
Block a user