-
Notifications
You must be signed in to change notification settings - Fork 143
/
index.html
279 lines (265 loc) · 10.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<style>
.tasklist{
padding-left: 0;
padding-top: 0;
}
.tab-con{
margin-left: 15px;
}
.tab-con .user-list{
overflow: hidden;
}
.tasklist .tab-nav{
background-color: #F0F0F1;
width: 125px;
height: 550px;
float: left;
}
.tasklist .tab-nav span{
display: block;
width: 125px;
padding-right:0 ;
height: 40px;
line-height: 40px;
padding-left: 20px;
position: relative;
cursor: pointer;
border:none;
background: #F0F0F1;
}
.tasklist .tab-nav span.on{
background-color:#fff ;
}
</style>
<div class="tasklist">
<div class="tab-nav">
<span class="on">用户端口</span>
<span class="">配置项</span>
<span class="">服务</span>
</div>
<div class="tab-con">
<div id="root" class="SetDns">
<div class="divtable" style="width: 520px;">
<input class="bt-input-text mr5" name="ss_port" type="number" value="" max="65535" min="81" style="width:80px" placeholder="端口" />
<input class="bt-input-text mr5" name="ss_password" id="ss_password" type="text" value="" style="width:200px" placeholder="密码" />
<span title="随机密码" style="margin-right: 10px;" class="glyphicon glyphicon-repeat cursor" onclick="$('#ss_password').val(RandomStrPwd(16));"></span>
<button class="btn btn-default btn-sm va0" onclick="CreateUser();">添加</button>
<table class="table table-hover" style="margin-top: 10px; max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>端口</th>
<th>密码</th>
<th style="text-align: right;">操作</th>
</tr>
</thead>
<tbody id="userlist"></tbody>
</table>
</div>
<ul class="help-info-text c7 mtb15" style="padding-top:30px">
<li style="color: red;">请尊守当地法律,不得将本插件商用!</li>
<li>客户端工具Windows版: <a class="btlink" href="/download?filename=%2Fwww%2Fserver%2Fpanel%2Fplugin%2Fss%2Fshadowsocks.zip" target="_blank">点击下载</a></li>
<li>客户端工具Android版: <a class="btlink" href="/download?filename=%2Fwww%2Fserver%2Fpanel%2Fplugin%2Fss%2Fshadowsocks-nightly-4.2.5.apk" target="_blank">点击下载</a></li>
</ul>
</div>
<div id="swap" class="SetSwap" style="display: none;">
<div class="conf_p" style="margin-bottom:0">
<p><span>server</span><input style="width: 120px;" class="bt-input-text mr5" name="ss_server" value="" type="text"><font>监听IP,请勿随意修改</font></p>
<p><span>method</span>
<select style="width: 120px;margin-left: -4px;" class="bt-input-text mr5" name="ss_method">
<option value="aes-256-cfb">aes-256-cfb</option>
<option value="aes-192-cfb">aes-192-cfb</option>
<option value="aes-128-cfb">aes-128-cfb</option>
<option value="aes-256-ctr">aes-256-ctr</option>
<option value="aes-192-ctr">aes-192-ctr</option>
<option value="aes-128-ctr">aes-128-ctr</option>
<option value="camellia-256-cfb">camellia-256-cfb</option>
<option value="camellia-192-cfb">camellia-192-cfb</option>
<option value="camellia-128-cfb">camellia-128-cfb</option>
<option value="aes-256-gcm">aes-256-gcm</option>
<option value="aes-192-gcm">aes-192-gcm</option>
<option value="aes-128-gcm">aes-128-gcm</option>
<option value="rc4-md5">rc4-md5</option>
<option value="bf-cfb">bf-cfb</option>
<option value="chacha20">chacha20</option>
<option value="chacha20-ietf">chacha20-ietf</option>
<option value="chacha20-ietf-poly1305">chacha20-ietf-poly1305</option>
</select>
<font>加密方式</font></p>
<p><span>timeout</span><input style="width: 120px;" class="bt-input-text mr5" name="ss_timeout" value="" type="number"><font>连接超时时间</font></p>
<p><span>local_address</span><input style="width: 120px;" class="bt-input-text mr5" name="ss_local_address" value="" type="text"><font>客户机本机环回地址</font></p>
<p><span>local_port</span><input style="width: 120px;" class="bt-input-text mr5" name="ss_local_port" value="" type="number"><font>客户机端口号</font></p>
<div style="margin-top:10px; padding-right:230px" class="text-right"><button class="btn btn-success btn-sm" onclick="SetOptions()">保存</button></div>
</div>
<ul class="help-info-text c7 mtb15" style="padding-top:30px">
<li>请尊守当地法律,不得将本插件商用!</li>
</ul>
</div>
<div class="soft-man-con" style="display: none;">
<p class="status">当前状态:<span>开启</span><span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play"></span></p>
<div class="sfm-opt">
<button class="btn btn-default btn-sm" onclick="SetServiceStatus('stop')">停止</button>
<button class="btn btn-default btn-sm" onclick="SetServiceStatus('restart')">重启</button>
</div>
<ul class="help-info-text c7 mtb15" style="padding-top:30px">
<li>请尊守当地法律,不得将本插件商用!</li>
</ul>
</div>
</div>
</div>
<script type="javascript/text">
$(".tab-nav span").click(function(){
var i = $(this).index();
$(this).addClass("on").siblings().removeClass("on");
$(".tab-con > div").hide().eq(i).show();
switch(i){
case 0:
GetUsers();
break;
case 1:
GetOptions();
break;
case 2:
GetStatus();
break;
}
});
function GetStatus(){
var loadT = layer.msg('正在获取,请稍候...',{icon:16,time:0});
$.get('/plugin?action=a&name=ss&s=get_status',function(status){
layer.close(loadT);
if(status !== true){
$(".status").html('当前状态:<span id="ss_status_str">关闭</span><span style="color: red; margin-left: 3px;" class="glyphicon glyphicon-pause"></span>');
$(".sfm-opt").html('<button class="btn btn-default btn-sm" onclick="SetServiceStatus(\'start\')">启动</button> ');
}else{
$(".status").html('当前状态:<span>开启</span><span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play"></span>');
$(".sfm-opt").html('<button class="btn btn-default btn-sm" onclick="SetServiceStatus(\'stop\')">停止</button><button class="btn btn-default btn-sm" onclick="SetServiceStatus(\'restart\')">重启</button>');
}
});
}
function SetServiceStatus(status){
var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0});
$.post('/plugin?action=a&name=ss&s=service_admin',{status:status},function(rdata){
layer.close(loadT);
if(rdata !== true) {
layer.msg('操作失败!',{icon:2});
return;
}
layer.msg('操作成功!',{icon:1});
GetStatus();
});
}
function GetOptions(){
var loadT = layer.msg('正在获取,请稍候...',{icon:16,time:0});
$.get('/plugin?action=a&name=ss&s=get_options',function(options){
layer.close(loadT);
$("input[name='ss_server']").val(options.server);
$("select[name='ss_method']").val(options.method);
$("input[name='ss_timeout']").val(options.timeout);
$("input[name='ss_local_address']").val(options.local_address);
$("input[name='ss_local_port']").val(options.local_port);
});
}
function SetOptions(){
data = {
server:$("input[name='ss_server']").val(),
method:$("select[name='ss_method']").val(),
timeout:$("input[name='ss_timeout']").val(),
local_address:$("input[name='ss_local_address']").val(),
local_port:$("input[name='ss_local_port']").val()
}
var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0});
$.post('/plugin?action=a&name=ss&s=set_options',data,function(rdata){
layer.close(loadT);
if(rdata !== true) {
layer.msg('设置失败!',{icon:2});
return;
}
layer.msg('设置成功!',{icon:1});
setTimeout(function(){
GetOptions();
},1000);
});
}
function GetUsers(){
var loadT = layer.msg('正在获取,请稍候...',{icon:16,time:0});
$.get('/plugin?action=a&name=ss&s=get_users',function(userList){
layer.close(loadT);
var tbody = '';
for(var i=0;i<userList.length;i++){
tbody += '<tr><td>'+userList[i]['port']+'</td><td>'+userList[i]['password']+'</td><td style="text-align: right;"><a class="btlink" onclick="SetPassword(\''+userList[i]['port']+'\')">修改密码</a> | <a class="btlink" onclick="RemoveUser(\''+userList[i]['port']+'\')">删除</a></td></tr>';
}
$("#userlist").html(tbody);
$('#ss_password').val(RandomStrPwd(16));
});
}
var messageboxIndex = 0;
function SetPassword(port){
messageboxIndex = layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '320px',
title: '修改端口['+port+']密码',
content: '<div class="bt-form pd20 pb70">\
<div class="line">\
<input type="text" class="bt-input-text" name="new_password" id="MyPassword" value="" placeholder="新的密码" style="width:250px" /><span title="随机密码" style="margin-left: 10px;" class="glyphicon glyphicon-repeat cursor" onclick="repeatPwd(16)"></span>\
</div>\
<div class="bt-form-submit-btn">\
<button type="button" class="btn btn-danger btn-sm" onclick="layer.close(messageboxIndex)">取消</button>\
<button id="CreateFileBtn" type="button" class="btn btn-success btn-sm" onclick="ToSetPassword(\''+port+'\')">修改</button>\
</div>\
</div>'
});
}
function ToSetPassword(port){
var spassword = $('#MyPassword').val();
var loadT = layer.msg('正在修改,请稍候...',{icon:16,time:0});
$.post('/plugin?action=a&name=ss&s=create_user',{port:port,password:spassword},function(rdata){
layer.close(loadT);
if(rdata !== true) {
layer.msg('修改失败!',{icon:2});
return;
}
layer.msg('修改成功!',{icon:1});
layer.close(messageboxIndex);
GetUsers();
});
}
function RemoveUser(port){
SafeMessage('删除用户端口','您真的要删除['+port+']端口吗?',function(){
var loadT = layer.msg('正在删除,请稍候...',{icon:16,time:0});
$.post('/plugin?action=a&name=ss&s=remove_user',{port:port},function(rdata){
layer.close(loadT);
if(rdata !== true) {
layer.msg('删除失败!',{icon:2});
return;
}
layer.msg('删除成功!',{icon:1});
GetUsers();
});
});
}
function CreateUser(){
var data = {
port:$("input[name='ss_port']").val(),
password:$("input[name='ss_password']").val()
}
if(data.port > 65535 || data.port < 81){
layer.msg('端口范围错误(81-65535)!',{icon:2});
return;
}
var loadT = layer.msg('正在添加,请稍候...',{icon:16,time:0});
$.post('/plugin?action=a&name=ss&s=create_user',data,function(rdata){
layer.close(loadT);
if(rdata !== true) {
layer.msg('添加失败!',{icon:2});
return;
}
layer.msg('添加成功!',{icon:1});
$("input[name='ss_port']").val('');
$("input[name='ss_password']").val('');
GetUsers();
});
}
GetUsers();
</script>