diff --git a/plugins/l2tp/index.html b/plugins/l2tp/index.html index 834706386..63ff7faa1 100755 --- a/plugins/l2tp/index.html +++ b/plugins/l2tp/index.html @@ -1,11 +1,8 @@
-

服务

-

项目列表

-

Node版本

-

模版管理

-

日志管理

+

服务

+

用户列表

@@ -13,4 +10,7 @@
\ No newline at end of file diff --git a/plugins/l2tp/index.py b/plugins/l2tp/index.py index 461db59c8..bf292da61 100755 --- a/plugins/l2tp/index.py +++ b/plugins/l2tp/index.py @@ -15,7 +15,7 @@ if public.isAppleSystem(): def getPluginName(): - return 'pureftp' + return 'l2tp' def getPluginDir(): @@ -179,261 +179,6 @@ def initdUinstall(): return 'ok' -def pftpDB(): - file = getServerDir() + '/ftps.db' - if not os.path.exists(file): - conn = public.M('ftps').dbPos(getServerDir(), 'ftps') - csql = public.readFile(getPluginDir() + '/conf/ftps.sql') - csql_list = csql.split(';') - for index in range(len(csql_list)): - conn.execute(csql_list[index], ()) - else: - conn = public.M('ftps').dbPos(getServerDir(), 'ftps') - return conn - - -def pftpUser(): - if public.isAppleSystem(): - user = public.execShell( - "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() - return user - return 'www' - - -def pftpAdd(username, password, path): - user = pftpUser() - - if not os.path.exists(path): - os.makedirs(path) - if public.isAppleSystem(): - os.system('chown ' + user + '.staff ' + path) - else: - os.system('chown www.www ' + path) - - cmd = getServerDir() + '/bin/pure-pw useradd ' + username + ' -u ' + user + ' -d ' + \ - path + '< 65535: - return '端口范围不正确!' - file = file = getServerDir() + '/etc/pure-ftpd.conf' - conf = public.readFile(file) - rep = u"\n#?\s*Bind\s+[0-9]+\.[0-9]+\.[0-9]+\.+[0-9]+,([0-9]+)" - # preg_match(rep,conf,tmp) - conf = re.sub( - rep, "\nBind 0.0.0.0," + port, conf) - public.writeFile(file, conf) - restart() - return 'ok' - except Exception as ex: - return str(ex) - - -def stopPort(): - args = getArgs() - if not 'id' in args: - return 'id missing' - - if not 'username' in args: - return 'username missing' - - if not 'status' in args: - return 'status missing' - - data = pftpStop(args['username']) - pftpReload() - conn = pftpDB() - conn.where('id=?', (int(args['id']),)).save( - 'status', (args['status'],)) - - if data[1] == '': - return 'ok' - return data[0] - - -def startPort(): - args = getArgs() - if not 'id' in args: - return 'id missing' - - if not 'username' in args: - return 'username missing' - - if not 'status' in args: - return 'status missing' - - data = pftpStart(args['username']) - pftpReload() - conn = pftpDB() - conn.where('id=?', (int(args['id']),)).save( - 'status', (args['status'],)) - - if data[1] == '': - return 'ok' - return data[0] - - if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -452,23 +197,5 @@ if __name__ == "__main__": print initdInstall() elif func == 'initd_uninstall': print initdUinstall() - elif func == 'conf': - print getConf() - elif func == 'get_www_dir': - print getWwwDir() - elif func == 'get_ftp_list': - print getFtpList() - elif func == 'add_ftp': - print addFtp() - elif func == 'del_ftp': - print delFtp() - elif func == 'mod_ftp': - print modFtp() - elif func == 'mod_ftp_port': - print modFtpPort() - elif func == 'stop_ftp': - print stopPort() - elif func == 'start_ftp': - print startPort() else: print 'error' diff --git a/plugins/l2tp/install.sh b/plugins/l2tp/install.sh index 42cdc4096..b28a8697e 100755 --- a/plugins/l2tp/install.sh +++ b/plugins/l2tp/install.sh @@ -10,28 +10,27 @@ serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/bt_install.pl - +SYSOS=`uname` Install_l2tp() { isStart="" - while [[ "$isStart" == "" ]]; - do - echo -e ".\c" - sleep 0.5 - startTime=`date +%s` - echo $startTime,'end' - done echo '正在安装脚本文件...' > $install_tmp mkdir -p $serverPath/l2tp echo '1.0' > $serverPath/l2tp/version.pl - echo '安装完成' > $install_tmp + + if [ "Darwin" == "$SYSOS" ];then + echo 'macosx unavailable' > $install_tmp + exit 0 + fi + + echo 'install complete' > $install_tmp } Uninstall_l2tp() { rm -rf $serverPath/l2tp - echo "卸载完成" > $install_tmp + echo "Uninstall completed" > $install_tmp } action=$1 diff --git a/plugins/l2tp/js/l2tp.js b/plugins/l2tp/js/l2tp.js new file mode 100755 index 000000000..5480b86f8 --- /dev/null +++ b/plugins/l2tp/js/l2tp.js @@ -0,0 +1,49 @@ +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}); +} diff --git a/route/static/app/site.js b/route/static/app/site.js index a3b773bd3..14890895a 100755 --- a/route/static/app/site.js +++ b/route/static/app/site.js @@ -1492,14 +1492,14 @@ function dns_check(){ } //证书夹 -function ssl_admin(siteName){ +function sslAdmin(siteName){ var loadT = layer.msg('正在提交任务...',{icon:16,time:0,shade: [0.3, '#000']}); $.get('/site/get_cert_list',function(data){ layer.close(loadT); var rdata = data['data']; var tbody = ''; for(var i=0;i'+rdata[i].dns.join('
')+''+rdata[i].notAfter+''+rdata[i].issuer+'部署 | 删除' + tbody += ''+rdata[i].subject+''+rdata[i].dns.join('
')+''+rdata[i].notAfter+''+rdata[i].issuer+'部署 | 删除' } var txt = '
\ \ @@ -1511,8 +1511,8 @@ function ssl_admin(siteName){ } //删除证书 -function remove_ssl(certName){ - SafeMessage('删除证书','您真的要从证书夹删除证书吗?',function(){ +function removeSsl(certName){ + safeMessage('删除证书','您真的要从证书夹删除证书吗?',function(){ var loadT = layer.msg(lan.site.the_msg,{icon:16,time:0,shade: [0.3, '#000']}); $.post('/ssl?action=RemoveCert',{certName:certName},function(rdata){ layer.close(loadT); @@ -1523,7 +1523,7 @@ function remove_ssl(certName){ } //从证书夹部署 -function set_cert_ssl(certName,siteName){ +function setCertSsl(certName,siteName){ var loadT = layer.msg('正在部署证书...',{icon:16,time:0,shade: [0.3, '#000']}); $.post('/ssl?action=SetCertToSite',{certName:certName,siteName:siteName},function(rdata){ layer.close(loadT); @@ -1537,7 +1537,7 @@ function setSSL(id,siteName){ Let\'s Encrypt\ 其他证书\ 关闭\ - 证书夹' + 证书夹' + '
\ 强制HTTPS\
\