mirror of https://github.com/midoks/mdserver-web
pull/109/head
parent
b763374bf0
commit
c2c231e07f
@ -1,21 +0,0 @@ |
||||
MIT License |
||||
|
||||
Copyright (c) 2019 Mr Chen |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
Before Width: | Height: | Size: 1.0 KiB |
@ -1,20 +0,0 @@ |
||||
<div class="bt-form"> |
||||
<div class="bt-w-main"> |
||||
<div class="bt-w-menu"> |
||||
<p class="bgw" onclick="pluginService('socket5');">服务</p> |
||||
<p onclick="pluginInitD('socket5');">自启动</p> |
||||
<p onclick="pluginConfig('socket5',null, 'conf');">配置</p> |
||||
<p onclick="pluginConfig('socket5',null, 'conf_pwd');">用户</p> |
||||
<p onclick="pluginConfig('socket5',null, 'conf_port');">端口</p> |
||||
<p onclick="readme();">说明</p> |
||||
</div> |
||||
<div class="bt-w-con pd15"> |
||||
<div class="soft-man-con"></div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<script type="text/javascript"> |
||||
$.getScript( "/plugins/file?name=socket5&f=js/socket5.js", function(){ |
||||
pluginService('socket5'); |
||||
}); |
||||
</script> |
@ -1,207 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
import sys |
||||
import io |
||||
import os |
||||
import time |
||||
import shutil |
||||
|
||||
sys.path.append(os.getcwd() + "/class/core") |
||||
import mw |
||||
|
||||
app_debug = False |
||||
if mw.isAppleSystem(): |
||||
app_debug = True |
||||
|
||||
|
||||
def getPluginName(): |
||||
return 'socket5' |
||||
|
||||
|
||||
def getPluginDir(): |
||||
return mw.getPluginDir() + '/' + getPluginName() |
||||
|
||||
|
||||
def getServerDir(): |
||||
return mw.getServerDir() + '/' + getPluginName() |
||||
|
||||
|
||||
def getInitDFile(): |
||||
if app_debug: |
||||
return '/tmp/' + getPluginName() |
||||
return '/etc/init.d/ss5' |
||||
|
||||
|
||||
def initDreplace(): |
||||
return getPluginDir() + '/init.d/ss5' |
||||
|
||||
|
||||
def getArgs(): |
||||
args = sys.argv[2:] |
||||
tmp = {} |
||||
args_len = len(args) |
||||
|
||||
if args_len == 1: |
||||
t = args[0].strip('{').strip('}') |
||||
t = t.split(':') |
||||
tmp[t[0]] = t[1] |
||||
elif args_len > 1: |
||||
for i in range(len(args)): |
||||
t = args[i].split(':') |
||||
tmp[t[0]] = t[1] |
||||
|
||||
return tmp |
||||
|
||||
|
||||
def checkArgs(data, ck=[]): |
||||
for i in range(len(ck)): |
||||
if not ck[i] in data: |
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) |
||||
return (True, mw.returnJson(True, 'ok')) |
||||
|
||||
|
||||
def status(): |
||||
cmd = "ps -ef|grep ss5 |grep -v grep | grep -v python | awk '{print $2}'" |
||||
data = mw.execShell(cmd) |
||||
if data[0] == '': |
||||
return 'stop' |
||||
return 'start' |
||||
|
||||
|
||||
def initConf(): |
||||
ss5_conf = getServerDir() + '/ss5.conf' |
||||
if not os.path.exists(ss5_conf): |
||||
tmp = getPluginDir() + '/tmp/ss5.conf' |
||||
if not os.path.exists(tmp): |
||||
mw.execShell('cp -rf ' + tmp + ' /etc/opt/ss5') |
||||
mw.execShell('cp -rf ' + tmp + ' ' + getServerDir()) |
||||
|
||||
init_file = '/etc/init.d/ss5' |
||||
if os.path.exists(init_file): |
||||
mw.execShell('chmod +x ' + init_file) |
||||
|
||||
ss5_pwd = getServerDir() + '/ss5.passwd' |
||||
if not os.path.exists(ss5_pwd): |
||||
tmp = getPluginDir() + '/tmp/ss5.passwd' |
||||
|
||||
if not os.path.exists(tmp): |
||||
mw.execShell('cp -rf ' + tmp + ' /etc/opt/ss5') |
||||
mw.execShell('cp -rf ' + tmp + ' ' + getServerDir()) |
||||
|
||||
|
||||
def start(): |
||||
initConf() |
||||
|
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
data = mw.execShell('service ss5 start') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return data[1] |
||||
|
||||
|
||||
def stop(): |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
data = mw.execShell('service ss5 stop') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return data[1] |
||||
|
||||
|
||||
def restart(): |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
data = mw.execShell('service ss5 restart') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return data[1] |
||||
|
||||
|
||||
def reload(): |
||||
data = mw.execShell('service ss5 reload') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return data[1] |
||||
|
||||
|
||||
def getPathFile(): |
||||
if mw.isAppleSystem(): |
||||
return getServerDir() + '/ss5.conf' |
||||
return '/etc/opt/ss5/ss5.conf' |
||||
|
||||
|
||||
def getPathFilePwd(): |
||||
if mw.isAppleSystem(): |
||||
return getServerDir() + '/ss5.passwd' |
||||
return '/etc/opt/ss5/ss5.passwd' |
||||
|
||||
|
||||
def getPathFilePort(): |
||||
return '/etc/sysconfig/ss5' |
||||
|
||||
|
||||
def initdStatus(): |
||||
if not app_debug: |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
initd_bin = getInitDFile() |
||||
if os.path.exists(initd_bin): |
||||
return 'ok' |
||||
return 'fail' |
||||
|
||||
|
||||
def initdInstall(): |
||||
import shutil |
||||
if not app_debug: |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
source_bin = initDreplace() |
||||
initd_bin = getInitDFile() |
||||
shutil.copyfile(source_bin, initd_bin) |
||||
mw.execShell('chmod +x ' + initd_bin) |
||||
mw.execShell('chkconfig --add ' + getPluginName()) |
||||
return 'ok' |
||||
|
||||
|
||||
def initdUinstall(): |
||||
if not app_debug: |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
mw.execShell('chkconfig --del ' + getPluginName()) |
||||
initd_bin = getInitDFile() |
||||
os.remove(initd_bin) |
||||
return 'ok' |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
func = sys.argv[1] |
||||
if func == 'status': |
||||
print(status()) |
||||
elif func == 'start': |
||||
print(start()) |
||||
elif func == 'stop': |
||||
print(stop()) |
||||
elif func == 'restart': |
||||
print(restart()) |
||||
elif func == 'reload': |
||||
print(reload()) |
||||
elif func == 'conf': |
||||
print(getPathFile()) |
||||
elif func == 'conf_pwd': |
||||
print(getPathFilePwd()) |
||||
elif func == 'conf_port': |
||||
print(getPathFilePort()) |
||||
elif func == 'initd_status': |
||||
print(initdStatus()) |
||||
elif func == 'initd_install': |
||||
print(initdInstall()) |
||||
elif func == 'initd_uninstall': |
||||
print(initdUinstall()) |
||||
else: |
||||
print('error') |
@ -1,14 +0,0 @@ |
||||
{ |
||||
"title":"socket5", |
||||
"tip":"soft", |
||||
"name":"socket5", |
||||
"type":"运行环境", |
||||
"ps":"socket5", |
||||
"versions":"1.0", |
||||
"shell":"install.sh", |
||||
"checks":"server/socket5", |
||||
"author":"midoks", |
||||
"home":"https://github.com/teddysun/across/blob/master/socket5.sh", |
||||
"date":"2021-01-29", |
||||
"pid": "5" |
||||
} |
@ -1,83 +0,0 @@ |
||||
#!/bin/sh |
||||
# |
||||
# chkconfig: 345 20 80 |
||||
# description: This script takes care of starting \ |
||||
# and stopping ss5 |
||||
# |
||||
|
||||
OS=`uname -s` |
||||
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then |
||||
|
||||
# Source function library. |
||||
. /etc/rc.d/init.d/functions |
||||
|
||||
# Source networking configuration. |
||||
. /etc/sysconfig/network |
||||
|
||||
# Check that networking is up. |
||||
[ ${NETWORKING} = "no" ] && exit 0 |
||||
|
||||
[ -f /usr/sbin/ss5 ] || exit 0 |
||||
fi |
||||
|
||||
# Test custom variables |
||||
test -f /etc/sysconfig/ss5 && . /etc/sysconfig/ss5 |
||||
|
||||
# See how we were called. |
||||
case "$1" in |
||||
start) |
||||
# Start daemon. |
||||
echo -n "Starting ss5... " |
||||
if [ $OS = "Linux" ]; then |
||||
daemon /usr/sbin/ss5 -t $SS5_OPTS |
||||
touch /var/lock/subsys/ss5 |
||||
else |
||||
if [ $OS = "SunOS" ]; then |
||||
/usr/sbin/ss5 -t |
||||
touch /var/lock/subsys/ss5 |
||||
else |
||||
/usr/local/sbin/ss5 -t |
||||
fi |
||||
fi |
||||
echo "done" |
||||
;; |
||||
stop) |
||||
# Stop daemon. |
||||
echo "Shutting down ss5... " |
||||
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then |
||||
killproc ss5 |
||||
rm -f /var/lock/subsys/ss5 |
||||
else |
||||
killall ss5 |
||||
fi |
||||
rm -f /var/run/ss5/ss5.pid |
||||
echo "done" |
||||
;; |
||||
reload) |
||||
# Reload configuration |
||||
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then |
||||
echo -n "Reloading ss5... " |
||||
killproc ss5 -1 |
||||
else |
||||
pkill -HUP ss5 |
||||
fi |
||||
echo "done reload" |
||||
;; |
||||
restart) |
||||
# Restart daemon |
||||
echo -n "Restarting ss5... " |
||||
$0 stop |
||||
$0 start |
||||
;; |
||||
status) |
||||
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then |
||||
status ss5 |
||||
fi |
||||
;; |
||||
*) |
||||
echo "Usage: ss5 {start|stop|status|restart|reload}" |
||||
exit 1 |
||||
;; |
||||
esac |
||||
|
||||
exit 0 |
@ -1,49 +0,0 @@ |
||||
#!/bin/bash |
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||
export PATH |
||||
|
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl |
||||
SYSOS=`uname` |
||||
|
||||
Install_socket5() |
||||
{ |
||||
yum -y install gcc automake make pam-devel openldap-devel cyrus-sasl-devel |
||||
|
||||
isStart="" |
||||
echo '正在安装脚本文件...' > $install_tmp |
||||
mkdir -p $serverPath/source |
||||
mkdir -p $serverPath/socket5 |
||||
|
||||
if [ ! -f $serverPath/source/ss5-3.8.9-8.tar.gz ];then |
||||
wget -O $serverPath/source/ss5-3.8.9-8.tar.gz http://downloads.sourceforge.net/project/ss5/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz |
||||
fi |
||||
echo '1.0' > $serverPath/socket5/version.pl |
||||
|
||||
cd $serverPath/source && tar -xzvf ss5-3.8.9-8.tar.gz |
||||
cd $serverPath/source/ss5-3.8.9 && ./configure && make && make install |
||||
|
||||
echo 'install complete' > $install_tmp |
||||
} |
||||
|
||||
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 |
||||
} |
||||
|
||||
action=$1 |
||||
if [ "${1}" == 'install' ];then |
||||
Install_socket5 |
||||
else |
||||
Uninstall_socket5 |
||||
fi |
@ -1,57 +0,0 @@ |
||||
function str2Obj(str){ |
||||
var data = {}; |
||||
kv = str.split('&'); |
||||
for(i in kv){ |
||||
v = kv[i].split('='); |
||||
data[v[0]] = v[1]; |
||||
} |
||||
return data; |
||||
} |
||||
|
||||
function lpPost(method,args,callback, title){ |
||||
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){ |
||||
_args = JSON.stringify(str2Obj(args)); |
||||
} else { |
||||
_args = JSON.stringify(args); |
||||
} |
||||
|
||||
var _title = '正在获取...'; |
||||
if (typeof(title) != 'undefined'){ |
||||
_title = title; |
||||
} |
||||
|
||||
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 }); |
||||
$.post('/plugins/run', {name:'l2tp', func:method, args:_args}, function(data) { |
||||
layer.close(loadT); |
||||
if (!data.status){ |
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); |
||||
return; |
||||
} |
||||
|
||||
if(typeof(callback) == 'function'){ |
||||
callback(data); |
||||
} |
||||
},'json');
|
||||
} |
||||
|
||||
function lpAsyncPost(method,args){ |
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){ |
||||
_args = JSON.stringify(str2Obj(args)); |
||||
} else { |
||||
_args = JSON.stringify(args); |
||||
} |
||||
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); |
||||
return syncPost('/plugins/run', {name:'l2tp', func:method, args:_args}); |
||||
} |
||||
|
||||
function readme(){ |
||||
var readme = '<ul class="help-info-text c7">'; |
||||
readme += '<li>默认需开放端口:UDP:1080</li>'; |
||||
readme += '<li><a href="https://github.com/midoks/mdserver-web/wiki/%E6%8F%92%E4%BB%B6%E7%AE%A1%E7%90%86%5BSOCK5%5D">参考</a></li>'; |
||||
readme += '</ul>'; |
||||
$('.soft-man-con').html(readme);
|
||||
} |
@ -1,8 +0,0 @@ |
||||
# 无用户配置 |
||||
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 - - - - - |
@ -1 +0,0 @@ |
||||
test test |
Loading…
Reference in new issue