luci-app-ssr-python-pro-server: fully convert to python3

This commit is contained in:
CN_SZTL 2020-05-04 16:38:55 +08:00
parent bf52a118f3
commit 62ff1b2a52
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
56 changed files with 95 additions and 95 deletions

View File

@ -7,7 +7,7 @@ local ipkg = require "luci.model.ipkg"
<script type="text/javascript">//<![CDATA[
var ssr_python_status = document.getElementsByClassName('ssr_python_status')[0];
ssr_python_status.setAttribute("style","font-weight:bold;");
<% if ipkg.installed("python") then %>
<% if ipkg.installed("python3") then %>
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "vpn", "ssr_python_pro_server", "status")%>', null,
function(x, result)
{
@ -17,7 +17,7 @@ local ipkg = require "luci.model.ipkg"
)
<% else %>
ssr_python_status.setAttribute("color","red");
ssr_python_status.innerHTML = '<%=translate("NOT INSTALLED")%><br><%=translate("please Install the python")%><br>opkg update && opkg install python</font></b>';
ssr_python_status.innerHTML = '<%=translate("NOT INSTALLED")%><br><%=translate("please Install the python3")%><br>opkg update && opkg install python3</font></b>';
<% end %>
function ssr_python_get_total_traffic(section,dom) {

View File

@ -139,8 +139,8 @@ msgstr "状态"
msgid "Current Condition"
msgstr "当前状态"
msgid "please Install the python"
msgstr "请安装python环境"
msgid "please Install the python3"
msgstr "请安装python3环境"
msgid "NOT INSTALLED"
msgstr "未安装"
@ -149,4 +149,4 @@ msgid "NOT RUNNING"
msgstr "未运行"
msgid "RUNNING"
msgstr "运行中"
msgstr "运行中"

View File

@ -52,7 +52,7 @@ set_ssr_python_crontab() {
}
start_ssr_python_server() {
python=/usr/bin/python
python=/usr/bin/python3
lua /usr/lib/lua/luci/model/cbi/ssr_python_pro_server/genssrmudbconfig.lua > /tmp/mudb.json
mv -f /tmp/mudb.json $ssr_python_path/mudb.json
$python $ssr_python_path/server.py >> /var/log/$CONFIG.log 2>&1 &
@ -73,7 +73,7 @@ EOF
stop_ssr_python_server() {
fw3 reload > /dev/null 2>&1
ps -w | grep "/usr/bin/python $ssr_python_path/server.py" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
ps -w | grep "/usr/bin/python3 $ssr_python_path/server.py" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
rm -rf /var/log/$CONFIG.log
set_ssr_python_crontab "stop"
}
@ -96,4 +96,4 @@ stop() {
restart() {
stop
start
}
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2014 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import importloader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import logging

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
def load(name):

View File

@ -13,10 +13,10 @@ fi
if [[ $ip_count == 1 ]]; then
echo "server IP is "${ip_addr}
sed -i "s/SERVER_PUB_ADDR = .\+/SERVER_PUB_ADDR = \'"${ip_addr}"\'/g" userapiconfig.py
user_count=`python mujson_mgr.py -l|grep -c -e "[0-9]"`
user_count=`python3 mujson_mgr.py -l|grep -c -e "[0-9]"`
if [[ $user_count == 0 ]]; then
port=`python -c 'import random;print(random.randint(10000, 65536))'`
python mujson_mgr.py -a -p ${port}
port=`python3 -c 'import random;print(random.randint(10000, 65536))'`
python3 mujson_mgr.py -a -p ${port}
fi
else
echo "unable to detect server IP"

View File

@ -1,7 +1,7 @@
#!/bin/bash
cd `dirname $0`
#python_ver=$(ls /usr/bin|grep -e "^python[23]\.[1-9]\+$"|tail -1)
eval $(ps -ef | grep "[0-9] python server\\.py m" | awk '{print "kill "$2}')
eval $(ps -ef | grep "[0-9] python3 server\\.py m" | awk '{print "kill "$2}')
ulimit -n 512000
nohup python server.py m >> ssserver.log 2>&1 &
nohup python3 server.py m >> ssserver.log 2>&1 &

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import traceback
@ -220,7 +220,7 @@ class MuMgr(object):
def print_server_help():
print('''usage: python mujson_manage.py -a|-d|-e|-c|-l [OPTION]...
print('''usage: python3 mujson_manage.py -a|-d|-e|-c|-l [OPTION]...
Actions:
-a add/edit a user

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import traceback
@ -211,7 +211,7 @@ class MuMgr(object):
def print_server_help():
print('''usage: python mujson_manage.py -a|-d|-e|-c|-l [OPTION]...
print('''usage: python3 mujson_manage.py -a|-d|-e|-c|-l [OPTION]...
Actions:
-a add/edit a user

View File

@ -1,7 +1,7 @@
#!/bin/bash
cd `dirname $0`
#python_ver=$(ls /usr/bin|grep -e "^python[23]\.[1-9]\+$"|tail -1)
eval $(ps -ef | grep "[0-9] python server\\.py m" | awk '{print "kill "$2}')
eval $(ps -ef | grep "[0-9] python3 server\\.py m" | awk '{print "kill "$2}')
ulimit -n 512000
nohup python server.py m>> /dev/null 2>&1 &
nohup python3 server.py m>> /dev/null 2>&1 &

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 breakwall

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2014 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# Copyright 2012-2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2014-2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2013-2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2014 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2014 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2014-2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2012-2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2013-2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2012-2015 clowwindy

View File

@ -1,5 +1,5 @@
#!/bin/bash
cd `dirname $0`
eval $(ps -ef | grep "[0-9] python server\\.py a" | awk '{print "kill "$2}')
eval $(ps -ef | grep "[0-9] python3 server\\.py a" | awk '{print "kill "$2}')
ulimit -n 512000
nohup python server.py a >> ssserver.log 2>&1 &
nohup python3 server.py a >> ssserver.log 2>&1 &

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015-2015 breakwa11
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015-2015 breakwa11
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015-2015 breakwa11
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015-2015 breakwa11
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015-2015 breakwa11
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015-2015 breakwa11
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015-2015 breakwa11
#

View File

@ -198,7 +198,7 @@ class OrderedDict(dict):
'od.__ne__(y) <==> od!=y'
return not self == other
# -- the following methods support python 3.x style dictionary views --
# -- the following methods support python3 3.x style dictionary views --
def viewkeys(self):
"od.viewkeys() -> a set-like object providing a view on od's keys"

View File

@ -1,5 +1,5 @@
#!/bin/bash
cd `dirname $0`
eval $(ps -ef | grep "[0-9] python server\\.py a" | awk '{print "kill "$2}')
eval $(ps -ef | grep "[0-9] python3 server\\.py a" | awk '{print "kill "$2}')
ulimit -n 512000
nohup python server.py a >> /dev/null 2>&1 &
nohup python3 server.py a >> /dev/null 2>&1 &

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/bin/bash
#python_ver=$(ls /usr/bin|grep -e "^python[23]\.[1-9]\+$"|tail -1)
eval $(ps -ef | grep "[0-9] python server\\.py a" | awk '{print "kill "$2}')
eval $(ps -ef | grep "[0-9] python3 server\\.py a" | awk '{print "kill "$2}')

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy

View File

@ -237,4 +237,4 @@ password,method,protocol,protocolparam,obfs,obfsparam)
with open('user-config.json','w') as f:
f.write(user.encode("utf-8"))
print user+"\n"+"请检查输入是否有误,若需要修改请重新执行程序。\
\n启动ssr请在终端切换至shadowsocksr/shadowsocks目录执行python local.py -d start"
\n启动ssr请在终端切换至shadowsocksr/shadowsocks目录执行python3 local.py -d start"

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2017 breakwa11

View File

@ -1,4 +1,4 @@
#!/bin/bash
# python_ver=$(ls /usr/bin|grep -e "^python[23]\.[1-9]\+$"|tail -1)
eval $(ps -ef | grep "[0-9] python server\\.py m" | awk '{print "kill "$2}')
eval $(ps -ef | grep "[0-9] python3 server\\.py m" | awk '{print "kill "$2}')

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -24,47 +24,47 @@ function run_test {
return 0
}
python --version
python3 --version
coverage erase
mkdir tmp
run_test pep8 --ignore=E402 .
run_test pyflakes .
run_test coverage run tests/nose_plugin.py -v
run_test python setup.py sdist
run_test python3 setup.py sdist
run_test tests/test_daemon.sh
run_test python tests/test.py --with-coverage -c tests/aes.json
run_test python tests/test.py --with-coverage -c tests/aes-ctr.json
run_test python tests/test.py --with-coverage -c tests/aes-cfb1.json
run_test python tests/test.py --with-coverage -c tests/aes-cfb8.json
run_test python tests/test.py --with-coverage -c tests/rc4-md5.json
run_test python tests/test.py --with-coverage -c tests/salsa20.json
run_test python tests/test.py --with-coverage -c tests/chacha20.json
run_test python tests/test.py --with-coverage -c tests/table.json
run_test python tests/test.py --with-coverage -c tests/server-multi-ports.json
run_test python tests/test.py --with-coverage -s tests/aes.json -c tests/client-multi-server-ip.json
run_test python tests/test.py --with-coverage -s tests/server-multi-passwd.json -c tests/server-multi-passwd-client-side.json
run_test python tests/test.py --with-coverage -c tests/workers.json
run_test python tests/test.py --with-coverage -s tests/ipv6.json -c tests/ipv6-client-side.json
run_test python tests/test.py --with-coverage -b "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -q" -a "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -vv"
run_test python tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --workers 1" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -qq -b 127.0.0.1"
run_test python tests/test.py --with-coverage --should-fail --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=127.0.0.1,::1,8.8.8.8" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
run_test python3 tests/test.py --with-coverage -c tests/aes.json
run_test python3 tests/test.py --with-coverage -c tests/aes-ctr.json
run_test python3 tests/test.py --with-coverage -c tests/aes-cfb1.json
run_test python3 tests/test.py --with-coverage -c tests/aes-cfb8.json
run_test python3 tests/test.py --with-coverage -c tests/rc4-md5.json
run_test python3 tests/test.py --with-coverage -c tests/salsa20.json
run_test python3 tests/test.py --with-coverage -c tests/chacha20.json
run_test python3 tests/test.py --with-coverage -c tests/table.json
run_test python3 tests/test.py --with-coverage -c tests/server-multi-ports.json
run_test python3 tests/test.py --with-coverage -s tests/aes.json -c tests/client-multi-server-ip.json
run_test python3 tests/test.py --with-coverage -s tests/server-multi-passwd.json -c tests/server-multi-passwd-client-side.json
run_test python3 tests/test.py --with-coverage -c tests/workers.json
run_test python3 tests/test.py --with-coverage -s tests/ipv6.json -c tests/ipv6-client-side.json
run_test python3 tests/test.py --with-coverage -b "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -q" -a "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -vv"
run_test python3 tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --workers 1" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -qq -b 127.0.0.1"
run_test python3 tests/test.py --with-coverage --should-fail --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=127.0.0.1,::1,8.8.8.8" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
# test if DNS works
run_test python tests/test.py --with-coverage -c tests/aes.json --url="https://clients1.google.com/generate_204"
run_test python3 tests/test.py --with-coverage -c tests/aes.json --url="https://clients1.google.com/generate_204"
# test localhost is in the forbidden list by default
run_test python tests/test.py --with-coverage --should-fail --tcp-only --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
run_test python3 tests/test.py --with-coverage --should-fail --tcp-only --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
# test localhost is available when forbidden list is empty
run_test python tests/test.py --with-coverage --tcp-only --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
run_test python3 tests/test.py --with-coverage --tcp-only --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
if [ -f /proc/sys/net/ipv4/tcp_fastopen ] ; then
if [ 3 -eq `cat /proc/sys/net/ipv4/tcp_fastopen` ] ; then
# we have to run it twice:
# the first time there's no syn cookie
# the second time there is syn cookie
run_test python tests/test.py --with-coverage -c tests/fastopen.json
run_test python tests/test.py --with-coverage -c tests/fastopen.json
run_test python3 tests/test.py --with-coverage -c tests/fastopen.json
run_test python3 tests/test.py --with-coverage -c tests/fastopen.json
fi
fi

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2015 clowwindy
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy
@ -26,7 +26,7 @@ import time
import argparse
from subprocess import Popen, PIPE
python = ['python']
python3 = ['python']
default_url = 'http://localhost/'
@ -44,10 +44,10 @@ parser.add_argument('--dns', type=str, default='8.8.8.8')
config = parser.parse_args()
if config.with_coverage:
python = ['coverage', 'run', '-p']
python3 = ['coverage', 'run', '-p']
client_args = python + ['shadowsocks/local.py', '-v']
server_args = python + ['shadowsocks/server.py', '-v']
client_args = python3 + ['shadowsocks/local.py', '-v']
server_args = python3 + ['shadowsocks/server.py', '-v']
if config.client_conf:
client_args.extend(['-c', config.client_conf])

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
import socket
import socks

View File

@ -12,7 +12,7 @@ SERVER=$!
sleep 3
python tests/test_udp_src.py
python3 tests/test_udp_src.py
r=$?
kill -s SIGINT $LOCAL

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2015 clowwindy