Psiphon for OpenWrt


#!/bin/shsed -r 's/\{"data": "([^"]*)".*/\1/' |\sed 's/\\n/0a/g' |\while read -n2 c; do printf "\x$c"; done |\sed -r -n 's/.*"region": "([^"]*)".*"capabilities": \[.*"SSH".*\].*"sshPort": ([0-9]*).*"sshUsername": "([^"]*)".*"ipAddress": "([^"]*)".*"sshPassword": "([^"]*)".*/\4\t\1\t\2\t\3\t\5/p'

使用:wget -O – | ./ > /etc/psi_server建议在pc上执行,路由器上shell处理hex string的那步太慢。仅支持ssh服务器。ossh懒去编译的,meek是go语言写的,重写太难。服务启动脚本/etc/init.d/psiphon:

#!/bin/sh /etc/rc.commonSTART=95PID_FILE=/var/run/psiphon.pidstart() {while read host region port user pass; do[ ${host:0:1} = '#' ] && continueecho "Try connecting $host"empty -f -p $PID_FILE ssh -C -N -D -p $port -l "$user" "$host"while true; do	empty -w -t 2 'yes/no' 'yes\n' 'assword:' "$pass\n" >/dev/null	case $? in	2)		echo 'Connected'		exit		;;	255)		echo 'Connect failed'		empty -k		break		;;	esacdonedone < /etc/psi_server}stop() {kill `cat $PID_FILE`}

参考文献:Build a wheel of autossh using expect

Leave a Reply

Your email address will not be published. Required fields are marked *