/
squid.js
449 lines (378 loc) · 18 KB
/
squid.js
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
var hostname_mem;
var rulename_mem;
var x_SquidActionService=function(obj){
LoadAjax('squid_main_config','squid.index.php?main=yes&tab=status&hostname='+hostname_mem) ;
}
var x_SquidActionNetwork=function(obj){
LoadAjax('squid_main_config','squid.index.php?main=yes&tab=networking&hostname='+hostname_mem) ;
}
var x_SquidActionAcl=function(obj){
LoadAjax('squid_main_config','squid.index.php?main=yes&tab=acl&hostname='+hostname_mem) ;
}
var x_SquidActionAclRule=function(obj){
LoadAjax('aclrules','squid.index.php?SquidAclAddrule=yes&hostname='+hostname_mem+'&rulename=' + rulename_mem);
LoadAjax('AclDatas','squid.index.php?SquidAclLoadDatas=yes&hostname='+hostname_mem+'&rulename=' + rulename_mem);
}
var x_SquidActionAccess=function(obj){
LoadAjax('squid_main_config','squid.index.php?main=yes&tab=access&hostname='+hostname_mem + '&rulename=' +rulename_mem );
}
var x_SquidActionCache=function(obj){
LoadAjax('squid_main_config','squid.index.php?main=yes&tab=cache&hostname='+hostname_mem);
}
function SwitchSquidActionAccess(hostname,main_rule){
LoadAjax('squid_main_config','squid.index.php?main=yes&tab=access&hostname='+hostname + '&rulename=' +main_rule );
}
function SquidActionService(hostname,action){
hostname_mem=hostname;
var XHR = new XHRConnection();
XHR.appendData('SquidActionService',hostname);
XHR.appendData('action',action);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionService);
//dansguardian_service
}
function Kav4ProxyActionService(hostname,action){
hostname_mem=hostname;
var XHR = new XHRConnection();
XHR.appendData('Kav4ProxyActionService',hostname);
XHR.appendData('action',action);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionService);
}
function DansGuardianActionService(hostname,action){
hostname_mem=hostname;
var XHR = new XHRConnection();
XHR.appendData('DansGuardianActionService',hostname);
XHR.appendData('action',action);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionService);
}
function squid_http_port_delete(hostname,index,port_type){
hostname_mem=hostname;
var XHR = new XHRConnection();
XHR.appendData('squid_http_port_delete',hostname);
XHR.appendData('index',index);
XHR.appendData('port_type',port_type);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionNetwork);
}
function SquidAclAddrule(hostname,rulename){
if(rulename){
LoadAjax('aclrules','squid.index.php?SquidAclAddrule=yes&hostname='+hostname+'&rulename=' + rulename);
LoadAjax('AclDatas','squid.index.php?SquidAclLoadDatas=yes&hostname='+hostname+'&rulename=' + rulename);
}else{
LoadAjax('aclrules','squid.index.php?SquidAclAddrule=yes&hostname='+hostname);
document.getElementById('AclDatas').innerHTML='';
}
}
function SquidSelectAcl(){
var acl_type=document.getElementById('acl_type').value;
LoadAjax('aclform','squid.index.php?SquidSelectAcl='+acl_type) ;
}
function SquidAclActiveRule(rulename,active,hostname){
hostname_mem=hostname;
var XHR = new XHRConnection();
XHR.appendData('SquidAclActiveRule',rulename);
XHR.appendData('active',active);
XHR.appendData('hostname',hostname);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAcl);
}
function SquidAddAcl(){
var acl_type=document.getElementById('acl_type').value;
var acl_name=document.getElementById('acl_name').value;
reg = /\s+/g;
acl_name=acl_name.replace(reg,'_');
var acl_value=document.getElementById('acl_value').value;
var hostname=document.getElementById('hostname').value;
hostname_mem=hostname;
rulename_mem=acl_name;
var XHR = new XHRConnection();
XHR.appendData('acl_type',acl_type);
XHR.appendData('acl_name',acl_name);
XHR.appendData('acl_value',acl_value);
XHR.appendData('hostname',hostname);
XHR.appendData('addacl','yes');
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAclRule);
}
function SquidDeleteAclData(hostname,rulename,index){
hostname_mem=hostname;
rulename_mem=rulename;
var XHR = new XHRConnection();
XHR.appendData('acl_name',rulename);
XHR.appendData('hostname',hostname);
XHR.appendData('acl_delete',index);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAclRule);
}
function SquidAclDeleteRule(hostname,rulename){
hostname_mem=hostname;
rulename_mem=rulename;
var XHR = new XHRConnection();
XHR.appendData('hostname',hostname);
XHR.appendData('rule_acl_delete',rulename);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAcl);
}
function SquidAccessSwitchEnable(hostname,num,keyname){
hostname_mem=hostname;
rulename_mem=keyname;
var XHR = new XHRConnection();
XHR.appendData('hostname',hostname);
XHR.appendData('AccessSwitch',keyname);
XHR.appendData('AccessSwitchIndex',num);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAccess);
}
function SquidAccessDelete(hostname,num,keyname){
hostname_mem=hostname;
rulename_mem=keyname;
var XHR = new XHRConnection();
XHR.appendData('hostname',hostname);
XHR.appendData('SquidAccessDelete',keyname);
XHR.appendData('index',num);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAccess);
}
function SquidBackAccessRules(hostname){
if (confirm('Sure ???')){
hostname_mem=hostname;
var XHR = new XHRConnection();
XHR.appendData('hostname',hostname);
XHR.appendData('SquidBackAccessRules','yes');
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAccess);
}
}
function SquidAccessMove(hostname,num,keyname,move){
var XHR = new XHRConnection();
hostname_mem=hostname;
rulename_mem=keyname;
XHR.appendData('hostname',hostname);
XHR.appendData('SquidAccessMove',keyname);
XHR.appendData('index',num);
XHR.appendData('move',move);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAccess);
}
function AddAccessAclRule(md){
var XHR = new XHRConnection();
var hostname=document.getElementById(md+'_hostname').value;
var rulename=document.getElementById(md+'_rulename').value;
hostname_mem=hostname;
rulename_mem=rulename;
var index=document.getElementById(md+'_index').value;
var acl=document.getElementById(md+'_acl').value;
var isnot='no'
if(document.getElementById(md+'_isnot').checked){isnot='yes';}
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('AddAccessAclRule',rulename);
XHR.appendData('index',index);
XHR.appendData('acl',acl);
XHR.appendData('isnot',isnot);
document.getElementById('access_acl_rule_edit_' +rulename+ '_'+ index).innerHTML='';
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAccess);
}
function InsertIntoAccessAclRule(md){
var XHR = new XHRConnection();
var hostname=document.getElementById(md+'_hostname').value;
var rulename=document.getElementById(md+'_rulename').value;
var index=document.getElementById(md+'_index').value;
var acl=document.getElementById(md+'_acl').value;
rulename_mem=rulename;
hostname_mem=hostname;
var isnot='no'
if(document.getElementById(md+'_isnot').checked){isnot='yes';}
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('InsertIntoAccessAclRule',rulename);
XHR.appendData('index',index);
XHR.appendData('acl',acl);
XHR.appendData('isnot',isnot);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAccess);
}
function SquidAccessInsertRule(hostname,index,keyname){
LoadAjax('access_acl_rule_edit_' + keyname + '_' + index,'squid.index.php?SquidAccessInsertRule=' + keyname + '&hostname='+hostname + '&index=' + index);
}
function SquidAccessDeleteAcl(hostname,keyname, index, acl_index){
hostname_mem=hostname;
rulename_mem=keyname;
var XHR = new XHRConnection();
XHR.appendData('hostname',hostname);
XHR.appendData('SquidAccessDeleteAcl',keyname);
XHR.appendData('index',index);
XHR.appendData('acl_index',acl_index);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionAccess);
}
function SquidUpdateNetworkConfig(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('UpdateGeneralConfig','yes');
if(document.getElementById('visible_hostname')){XHR.appendData('visible_hostname',document.getElementById('visible_hostname').value);}
if(document.getElementById('dead_peer_timeout')){XHR.appendData('dead_peer_timeout',document.getElementById('dead_peer_timeout').value);}
if(document.getElementById('connect_timeout')){XHR.appendData('connect_timeout',document.getElementById('connect_timeout').value);}
if(document.getElementById('peer_connect_timeout')){XHR.appendData('dns_timeout',document.getElementById('peer_connect_timeout').value);}
if(document.getElementById('peer_connect_timeout')){XHR.appendData('peer_connect_timeout',document.getElementById('peer_connect_timeout').value);}
if(document.getElementById('request_body_max_size')){XHR.appendData('request_body_max_size',document.getElementById('request_body_max_size').value);}
if(document.getElementById('maximum_object_size').value){XHR.appendData('maximum_object_size',document.getElementById('maximum_object_size').value);}
if(document.getElementById('cache_mem').value){XHR.appendData('cache_mem',document.getElementById('cache_mem').value);}
if(document.getElementById('cache_swap_low').value){XHR.appendData('cache_swap_low',document.getElementById('cache_swap_low').value);}
if(document.getElementById('cache_swap_high').value){XHR.appendData('cache_swap_high',document.getElementById('cache_swap_high').value);}
if(document.getElementById('minimum_object_size').value){XHR.appendData('minimum_object_size',document.getElementById('minimum_object_size').value);}
if(document.getElementById('maximum_object_size_in_memory').value){XHR.appendData('maximum_object_size_in_memory',document.getElementById('maximum_object_size_in_memory').value);}
if(document.getElementById('ipcache_size').value){XHR.appendData('ipcache_size',document.getElementById('ipcache_size').value);}
if(document.getElementById('ipcache_low').value){XHR.appendData('ipcache_low',document.getElementById('ipcache_low').value);}
if(document.getElementById('ipcache_high').value){XHR.appendData('ipcache_high',document.getElementById('ipcache_high').value);}
if(document.getElementById('fqdncache_size').value){XHR.appendData('fqdncache_size',document.getElementById('fqdncache_size').value);}
if(document.getElementById('left-cache')){
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionCache);
return true;
}
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionNetwork);
}
function SquidCacheAdd(hostname,path){
LoadAjax('left-cache','squid.index.php?main=yes&tab=cache&hostname=' + hostname + '&subsection=add-cache&path='+path);
}
function SquidCacheAddAjax(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('cache_dir',document.getElementById('cache_dir').value);
XHR.appendData('cache_size',document.getElementById('cache_size').value);
XHR.appendData('cache_type',document.getElementById('cache_type').value);
XHR.appendData('cache_dir_level1',document.getElementById('cache_dir_level1').value);
XHR.appendData('cache_dir_level2',document.getElementById('cache_dir_level2').value);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionCache);
}
function SquidCacheDelete(hostname,index){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('SquidCacheDelete',index);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionCache);
}
var SquidSimpleNetwork=function(obj){
LoadAjax('squid_main_config','squid.simple.php?main=network&hostname='+hostname_mem) ;
}
var SquidSimpleKav=function(obj){
LoadAjax('squid_main_config','squid.simple.php?main=kavav&hostname='+hostname_mem) ;
}
var SquidSimpleSafePortsList=function(obj){
LoadAjax('Safe_Ports','squid.simple.php?main=Safe_ports_list&hostname='+hostname_mem) ;
}
var SquidSimpleDenyExt=function(obj){
document.getElementById('_table_deny_ext').innerHTML='';
LoadAjax2('_table_deny_ext','squid.simple.php?main=deny_ext_list&hostname='+hostname_mem) ;
}
function SquidSimpleAddsrc(hostname){
var squid_ip_client=document.getElementById('squid_ip_client').value;
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('squid_ip_client',squid_ip_client);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleNetwork);
}
function SquidSimpleDelsrc(hostname,acl_name,index){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('squid_acl_to_delete',acl_name);
XHR.appendData('index',index);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleNetwork);
}
function SquidSimpleLdapEnable(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
var auth_allow;
if(document.getElementById('auth_allow').checked){
auth_allow="yes";
}else{auth_allow="no";}
XHR.appendData('hostname',hostname);
XHR.appendData('auth_allow',auth_allow);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleNetwork);
}
function SquidSimpleAddSafePorts(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
var protocol=document.getElementById('protocol').value;
XHR.appendData('hostname',hostname);
XHR.appendData('add_protocol',protocol);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleSafePortsList);
}
function SquidSimpleDelSafePort(hostname,index){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('Safe_Ports_delete',index);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleSafePortsList);
}
function SquidSimpleAddDenyExt(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
var add_deny_ext=document.getElementById('deny_ext').value;
XHR.appendData('hostname',hostname);
XHR.appendData('add_deny_ext',add_deny_ext);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleDenyExt);
}
function SquidSimpleDelDenyExt(hostname,index){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('del_deny_ext',index);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleDenyExt);
}
function SquidSimpleEditDansPort(hostname){
var XHR = new XHRConnection();
var http_port=document.getElementById('dans_listen_port').value;
var http_port_ip=document.getElementById('dans_http_port_ip').value;
var squid_port=document.getElementById('squid_listen_port').value;
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('dans_http_port',http_port);
XHR.appendData('dans_http_port_ip',http_port_ip);
XHR.appendData('squid_http_port',squid_port);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleNetwork);
}
function SquidSimpleEditSquidPort(hostname){
var XHR = new XHRConnection();
var http_port=document.getElementById('listen_port').value;
var http_port_ip=document.getElementById('http_port_ip').value;
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('squid_http_port',http_port);
XHR.appendData('squid_http_port_ip',http_port_ip);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleNetwork);
}
function squid_dnsserver_delete(hostname,index){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('squid_dnsserver_delete',index);
XHR.sendAndLoad('squid.index.php', 'GET',x_SquidActionNetwork);
}
function SquidSimpleKav4Proxy(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('EnableKav4Proxy',document.getElementById('EnableKav4Proxy').value);
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleKav);
}
function SquidSimpleKav4ProxyMacro1(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('SquidSimpleKav4ProxyMacro1','yes');
XHR.sendAndLoad('squid.simple.php', 'GET',SquidSimpleKav);
}
var X_SQUID_APPLY=function(obj){
var text;
var mtext;
text=obj.responseText;
if(text.length>0){
alert(text);
}
LoadAjax('services_status','squid.index.php?status=yes&hostname='+hostname_mem);
}
function SQUID_APPLY(hostname){
var XHR = new XHRConnection();
hostname_mem=hostname;
XHR.appendData('hostname',hostname);
XHR.appendData('ApplyConfig','yes');
XHR.sendAndLoad('squid.index.php', 'GET',X_SQUID_APPLY);
}
function SquidViewStartError(){
YahooWin3(350,'squid.index.php?StartError=yes','Errors');
}