├── Changelog.txt ├── backup.sh ├── build.py ├── config.json.js ├── history ├── 1.5 │ └── ssserver.tar.gz ├── 1.6 │ └── ssserver.tar.gz ├── 1.7 │ └── ssserver.tar.gz ├── 1.8 │ └── ssserver.tar.gz ├── 1.9 │ └── ssserver.tar.gz ├── 2.0 │ └── ssserver.tar.gz ├── 2.1 │ └── ssserver.tar.gz └── version ├── ssserver.tar.gz └── ssserver ├── bin ├── obfs-server └── ss-server ├── install.sh ├── res └── icon-ssserver.png ├── scripts └── ssserver_config.sh ├── ssserver └── ssserver.sh ├── uninstall.sh └── webs └── Module_ssserver.asp /Changelog.txt: -------------------------------------------------------------------------------- 1 | Koolshare Asuswrt-Merlin ss-server Changelog 2 | =========================================== 3 | 2.0 4 | - update update config page 5 | - update update ss-server binary to 3.0.8 6 | - add add obfs-server binary version 0.3 7 | - enable obfuscation 8 | 9 | 10 | 1.8 11 | - fix fix iptables rule lost 12 | - add add obfs support 13 | - update update ss-server binary 14 | 15 | 1.6 16 | - fix fix start up 17 | 18 | 1.4 19 | - fix add ss-server binary 20 | 21 | 1.3 22 | - fix fix nat-rule won't clean when disadble ssserver 23 | 24 | 1.0 25 | - add add ss-server 26 | 27 | 1.9 28 | - fix fix iiptables 29 | - fix change binary because newer binary unstable 30 | - add add ss option 31 | -------------------------------------------------------------------------------- /backup.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # you can do something here 4 | # this shell scripts will run at the end of build.py scripts 5 | 6 | 7 | 8 | mkdir -p history 9 | if [ ! -f ./history/version ];then 10 | touch ./history/version 11 | fi 12 | 13 | version_old=`cat history/version | awk '{print $1}' | sort -rn |sed -n 1p` 14 | version_new=`cat config.json.js |grep "version"|cut -d"\"" -f 4` 15 | md5_old=`cat history/version | sort -nk1 | awk '{print $1}' |sed -n 1p` 16 | md5_new=` md5sum ssserver.tar.gz | awk '{print $1}'` 17 | 18 | if [ -f ./ssserver.tar.gz ];then 19 | if [ "$version_old" != "$version_new" ];then 20 | mkdir ./history/$version_new/ 21 | cp ./ssserver.tar.gz ./history/$version_new/ 22 | echo $version_new $md5_new >> ./history/version 23 | fi 24 | fi 25 | 26 | -------------------------------------------------------------------------------- /build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # _*_ coding:utf-8 _*_ 3 | 4 | import os 5 | import json 6 | import codecs 7 | import hashlib 8 | from string import Template 9 | 10 | parent_path = os.path.dirname(os.path.realpath(__file__)) 11 | 12 | def md5sum(full_path): 13 | with open(full_path, 'rb') as rf: 14 | return hashlib.md5(rf.read()).hexdigest() 15 | 16 | def get_or_create(): 17 | conf_path = os.path.join(parent_path, "config.json.js") 18 | conf = {} 19 | if not os.path.isfile(conf_path): 20 | print u"config.json.js 文件找不到,build.py 一定得放插件根目录。自动为您生成一个config.json.js,其它信息请您自己修改。" 21 | module_name = os.path.basename(parent_path) 22 | conf["module"] = module_name 23 | conf["version"] = "0.0.1" 24 | conf["home_url"] = ("Module_%s.asp" % module_name) 25 | conf["title"] = "title of " + module_name 26 | conf["description"] = "description of " + module_name 27 | else: 28 | with codecs.open(conf_path, "r", "utf-8") as fc: 29 | conf = json.loads(fc.read()) 30 | return conf 31 | 32 | def build_module(): 33 | try: 34 | conf = get_or_create() 35 | except: 36 | print u"config.json.js 文件格式错误" 37 | traceback.print_exc() 38 | if "module" not in conf: 39 | print u"没有 module 在 config.json.js 里" 40 | return 41 | module_path = os.path.join(parent_path, conf["module"]) 42 | if not os.path.isdir(module_path): 43 | print u"找不到对应的 %s 文件夹,config.json.js 里面的 module 值不对?" % module_path 44 | return 45 | install_path = os.path.join(parent_path, conf["module"], "install.sh") 46 | if not os.path.isfile(install_path): 47 | print u"找不到对应的 %s 文件,插件确实 install.sh 文件" 48 | return 49 | print u"生成中..." 50 | t = Template("cd $parent_path && rm -f $module.tar.gz && tar -zcf $module.tar.gz $module") 51 | os.system(t.substitute({"parent_path": parent_path, "module": conf["module"]})) 52 | conf["md5"] = md5sum(os.path.join(parent_path, conf["module"] + ".tar.gz")) 53 | conf_path = os.path.join(parent_path, "config.json.js") 54 | with codecs.open(conf_path, "w", "utf-8") as fw: 55 | json.dump(conf, fw, sort_keys = True, indent = 4, ensure_ascii=False, encoding='utf8') 56 | print u"生成完成", conf["module"] + ".tar.gz" 57 | hook_path = os.path.join(parent_path, "backup.sh") 58 | if os.path.isfile(hook_path): 59 | os.system(hook_path) 60 | 61 | build_module() 62 | -------------------------------------------------------------------------------- /config.json.js: -------------------------------------------------------------------------------- 1 | { 2 | "build_date": "2017-10-15_15:11:43", 3 | "description": "ss-server", 4 | "home_url": "Module_ssserver.asp", 5 | "md5": "a58a6e8255a9c9e486f92e36944de10c", 6 | "module": "ssserver", 7 | "title": "ss-server", 8 | "version": "2.1" 9 | } -------------------------------------------------------------------------------- /history/1.5/ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/history/1.5/ssserver.tar.gz -------------------------------------------------------------------------------- /history/1.6/ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/history/1.6/ssserver.tar.gz -------------------------------------------------------------------------------- /history/1.7/ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/history/1.7/ssserver.tar.gz -------------------------------------------------------------------------------- /history/1.8/ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/history/1.8/ssserver.tar.gz -------------------------------------------------------------------------------- /history/1.9/ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/history/1.9/ssserver.tar.gz -------------------------------------------------------------------------------- /history/2.0/ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/history/2.0/ssserver.tar.gz -------------------------------------------------------------------------------- /history/2.1/ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/history/2.1/ssserver.tar.gz -------------------------------------------------------------------------------- /history/version: -------------------------------------------------------------------------------- 1 | 1.5 347e4747437de8204710fb685e49c78d 2 | 1.6 3fe9392295eaae17300f504f22388621 3 | 1.7 e62840e68bae9f80ac1a4db381c4a810 4 | 1.8 eb54d28e02b7a66995f036a507eb64b9 5 | 1.9 d03e1f5214c1673fb4a31b331bb14a53 6 | 2.0 f985af51db7150c9af62b6489eead480 7 | 2.1 a58a6e8255a9c9e486f92e36944de10c 8 | -------------------------------------------------------------------------------- /ssserver.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/ssserver.tar.gz -------------------------------------------------------------------------------- /ssserver/bin/obfs-server: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/ssserver/bin/obfs-server -------------------------------------------------------------------------------- /ssserver/bin/ss-server: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/ssserver/bin/ss-server -------------------------------------------------------------------------------- /ssserver/install.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | cd /tmp 3 | cp -rf /tmp/ssserver/bin/* /koolshare/bin 4 | cp -rf /tmp/ssserver/ssserver /koolshare/ 5 | cp -rf /tmp/ssserver/scripts/* /koolshare/scripts/ 6 | cp -rf /tmp/ssserver/webs/* /koolshare/webs/ 7 | cp -rf /tmp/ssserver/res/* /koolshare/res/ 8 | if [ ! -L "/koolshare/init.d/S10Softcenter.sh" ]; then 9 | ln -sf /koolshare/ssserver/ssserver.sh /koolshare/init.d/S66ssserver.sh 10 | fi 11 | 12 | cd / 13 | rm -rf /tmp/ssserver* >/dev/null 2>&1 14 | 15 | 16 | chmod 755 /koolshare/bin/ss-server 17 | chmod 755 /koolshare/ssserver/* 18 | chmod 755 /koolshare/bin/* 19 | chmod 755 /koolshare/init.d/* 20 | chmod 755 /koolshare/scripts/* 21 | 22 | -------------------------------------------------------------------------------- /ssserver/res/icon-ssserver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koolshare/merlin-ssserver/ade35cf2bd55787bac2bcb70d473761dfb428be4/ssserver/res/icon-ssserver.png -------------------------------------------------------------------------------- /ssserver/scripts/ssserver_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | eval `dbus export ssserver` 4 | 5 | if [ "$ssserver_enable" == "1" ];then 6 | sh /koolshare/ssserver/ssserver.sh restart 7 | else 8 | sh /koolshare/ssserver/ssserver.sh stop 9 | fi 10 | -------------------------------------------------------------------------------- /ssserver/ssserver/ssserver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ====================================变量定义==================================== 4 | # 版本号定义 5 | version="1.8" 6 | # 引用环境变量等 7 | source /koolshare/scripts/base.sh 8 | 9 | # 导入skipd数据 10 | eval `dbus export ssserver` 11 | 12 | # kill first 13 | stop_ssserver(){ 14 | killall ss-server 15 | killall obfs-server 16 | } 17 | 18 | # start ssserver 19 | start_ssserver(){ 20 | mkdir -p /jffs/ss/ssserver 21 | 22 | [ $ssserver_udp -ne 1 ] && ARG_UDP="" || ARG_UDP="-u"; 23 | if [ "$ssserver_obfs" == "http" ];then 24 | ARG_OBFS="--plugin obfs-server --plugin-opts obfs=http" 25 | elif [ "$ssserver_obfs" == "tls" ];then 26 | ARG_OBFS="--plugin obfs-server --plugin-opts obfs=tls" 27 | else 28 | ARG_OBFS="" 29 | fi 30 | 31 | #ss-server -c /koolshare/ssserver/ss.json $ARG_UDP $ARG_OBFS -f /tmp/ssserver.pid 32 | ss-server -s 0.0.0.0 -p $ssserver_port -k $ssserver_password -m $ssserver_method -t $ssserver_time $ARG_UDP -f /tmp/ssserver.pid $ARG_OBFS 33 | } 34 | 35 | open_port(){ 36 | iptables -t filter -I INPUT -p tcp --dport $ssserver_port -j ACCEPT >/dev/null 2>&1 37 | iptables -t filter -I INPUT -p udp --dport $ssserver_port -j ACCEPT >/dev/null 2>&1 38 | } 39 | 40 | close_port(){ 41 | iptables -t filter -D INPUT -p tcp --dport $ssserver_port -j ACCEPT >/dev/null 2>&1 42 | iptables -t filter -D INPUT -p udp --dport $ssserver_port -j ACCEPT >/dev/null 2>&1 43 | } 44 | 45 | write_nat_start(){ 46 | echo 添加nat-start触发事件... 47 | dbus set __event__onnatstart_ssserver="/koolshare/ssserver/ssserver.sh" 48 | } 49 | 50 | remove_nat_start(){ 51 | echo 删除nat-start触发... 52 | dbus remove __event__onnatstart_koolproxy 53 | } 54 | 55 | write_output(){ 56 | ss_enable=`dbus get ss_basic_enable` 57 | if [ "$ssserver_use_ss" == "1" ] && [ "$ss_enable" == "1" ];then 58 | if [ ! -L "/jffs/configs/dnsmasq.d/gfwlist.conf" ];then 59 | echo link gfwlist.conf 60 | ln -sf /koolshare/ss/rules/gfwlist.conf /jffs/configs/dnsmasq.d/gfwlist.conf 61 | fi 62 | service restart_dnsmasq 63 | iptables -t nat -A OUTPUT -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-ports 3333 64 | fi 65 | } 66 | 67 | del_output(){ 68 | iptables -t nat -D OUTPUT -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-ports 3333 >/dev/null 2>&1 69 | } 70 | 71 | case $ACTION in 72 | start) 73 | if [ "$ssserver_enable" == "1" ];then 74 | logger "[软件中心]: 启动ss-server!" 75 | start_ssserver 76 | open_port 77 | write_output 78 | else 79 | logger "[软件中心]: ss-server未设置开机启动,跳过!" 80 | fi 81 | ;; 82 | stop | kill ) 83 | close_port 84 | stop_ssserver 85 | remove_nat_start 86 | del_output 87 | ;; 88 | restart) 89 | close_port 90 | stop_ssserver 91 | del_output 92 | sleep 1 93 | start_ssserver 94 | open_port 95 | write_nat_start 96 | write_output 97 | ;; 98 | *) 99 | close_port 100 | del_output 101 | open_port 102 | write_output 103 | esac 104 | -------------------------------------------------------------------------------- /ssserver/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf /koolshare/bin/ssserver 4 | rm -rf /koolshare/ssserver 5 | rm -rf /koolshare/init.d/koolshare/init.d/S66ssserver.sh 6 | rm -rf /koolshare/scripts/ssserver_config.sh 7 | rm -rf /koolshare/webs/Module_ssserver.asp 8 | rm -rf /koolshare/scripts/uninstall_ssserver.sh 9 | 10 | -------------------------------------------------------------------------------- /ssserver/webs/Module_ssserver.asp: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |