diff --git a/README.md b/README.md index 38a884e..67041f6 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ modouSS * 加入pdnsd,避免dns污染问题 * 修复了未加www访问某些网站时不能解析的问题 * 解决了某宽带对dns查询(tcp)的劫持问题 + * 支持魔豆路由宝配置 ## 缺陷 diff --git a/conf/actions.json b/conf/actions.json new file mode 100644 index 0000000..534a127 --- /dev/null +++ b/conf/actions.json @@ -0,0 +1,15 @@ +{ + "start_shadow_socks" : { + "id" : "start_shadow_socks", + "is_sync" : false, + "cmd" : "./init start", + "relative": true + }, + "stop_shadow_socks" : { + "id" : "stop_shadow_socks", + "is_sync" : false, + "cmd" : "./init stop", + "relative": true + } + } + diff --git a/conf/data.json b/conf/data.json new file mode 100644 index 0000000..be9d2ff --- /dev/null +++ b/conf/data.json @@ -0,0 +1,55 @@ +{ + "state_shadow_socks" : { + "id" : "state_shadow_socks", + "name" : "状态", + "value" : false, + "group_id" : "main_info_display", + "type" : { + "class" : "BOOL" + } + }, + "service_ip_address" : { + "id" : "service_ip_address", + "name" : "服务地址", + "value" : "", + "group_id" : "main_info_display", + "type" : { + "class" : "STRING", + "min" : 7, + "max" : 15 + } + }, + "port_shadow_socks" : { + "id" : "port_shadow_socks", + "name" : "端口号", + "value" : 0, + "group_id" : "main_info_display", + "type" : { + "class" : "INT", + "min" : 10, + "max" : 9999999 + } + }, + "method_security" : { + "id" : "method_security", + "name" : "加密方式", + "value" : "", + "group_id" : "main_info_display", + "type" : { + "class" : "ENUM", + "items" : ["aes-256-cfb", "aes-192-cfb", "aes-128-cfb", "bf-cfb", "camellia-128-cfb", "camellia-192-cfb", "camellia-256-cfb", "cast5-cfb", "des-cfb", "idea-cfb", "rc2-cfb", "rc4", "seed-cfb"], + "multiple" : false + } + }, + "password_shadow_socks" : { + "id" : "password_shadow_socks", + "name" : "密码", + "value" : "", + "group_id" : "main_info_display", + "type" : { + "class" : "STRING", + "min" : 6, + "max" : 30 + } + } + } diff --git a/conf/mobile_views.json b/conf/mobile_views.json new file mode 100644 index 0000000..069588b --- /dev/null +++ b/conf/mobile_views.json @@ -0,0 +1,99 @@ +{ + "main_page_shadow_socks" : { + "id" : "main_page_shadow_socks", + "name" : "魔豆ShadowSocks", + "type" : "main", + "data" : { + "state_shadow_socks" : { + "id" : "state_shadow_socks", + "access" : "RO" + }, + "service_ip_address" : { + "id" : "service_ip_address", + "access" : "RO" + }, + "port_shadow_socks" : { + "id" : "port_shadow_socks", + "access" : "RO" + }, + "method_security" : { + "id" : "method_security", + "access" : "RO" + }, + "password_shadow_socks" : { + "id" : "password_shadow_socks", + "access" : "RO" + } + }, + "menu" : { + "1" : { + "index" : 1, + "text" : "开启服务", + "type" : "COMMAND", + "action" : "start_shadow_socks", + "input" : "params" + }, + "2" : { + "index" : 2, + "text" : "服务控制", + "type" : "MENU", + "items" : { + "1" : { + "index" : 1, + "text" : "开启服务", + "type" : "COMMAND", + "action" : "start_shadow_socks", + "input" : "params" + }, + "2" : { + "index" : 2, + "text" : "关闭服务", + "type" : "COMMAND", + "action" : "stop_shadow_socks", + "input" : "params" + }, + "3" : { + "index" : 3, + "text" : "配置账号", + "type" : "VIEW", + "viewid" : "page_account_setting" + } + } + }, + "3" : { + "index" : 3, + "text" : "配置账号", + "type" : "VIEW", + "viewid" : "page_account_setting" + } + } + }, + "page_account_setting" : { + "id" : "page_account_setting", + "name" : "配置账号", + "type" : "sub", + "data" : { + "state_shadow_socks" : { + "id" : "state_shadow_socks", + "access" : "RW" + }, + "service_ip_address" : { + "id" : "service_ip_address", + "access" : "RW" + }, + "port_shadow_socks" : { + "id" : "port_shadow_socks", + "access" : "RW" + }, + "method_security" : { + "id" : "method_security", + "access" : "RW" + }, + "password_shadow_socks" : { + "id" : "password_shadow_socks", + "access" : "RW" + } + } + } + } + diff --git a/init b/init index 0404204..c2dc7e8 100755 --- a/init +++ b/init @@ -59,9 +59,10 @@ status() return 0; } -config() +set_config() { - echo "Hello, modou" + $CURDIR/sbin/ss.sh stop + $CURDIR/sbin/ss.sh start return 0; } @@ -94,8 +95,8 @@ case "$1" in fi exit 0; ;; - "config") - config; + "set_config") + set_config; if [ "0" != "$?" ]; then exit 1; fi diff --git a/manifest.json b/manifest.json index 9f676e2..c7ac471 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,11 @@ { "package_id" : "com.modouwifi.vpnss", -"os_version" : "0.6.33", +"os_version" : "0.6.38", "name" : "魔豆shadowsocks", "author" : "yinkeedai", "author_mail" : "shadow@shadowsocks.org", "homepage" : "shadowsocks.org", -"version" : "0.2.2", +"version" : "0.3.0", "release_date" : "2014.10.13", "icon" : "./res/icon.png", "location" : "internal", diff --git a/sbin/ss.sh b/sbin/ss.sh index 918b539..a7b5f7e 100755 --- a/sbin/ss.sh +++ b/sbin/ss.sh @@ -3,6 +3,7 @@ CURWDIR=$(cd $(dirname $0) && pwd) CUSTOMCONF="$CURWDIR/../conf/custom.conf" SETCONFDEF="$CURWDIR/../conf/set.def" SETCONF="$CURWDIR/../conf/set.conf" +DATAJSON="$CURWDIR/../conf/data.json" PDNSDCONFILE="$CURWDIR/../conf/pdnsd.conf" PIDFILE="$CURWDIR/../conf/custom.pid" SSBIN="$CURWDIR/../bin/ss-redir" @@ -95,8 +96,10 @@ genCustomContent() if [ "$isserverstart" == "1" ]; then contentbody="**服务已启动**" + /system/sbin/json4sh.sh "set" $DATAJSON state_shadow_socks value true else contentbody="**服务未启动**" + /system/sbin/json4sh.sh "set" $DATAJSON state_shadow_socks value false fi if [ "$isserverconfig" == "1" ]; then @@ -168,6 +171,14 @@ ssTpStart() ssConfig() { generate-config-file $SETCONFDEF + serveraddr=`head -n 1 $SETCONFDEF | cut -d ' ' -f2-`; + serverport=`head -n 2 $SETCONFDEF | tail -n 1 | cut -d ' ' -f2-`; + secmode=`head -n 3 $SETCONFDEF | tail -n 1 | cut -d ' ' -f2-`; + passwd=`head -n 4 $SETCONFDEF | tail -n 1 | cut -d ' ' -f2-`; + /system/sbin/json4sh.sh "set" $DATAJSON service_ip_address value $serveraddr + /system/sbin/json4sh.sh "set" $DATAJSON port_shadow_socks value $serverport + /system/sbin/json4sh.sh "set" $DATAJSON method_security value $secmode + /system/sbin/json4sh.sh "set" $DATAJSON password_shadow_socks value $passwd cp $SETCONFDEF $SETCONF genCustomConfig; pid=`cat $PIDFILE 2>/dev/null`; @@ -178,10 +189,10 @@ ssConfig() ssStart() { pdnsdEnable; - serveraddr=`head -n 1 $SETCONF | cut -d ' ' -f2-`; - serverport=`head -n 2 $SETCONF | tail -n 1 | cut -d ' ' -f2-`; - secmode=`head -n 3 $SETCONF | tail -n 1 | cut -d ' ' -f2-`; - passwd=`head -n 4 $SETCONF | tail -n 1 | cut -d ' ' -f2-`; + serveraddr=`/system/sbin/json4sh.sh "get" $DATAJSON service_ip_address value` + serverport=`/system/sbin/json4sh.sh "get" $DATAJSON port_shadow_socks value` + secmode=`/system/sbin/json4sh.sh "get" $DATAJSON method_security value` + passwd=`/system/sbin/json4sh.sh "get" $DATAJSON password_shadow_socks value` $SSSHELL $serveraddr $serverport $secmode $passwd & chown matrix $PDNSDCONFILE 1>/dev/null 2>&1 $PDNSDBIN -c $PDNSDCONFILE & @@ -196,6 +207,8 @@ ssStop() { pdnsdDisable; killall ss-redir 1>/dev/null 2>&1; + killall sswhitelist.sh 1>/dev/null 2>&1; + killall ss-transp.sh 1>/dev/null 2>&1; iptables -t nat -F PDNSD 1>/dev/null 2>&1 iptables -t nat -D OUTPUT -p tcp -j PDNSD 1>/dev/null 2>&1 iptables -t nat -F SHADOWSOCKS 1>/dev/null 2>&1