Psiphon for OpenWrt

本文谢绝转载与链接。软件包:openssh-client、empty(用于自动输入密码)处理服务器列表的脚本psi_list.sh:

#!/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 – https://psiphon.ca/server_list | ./psi_list.sh > /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 0.0.0.0:1080 -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 *

Using REAL email address will help you receive reply notifications.

Current ye@r *