diff --git a/plugins/socket5/index.py b/plugins/socket5/index.py index 3e896f45b..b67c6aabd 100755 --- a/plugins/socket5/index.py +++ b/plugins/socket5/index.py @@ -51,7 +51,7 @@ def checkArgs(data, ck=[]): def status(): - cmd = "ps -ef|grep xl2tpd |grep -v grep | grep -v python | awk '{print $2}'" + cmd = "ps -ef|grep ss5 |grep -v grep | grep -v python | awk '{print $2}'" data = mw.execShell(cmd) if data[0] == '': return 'stop' @@ -59,15 +59,15 @@ def status(): def initConf(): - l2tp_cs = getServerDir() + '/chap-secrets' - if not os.path.exists(l2tp_cs): + ss5_conf = getServerDir() + '/ss5.conf' + if not os.path.exists(ss5_conf): mw.execShell('cp -rf ' + getPluginDir() + - '/tmp/chap-secrets' + ' ' + getServerDir()) + '/tmp/ss5.conf' + ' ' + getServerDir()) - l2tp_is = getServerDir() + '/ipsec.secrets' - if not os.path.exists(l2tp_is): + ss5_pwd = getServerDir() + '/ss5.passwd' + if not os.path.exists(ss5_pwd): mw.execShell('cp -rf ' + getPluginDir() + - '/tmp/ipsec.secrets' + ' ' + getServerDir()) + '/tmp/ss5.passwd' + ' ' + getServerDir()) def start(): @@ -76,7 +76,7 @@ def start(): if mw.isAppleSystem(): return "Apple Computer does not support" - data = mw.execShell('service xl2tpd start') + data = mw.execShell('service ss5 start') if data[0] == '': return 'ok' return data[1] @@ -86,7 +86,7 @@ def stop(): if mw.isAppleSystem(): return "Apple Computer does not support" - data = mw.execShell('service xl2tpd stop') + data = mw.execShell('service ss5 stop') if data[0] == '': return 'ok' return data[1] @@ -96,14 +96,14 @@ def restart(): if mw.isAppleSystem(): return "Apple Computer does not support" - data = mw.execShell('service xl2tpd restart') + data = mw.execShell('service ss5 restart') if data[0] == '': return 'ok' return data[1] def reload(): - data = mw.execShell('service xl2tpd reload') + data = mw.execShell('service ss5 reload') if data[0] == '': return 'ok' return data[1] @@ -121,90 +121,6 @@ def getPathFilePwd(): return '/etc/opt/ss5/ss5.passwd' -def getUserList(): - import re - path = getPathFile() - if not os.path.exists(path): - return mw.returnJson(False, '密码配置文件不存在!') - conf = mw.readFile(path) - - conf = re.sub('#(.*)\n', '', conf) - - if conf.strip() == '': - return mw.returnJson(True, 'ok', []) - - ulist = conf.strip().split('\n') - - user = [] - for line in ulist: - line_info = {} - line = re.match(r'(\w*)\s*(\w*)\s*(\w*)\s*(.*)', - line.strip(), re.M | re.I).groups() - line_info['user'] = line[0] - line_info['pwd'] = line[2] - line_info['type'] = line[1] - line_info['ip'] = line[3] - user.append(line_info) - - return mw.returnJson(True, 'ok', user) - - -def addUser(): - if mw.isAppleSystem(): - return mw.returnJson(False, "Apple Computer does not support") - - args = getArgs() - data = checkArgs(args, ['username']) - if not data[0]: - return data[1] - ret = mw.execShell('echo ' + args['username'] + '|l2tp -a') - if ret[1] == '': - return mw.returnJson(True, '添加成功!:' + ret[0]) - return mw.returnJson(False, '添加失败:' + ret[0]) - - -def delUser(): - if mw.isAppleSystem(): - return mw.returnJson(False, "Apple Computer does not support") - - args = getArgs() - data = checkArgs(args, ['username']) - if not data[0]: - return data[1] - - ret = mw.execShell('echo ' + args['username'] + '|l2tp -d') - if ret[1] == '': - return mw.returnJson(True, '删除成功!:' + ret[0]) - return mw.returnJson(False, '删除失败:' + ret[0]) - - -def modUser(): - - args = getArgs() - data = checkArgs(args, ['username', 'password']) - if not data[0]: - return data[1] - - path = getPathFile() - username = args['username'] - password = args['password'] - - # sed -i "/^\<${user}\>/d" /etc/ppp/chap-secrets - # echo "${user} l2tpd ${pass} *" >> /etc/ppp/chap-secrets - - if mw.isAppleSystem(): - mw.execShell("sed -i .bak '/^\(" + username + "\)/d' " + path) - else: - mw.execShell("sed -i '/^\(" + username + "\)/d' " + path) - # print 'echo "' + username + " l2tpd " + password + " *\" >>" - # + path - ret = mw.execShell("echo \"" + username + - " l2tpd " + password + " *\" >>" + path) - if ret[1] == '': - return mw.returnJson(True, '修改成功!') - return mw.returnJson(False, '修改失败') - - if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -219,15 +135,7 @@ if __name__ == "__main__": print reload() elif func == 'conf': print getPathFile() - elif func == 'conf_psk': + elif func == 'conf_pwd': print getPathFilePwd() - elif func == 'user_list': - print getUserList() - elif func == 'add_user': - print addUser() - elif func == 'del_user': - print delUser() - elif func == 'mod_user': - print modUser() else: print 'error' diff --git a/plugins/socket5/install.sh b/plugins/socket5/install.sh index 2f2a97592..a2d35cf4f 100755 --- a/plugins/socket5/install.sh +++ b/plugins/socket5/install.sh @@ -36,6 +36,8 @@ Uninstall_socket5() { rm -rf $serverPath/socket5 rm -rf /usr/sbin/ss5 + service ss5 stop + rm -rf /etc/init.d/ss5 echo "Uninstall completed" > $install_tmp } diff --git a/plugins/socket5/tmp/chap-secrets b/plugins/socket5/tmp/chap-secrets deleted file mode 100644 index 20721096a..000000000 --- a/plugins/socket5/tmp/chap-secrets +++ /dev/null @@ -1,3 +0,0 @@ -# Secrets for authentication using CHAP -# client server secret IP addresses -demo demo demo * diff --git a/plugins/socket5/tmp/ipsec.secrets b/plugins/socket5/tmp/ipsec.secrets deleted file mode 100644 index e186ee087..000000000 --- a/plugins/socket5/tmp/ipsec.secrets +++ /dev/null @@ -1 +0,0 @@ -%any %any : PSK "midoks" diff --git a/plugins/socket5/tmp/ss5.conf b/plugins/socket5/tmp/ss5.conf new file mode 100755 index 000000000..8bda3c201 --- /dev/null +++ b/plugins/socket5/tmp/ss5.conf @@ -0,0 +1,8 @@ +# 无用户配置 +auth 0.0.0.0/0 - - +permit - 0.0.0.0/0 - 0.0.0.0/0 - - - - - + + +# 用户配置 +#auth 0.0.0.0/0 - u +#permit - 0.0.0.0/0 - 0.0.0.0/0 - - - - - \ No newline at end of file diff --git a/plugins/socket5/tmp/ss5.passwd.conf b/plugins/socket5/tmp/ss5.passwd.conf new file mode 100755 index 000000000..4be3c4508 --- /dev/null +++ b/plugins/socket5/tmp/ss5.passwd.conf @@ -0,0 +1 @@ +test test \ No newline at end of file