-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaegis.htm
591 lines (591 loc) · 31.7 KB
/
aegis.htm
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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
<!DOCTYPE html>
<html>
<head>
<title>Aegis</title>
<style>
html, body { margin: 0; padding: 0; border: none; width: calc(100% + 1px); background-color: white; }
body { height: 100vh; width: 100%; font-family: Arial, Helvetica, sans-serif; overflow: hidden; }
section { box-sizing: border-box; display: flex; flex-direction: column; height: inherit; max-height: 100vh; }
section > * { box-sizing: border-box; }
#header, #menu { width: calc(100% + 1px); }
#header { color: white; background: linear-gradient(180deg, rgba(0,0,0,1) 0%, rgba(47,79,79,1) 100%); padding: 0.5em 1em; border: 1px solid rgb(47.79.79); margin-bottom: -1px; }
#header h1 { line-height: 0.5em; height: 0.5em; color: rgba(255, 255, 255, 0.8); float: left; margin: 0.5em 0; }
#header #by { float: left; color: rgba(255, 255, 255, 0.5); line-height: 2.5em; height: 1em; font-size: 0.8em; margin: 0.5em 0 0 0.5em; font-family: Bradley Hand, cursive; }
#info { color: rgba(255, 255, 255, 0.9); float: right; font-size: 0.8em; }
#menu { background: linear-gradient(180deg, rgba(47,79,79,0.7) 0%, rgba(47,79,79,0.3) 100%); padding: 0 0 0 0.5em; }
#menu > input { display: none; }
#menu > input + label { background: linear-gradient(180deg, rgb(47,79,79) 0%, rgb(99,123,123) 100%); border-radius: 0 0 0.5em 0.5em; margin-left: 0.3em; padding: 0.3em 0.5em; color: white; font-size: 1em; text-align: center; text-decoration: none; display: block; width: fit-content; float: left; }
#menu > input:checked + label { border-radius: 0.5em 0.5em 0 0; background: linear-gradient(180deg, rgb(203,211,211) 0%, rgb(255,255,255) 100%); color: darkSlateGrey; }
#menu > #menu-upgrade + label { display: none; background: linear-gradient(180deg, rgb(47,79,79) 0%, rgb(255,0,0) 100%); }
#menu > #menu-upgrade:checked + label { background: linear-gradient(180deg, rgb(203,211,211) 0%, rgb(255,255,255) 100%); color: red; }
#ctrl > * { display: none; }
#ctrl > .show { padding: 0.5em 0 0.5em 1em; font-size: 0.8em; margin-bottom: 0; border-bottom: 1px dotted darkSlateGrey; }
#vers-message { font-size: 1.5em; font-weight: bold; color: red; margin-bottom: 0.2em; }
#ctrl-log input { margin-left: 1em; }
#ctrl-stats span, #ctrl-stats input, #ctrl-stats label { vertical-align: middle; }
#ctrl-stats .ext { display: inline-block; margin-left: 1em; font-weight: bold; color: #FF8888; }
#ctrl-stats .int { display: inline-block; margin-left: 1em; font-weight: bold; color: #8888FF; }
#ctrl-tools > #check-ip { font-family: monospace; font-size: 1.1em; border: 1px solid black; outline: none; box-shadow: none; resize: none; }
#ctrl > .list > * { display: inline; margin-right: 1em; }
#log-filter-incoming + label { color: red; border-top: 2px solid lightgrey; }
#log-filter-outgoing + label { color: blue; border-top: 2px solid lightgrey; }
#log-filter-wan + label { color: #F87217; border-top: 2px solid red; }
#log-filter-vpn + label { color: #F535AA; border-top: 2px solid red; }
#log-filter-bdc + label { color: #E238EC; border-top: 2px solid blue; }
#log-filter-rtr + label { color: #43BFC7; border-top: 2px solid blue; }
#log-filter-lan + label { color: #2B65EC; border-top: 2px solid blue; }
#main { display: flex; align-items: stretch; width: 100%; flex-grow: 1; overflow: hidden; max-height: inherit; }
#main > * { box-sizing: border-box; max-height: inherit; width: 100%; padding: 0 0.5em; display: none; }
#main .scroll { overflow: auto; padding-top: 0.35em; }
#main .scroll:before {
content: ' ';
width: calc(100% + 1px);
height: 0.6em;
position: absolute;
margin: -0.35em 0 0 -0.5em;
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
}
#status.running { background-color:#b3e6c9; border: solid 1em MediumSeaGreen; }
#status.off { background-color:LightGrey; border: solid 1em DarkGrey; }
#status.error { background-color:#ffa899; border: solid 1em Tomato; }
#status li { margin-left: -1em; }
#main-status h2 { font-variant: all-small-caps slashed-zero; margin: 0; }
#main-status h2 span { color:Grey; font-weight: normal; }
#main-status h3 { padding-left: 1em; margin: 0; }
#main-status h3 + ul { margin: 0 0 0.5em 0; padding: 0.5em 2.5em; 0 0; }
#main-status h3.error { background-color:Tomato; }
#main-status h3.error + ul { background-color:#ffe9e6; }
#main-status h3.warning { background-color:Orange; }
#main-status h3.warning + ul { background-color:#fff6e6; }
#main-status h3.more + input + label { background-color:Violet; }
#main-status h3.more + input + label + ul { background-color:#fce9fc; }
#main-status h3.collapsibleList { display: none; }
#main-status h3.collapsibleList + input { display: none; }
#main-status h3.collapsibleList + input + label { display: block; margin-bottom: 0.5em; font-weight: bold; font-size: 1.2em; padding-left: 1em; cursor: pointer; }
#main-status h3.collapsibleList + input:checked + label { margin-bottom: 0; }
#main-status h3.collapsibleList + input + label + * { display: none; padding-top: 0.5em; }
#main-status h3.collapsibleList + input:checked + label + * { display: block; margin: 0 0 0.5em 0; }
#main-status h3.collapsibleList + input + label::before {
content: ' ';
display: inline-block;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-left: 5px solid currentColor;
vertical-align: middle;
margin-right: .7rem;
transform: translateY(-2px);
transition: transform .2s ease-out;
}
#main-status h3.collapsibleList + input:checked + label::before { transform: rotate(90deg) translateX(-3px); }
#main-command, #main-upgrade { font-family: monospace; min-width: max-content; }
#logbox { display:table; font-family: "Andale Mono", AndaleMono, monospace; font-size: 0.85em; line-height: 1.1em; min-width: max-content; }
#logbox p { margin: 0 0.5em 0 0; display: table-row; }
#logbox.incoming p.incoming { display: none; }
#logbox.outgoing p.outgoing { display: none; }
#logbox.wan p.wan { display: none; }
#logbox.vpn p.vpn { display: none; }
#logbox.bdc p.bdc { display: none; }
#logbox.rtr p.rtr { display: none; }
#logbox.lan p.lan { display: none; }
#logbox p > * { display: table-cell; padding-right: 0.5em; }
#logbox log-ts { color: #666; }
#logbox p.wan log-if { font-weight: bold; color: #F87217; }
p.wan log-if::before { content: 'WAN'; }
#logbox p.vpn log-if { font-weight: bold; color: #F535AA; }
p.vpn log-if::before { content: 'VPN'; }
#logbox p.incoming log-dir::after { content: '\A0\21E5\A0'; color: red; font-size: 2.2em; line-height: 0; vertical-align: sub; }
#logbox p.outgoing log-dir::after { content: '\A0\21E4\A0'; color: blue; font-size: 2.2em; line-height: 0; vertical-align: sub; }
p.incoming log-ts::after { content: ' INCOMING'; font-weight: bold; color: red; }
p.outgoing log-ts::after { content: ' OUTGOING'; font-weight: bold; color: blue; }
#logbox p log-ptl { text-decoration: underline; color: green; text-decoration-style: dotted; cursor: pointer; }
#logbox p log-rip { font-weight: bold; color: red; text-decoration: underline; text-decoration-style: dotted; cursor: pointer; padding-right: 0px; }
p.lan log-lnm { font-weight: bold; color: #2B65EC; }
p.rtr log-lnm { font-weight: bold; color: #43BFC7; }
p.bdc log-lnm { font-weight: bold; color: #E238EC; }
log-if::after, log-lnm::after { content: ':'; color: darkgrey; }
log-if, log-lnm { text-align: right; }
#logbox p log-lip { font-weight: bold; color: blue; padding-right: 0px; }
log-pt::before { display:inline-block; color: darkgrey; content: ':'; }
#logbox p log-rip + log-pt { color: red; text-decoration: underline; text-decoration-style: dotted; cursor: pointer; }
#logbox p log-lip + log-pt { color: blue; text-decoration: underline; text-decoration-style: dotted; cursor: pointer; }
@keyframes highlight-red {
0% { background: #f88; }
100% { background: none; }
}
@keyframes highlight-blue {
0% { background: #88f; }
100% { background: none; }
}
#logbox p.incoming.new { animation: highlight-red 1s; }
#logbox p.outgoing.new { animation: highlight-blue 1s; }
.overlay { display: none; box-sizing: border-box; position: fixed; z-index: 9999; top: 50%; left: 50%; transform: translate(-50%, -50%); width: fit-content; background-color: rgba(0,0,0,0.8); border: 0.5em solid black; border-radius: 0.5em; color: white; }
.overlay > .title { width: inherited; background: black; padding-bottom: 0.25em; text-align: center; font-weight: bold; font-size: 1em; }
.overlay > .message { padding: 0.25em 0.5em; overflow: auto; }
.overlay > .message p { width: max-content; margin: 0 1em 0 0; }
.overlay input { float: right; margin: 0.25em 0.5em 0.5em 0; color: white; font-size: 1em; font-weight: bold; background: #718787; border: 0.2em solid #bfc9c9; border-radius: 0.4em; text-shadow: none; cursor: pointer; }
#statsbox stats-head { font-size: 1.1em; font-weight: bold; color: #999999; }
#statsbox stats-head strong { color: black; }
#statsbox stats-head2 { font-weight: bold; color: #999999; }
#statsbox stats-hits { display: inline-block; font-weight: bold; font-family: Courier New, monospace; width: 4em; text-align: right; margin-right: 0.5em; }
#statsbox stats-ptl { text-decoration: underline; font-weight: bold; color: green; text-decoration-style: dotted; cursor: pointer; }
#statsbox stats-rip { text-decoration: underline; font-weight: bold; color: red; text-decoration-style: dotted; cursor: pointer; padding-right: 0px; }
#statsbox stats-lip { font-weight: bold; color: blue; padding-right: 0px; }
#statsbox stats-pt { font-weight: bold; text-decoration: underline; text-decoration-style: dotted; cursor: pointer; }
#statsbox stats-pt::before { display:inline-block; font-weight: normal; color: darkgrey; content: ' PORT\A0'; text-decoration: none; }
#statsbox stats-pt.empty::before { content: ' NO PORT'; }
#statsbox stats-rip + stats-pt::before { font-weight: bold; content: ':'; }
#statsbox stats-rip + stats-pt.empty::before { content: ':\2205'; }
#statsbox stats-lip + stats-pt::before { font-weight: bold; content: ':'; }
#statsbox stats-lip + stats-pt.empty::before { content: ':\2205'; }
#statsbox stats-dir.incoming { font-weight: bold; color: red; }
#statsbox stats-dir.outgoing { font-weight: bold; color: blue; }
#statsbox stats-ext { color: red; }
#statsbox stats-int { color: blue; }
#statsbox stats-ntl { color: darkgrey; }
#statsbox stats-iface.wan { font-weight: bold; color: #F87217; }
#statsbox stats-iface.vpn { font-weight: bold; color: #F535AA; }
#statsbox stats-loc.lan { font-weight: bold; color: #2B65EC; }
#statsbox stats-loc.rtr { font-weight: bold; color: #43BFC7; }
#statsbox stats-loc.bdc { font-weight: bold; color: #E238EC; }
#statsbox stats-lt { color: darkgrey; font-style: oblique; }
#statsbox stats-lt::before { content: ' (latest hit: '; }
#statsbox stats-lt::after { content: ')'; }
textarea.list { font-family: monospace; font-size: 1em; border: none; overflow: auto; outline: none; box-shadow: none; resize: none; }
#main-doc code { display: inline-block; background: lightgrey; color: darkgreen; }
</style>
<script>
var activeMenu;
var logMaxLen = 300;
function aegis(cmd, dst, arg, pos, callback) {
if (dst !== undefined) { var dstElem = document.getElementById(dst); }
if (arg === undefined) { arg=''; } else { arg='&arg='+arg; }
var url='/bolemo/cgi-bin/aegis_web.cgi?cmd='+cmd+arg;
var xhttpOutput;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
switch (this.status) {
case 500:
xhttpOutput = this.responseText.substring(47);
break;
case 200:
xhttpOutput = this.responseText;
break;
default:
alert('Error loading ' + cmd + ': code ' + this.status);
xhttpOutput = '';
}
if (dst !== undefined) {
if (pos === undefined) {
dstElem.innerHTML = xhttpOutput;
} else {
dstElem.insertAdjacentHTML(pos, xhttpOutput);
}
var callbackParam = undefined;
} else {
var callbackParam = xhttpOutput;
}
if (callback instanceof Function) callback(callbackParam);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
function showMenu(item, visible) {
if (visible == true) { var display = "block"; } else { var display = "none"; }
document.querySelector("#menu-"+item+" + label").style.display=display;
}
function displayFor(item) {
activeMenu=item;
clearTimeout(logTimer); clearTimeout(devTimer);
document.title="Aegis - "+item;
document.location.href=window.location.href.split('#')[0]+"#"+item;
document.querySelectorAll("#ctrl > *, #main > *").forEach(elem => elem.style.display="none");
document.getElementById("menu-"+item).checked=true;
document.getElementById("ctrl-"+item).style.display="block";
document.getElementById("main-"+item).style.display="block";
}
function infoCallback(jsonData) {
var _info = JSON.parse(jsonData);
document.getElementById("info").innerHTML = 'version '+_info.version+'<br />'+_info.location+' drive';
switch (_info.versionStatus) {
case 0: break; //current version is latest
case 2: break; //current version is higher than latest one!
case 1: var message = 'Aegis version '+_info.newVersion+' is available!'
document.getElementById("vers-message").innerHTML = message;
showMenu('upgrade', true);
break;
case 3: break; //error checking version!
}
infoTimer = setTimeout(function() { aegis('info', undefined, undefined, undefined, infoCallback); }, 300000);
}
function info() { aegis('info', undefined, undefined, undefined, infoCallback) }
function initCgi() { aegis('init', undefined, undefined, undefined, undefined) }
function status() {
displayFor('status');
document.getElementById("main-status").innerHTML="Getting Aegis status...";
aegis('status', 'main-status');
}
function debug() {
displayFor('debug');
document.getElementById("main-debug").innerHTML="Getting Aegis debug...";
aegis('debug', 'main-debug');
}
function command() {
displayFor('command');
document.getElementById("main-command").innerHTML = '';
}
var logTimer;
var devTimer;
function logPost() {
if (activeMenu != 'log') return;
var logboxElem = document.getElementById("logbox");
var logboxLines = logboxElem.children.length;
if (logboxLines > logMaxLen) {
var diff = logboxLines-logMaxLen;
var i;
for (i=0; i<diff; i++) {
logboxElem.removeChild(logboxElem.lastElementChild);
}
}
logFilter();
setTimeout(function() { document.querySelectorAll("#logbox > p.new").forEach(elem => elem.classList.remove("new")); }, 1200);
clearTimeout(logTimer);
logTimer = setTimeout(function() { if (activeMenu == 'log') { aegis('refresh_log', 'logbox', logMaxLen, 'afterbegin', logPost); } else { clearTimeout(logTimer); } }, 10000);
}
var firstLog = true;
function log() {
hideIpInfo('log');
displayFor('log');
if (firstLog) {
firstLog = false;
document.getElementById("logbox").innerHTML="Retrieving Aegis log...";
aegis('log', 'logbox', logMaxLen, undefined, logPost);
} else { aegis('refresh_log', 'logbox', logMaxLen, 'afterbegin', logPost); }
}
function logFilter() {
var logboxElem = document.getElementById("logbox");
var logFilterIncoming = document.getElementById("log-filter-incoming");
var logFilterOutgoing = document.getElementById("log-filter-outgoing");
var logFilterWan = document.getElementById("log-filter-wan");
var logFilterVpn = document.getElementById("log-filter-vpn");
var logFilterBdc = document.getElementById("log-filter-bdc");
var logFilterRtr = document.getElementById("log-filter-rtr");
var logFilterLan = document.getElementById("log-filter-lan");
if (logFilterIncoming.checked == false) { logboxElem.classList.add('incoming'); } else { logboxElem.classList.remove('incoming'); }
if (logFilterOutgoing.checked == false) { logboxElem.classList.add('outgoing'); } else { logboxElem.classList.remove('outgoing'); }
if (logFilterWan.checked == false) { logboxElem.classList.add('wan'); } else { logboxElem.classList.remove('wan'); }
if (logFilterVpn.checked == false) { logboxElem.classList.add('vpn'); } else { logboxElem.classList.remove('vpn'); }
if (logFilterBdc.checked == false) { logboxElem.classList.add('bdc'); } else { logboxElem.classList.remove('bdc'); }
if (logFilterRtr.checked == false) { logboxElem.classList.add('rtr'); } else { logboxElem.classList.remove('rtr'); }
if (logFilterLan.checked == false) { logboxElem.classList.add('lan'); } else { logboxElem.classList.remove('lan'); }
}
function stats() {
doStats();
hideIpInfo('stats');
displayFor('stats');
}
function doStats() {
document.getElementById("statsbox").innerHTML="Retrieving stats...";
getStats();
}
var statsTimer;
function getStats() {
var sq=document.getElementById('stats-dir').value+"-"+document.getElementById('stats-iface').value;
for (var cb of document.getElementsByName('statsKeys')) {
if (cb.checked) sq+='-'+cb.value;
}
aegis('stats', 'statsbox', sq);
clearTimeout(statsTimer);
statsTimer = setTimeout(function() { if (activeMenu == 'stats') { getStats(); } else { clearTimeout(statsTimer); } }, 60000);
}
function getProtoInfo(ptl,e) {
var url='/bolemo/cgi-bin/aegis_web.cgi?cmd=proto_info&arg='+ptl;
var ptlInfoReq = new XMLHttpRequest();
ptlInfoReq.onreadystatechange = function() { if ((this.readyState == 4) && (this.status == 200)) {
try { var ptlInfo = JSON.parse(this.responseText); } catch (e) { return; }
document.querySelector("#main-"+e+" > .overlay > .title").innerHTML=ptlInfo.title;
document.querySelector("#main-"+e+" > .overlay > .message").innerHTML=ptlInfo.message;
document.querySelector("#main-"+e+" > .overlay").style.display="block";
} }
ptlInfoReq.open("GET", url, true);
ptlInfoReq.send();
}
function getIpInfo(ip,e) {
var url='http://ip-api.com/json/'+ip+'?fields=status,message,continent,country,regionName,city,district,isp,org,as,reverse,mobile,proxy,hosting,query';
var ipApiReq = new XMLHttpRequest();
ipApiReq.onreadystatechange = function() { if ((this.readyState == 4) && (this.status == 200)) {
var ipApi = JSON.parse(this.responseText);
var ipApiTtl, ipApiMsg = "";
if (ipApi.status == 'success') {
if (ipApi.reverse != '') ipApi.reverse=" ("+ipApi.reverse+")";
if (ipApi.district != '') ipApi.district+=", ";
ipApiTtl = ipApi.query+ipApi.reverse;
if (ipApi.mobile) ipApiMsg+="<p><u>This is a mobile IP</u></p>";
if (ipApi.proxy) ipApiMsg+="<p><u>This is a proxy IP</u></p>";
if (ipApi.hosting) ipApiMsg+="<p><u>This is a hosting IP</u></p>";
ipApiMsg += "<p><strong>Location:</strong> "+ipApi.district+ipApi.city+', '+ipApi.regionName+', '+ipApi.country+', '+ipApi.continent+"</p>";
if (ipApi.isp != '') ipApiMsg += "<p><strong>ISP:</strong> "+ipApi.isp+"</p>";
if (ipApi.org != '') ipApiMsg += "<p><strong>Org.:</strong> "+ipApi.org+"</p>";
if (ipApi.as != '') ipApiMsg += "<p><strong>AS: </strong>"+ipApi.as+"</p>";
} else {
if (ipApi.status="private range") {
ipApiTtl = ipApi.query;
ipApiMsg = "<p>Private Range IP.</p><p>Likely to be bogon!</p>";
} else {
ipApiTtl = ipApi.query;
ipApiMsg = "<p>"+ipApi.status+"</p><p>"+ipApi.message+"</p>"
}
}
document.querySelector("#main-"+e+" > .overlay > .title").innerHTML=ipApiTtl;
document.querySelector("#main-"+e+" > .overlay > .message").innerHTML=ipApiMsg;
document.querySelector("#main-"+e+" > .overlay").style.display="block";
} }
ipApiReq.open("GET", url, true);
ipApiReq.send();
}
function hideIpInfo(e) {
document.querySelector("#main-"+e+" > .overlay").style.display="none";
}
function setIpInfoClick() {
document.onclick=function(elem){
elem=window.event? event.srcElement: elem.target;
if (elem.tagName == "LOG-RIP") getIpInfo(elem.innerHTML,"log");
if (elem.tagName == "LOG-PT") { var win = window.open("https://www.speedguide.net/port.php?port="+elem.innerHTML, '_blank'); win.focus(); }
if (elem.tagName == "LOG-PTL") getProtoInfo(elem.getAttribute('value'),"log");
if (elem.tagName == "STATS-RIP") getIpInfo(elem.innerHTML,"stats");
if (elem.tagName == "STATS-PTL") getProtoInfo(elem.getAttribute('value'),"stats");
if (elem.tagName == "STATS-PT") { var win = window.open("https://www.speedguide.net/port.php?port="+elem.innerHTML, '_blank'); win.focus(); }
}
}
function ipTest(ip) { return (typeof(ip) === 'string') && (ip.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)) && (ip.split('.').filter(octet => octet >= 0 && octet <= 255).length === 4); }
function testIp() {
var ipToTest = document.getElementById("check-ip").value;
if (ipTest(ipToTest)) {
aegis('check', 'main-tools', ipToTest, 'afterbegin');
} else { alert(ipToTest + 'is not a valid IP Address!'); }
}
function tools() {
displayFor('tools');
}
function sendCommand() {
var cmdCmd = document.getElementById("command-cmd").value;
var cmdLog = document.getElementById("command-log").value;
document.getElementById("main-command").innerHTML="Executing Aegis command...";
aegis('command', 'main-command', cmdCmd+':'+cmdLog);
}
function showCommandLog(value) {
switch (value) {
case 'down': var displayVal = true;
break;
default: var displayVal = false;
}
document.getElementById("command-log").disabled=displayVal;
}
function doList(list) {
displayFor('lists');
document.getElementById("main-lists").value="";
document.getElementById("lists-info").innerHTML="";
if (list == '-') {
document.querySelectorAll("#ctrl-lists > input").forEach(elem => elem.style.display="none");
document.getElementById('lists-list').value="-";
} else {
aegis("print_list", undefined, list, undefined, function(val) {
document.getElementById("lists-info").innerHTML=val.split('\n')[0];
document.getElementById("main-lists").value=val.substring(val.indexOf("\n") + 1);
document.querySelectorAll("#ctrl-lists > input").forEach(elem => elem.style.display="inline");
document.getElementById('lists-list').value=list;
});
}
}
function sendList(list) {
var listName;
switch (list) {
case 'src': listName="blocklists sources list"; break;
case 'abl': listName="custom global block list"; break;
case 'awl': listName="custom global bypass list"; break;
case 'wbl': listName="custom WAN only block list"; break;
case 'wwl': listName="custom WAN only bypass list"; break;
case 'tbl': listName="custom VPN only block list"; break;
case 'twl': listName="custom VPN only bypass list"; break;
default: alert ("Select a list first!"); return; break;
}
if (confirm("Are you sure you want to save "+listName+"?")) {
var url='/bolemo/cgi-bin/aegis_web.cgi?cmd=save_list&arg='+list;
var saveListReq = new XMLHttpRequest();
saveListReq.onreadystatechange = function() { if ((this.readyState == 4) && (this.status == 200)) {
if (this.responseText != 0) { alert ("Problem saving "+listName+"!"); }
doList(list);
} }
saveListReq.open("POST", url, true);
saveListReq.send(document.getElementById("main-lists").value);
} else { alert ("Saved of "+listName+" cancelled!"); }
}
function doDoc(doc) {
document.getElementById("main-doc").innerHTML = '';
var rmReq = new XMLHttpRequest();
rmReq.onreadystatechange = function() { if ((this.readyState == 4) && (this.status == 200)) {
document.getElementById("main-doc").innerHTML = this.responseText;
} }
rmReq.open("GET", 'aegis_data/'+doc+'.htm', true);
rmReq.send();
}
function doc() {
doDoc('README');
displayFor('doc');
}
function upgrade() {
displayFor('upgrade');
document.getElementById("main-upgrade").innerHTML = '';
}
function upgradeCallback() {
var mainUpgradeElem = document.getElementById("main-upgrade");
if (mainUpgradeElem.innerHTML.slice(-11).slice(0,8) == "Success!") {
mainUpgradeElem.insertAdjacentHTML('beforeend', 'Reloading page in 5 seconds...');
setTimeout(function() { window.location.reload(); }, 5000);
}
}
function doUpgrade() {
var upgradeCmd = document.getElementById("vers-cmd").value;
document.getElementById("main-upgrade").innerHTML="Processing Aegis upgrade...";
aegis('command', 'main-upgrade', upgradeCmd, undefined, upgradeCallback);
}
function ready() {
initCgi(); setIpInfoClick(); info();
switch (window.location.hash) {
case '#command': command(); break;
case '#log': log(); break;
case '#stats': stats(); break;
case '#tools': tools(); break;
case '#lists': doList('-'); break;
case '#debug': debug(); break;
case '#doc': doc(); break;
case '#status':
default:
status(); break;
}
}
</script>
</head>
<body onLoad="ready();">
<section>
<div id="header">
<h1>AEGIS</h1>
<div id="by">by bolemo</div>
<div id="info"></div>
<div style="clear: both; height: 0;"> </div>
</div>
<div id="menu">
<input type="radio" name="menu" id="menu-upgrade" onclick="upgrade();"><label for="menu-upgrade">UPGRADE</label>
<input type="radio" name="menu" checked id="menu-status" onclick="status();"><label for="menu-status">STATUS</label>
<input type="radio" name="menu" id="menu-command" onclick="command();"><label for="menu-command">COMMAND</label>
<input type="radio" name="menu" id="menu-log" onclick="log();"><label for="menu-log">LOG</label>
<input type="radio" name="menu" id="menu-stats" onclick="stats();"><label for="menu-stats">STATS</label>
<input type="radio" name="menu" id="menu-tools" onclick="tools();"><label for="menu-tools">TOOLS</label>
<input type="radio" name="menu" id="menu-lists" onclick="doList('-');"><label for="menu-lists">LISTS</label>
<input type="radio" name="menu" id="menu-debug" onclick="debug();"><label for="menu-debug">DEBUG</label>
<input type="radio" name="menu" id="menu-doc" onclick="doc();"><label for="menu-doc">DOC</label>
</div>
<div id="ctrl">
<div id="ctrl-status"></div>
<div id="ctrl-command" class="show">
COMMAND:
<select id="command-cmd" name="commandCmd" onchange="showCommandLog(this.value);">
<option value="refresh" selected>REFRESH directives then start aegis</option>
<option value="refresh_custom">REFRESH ONLY CUSTOM directives then start aegis</option>
<option value="up">SHIELD UP (start aegis)</option>
<option value="down">SHIELD DOWN (stop aegis)</option>
</select>
<select id="command-log" name="commandLog">
<option value="" selected>without changing logging</option>
<option value="on">with logging ENABLED</option>
<option value="off">with logging DISABLED</option>
</select>
<input type="submit" value="Submit" onclick="sendCommand();" />
</div>
<div id="ctrl-tools" class="show">
<label for="check-ip">CHECK IP:</label>
<input type="text" id="check-ip" name="check-ip" required minlength="7" maxlength="15" size="15" />
<input type="submit" value="Submit" onclick="testIp();" />
</div>
<div id="ctrl-log" class="show">
SHOW:
<input type="checkbox" name="logFilter" checked id="log-filter-incoming" onclick="logFilter();" /><label for="log-filter-incoming">INCOMING</label>
<input type="checkbox" name="logFilter" checked id="log-filter-outgoing" onclick="logFilter();" /><label for="log-filter-outgoing">OUTGOING</label>
<input type="checkbox" name="logFilter" checked id="log-filter-wan" onclick="logFilter();" /><label for="log-filter-wan">WAN</label>
<input type="checkbox" name="logFilter" checked id="log-filter-vpn" onclick="logFilter();" /><label for="log-filter-vpn">VPN</label>
<input type="checkbox" name="logFilter" checked id="log-filter-lan" onclick="logFilter();" /><label for="log-filter-lan">LAN</label>
<input type="checkbox" name="logFilter" checked id="log-filter-rtr" onclick="logFilter();" /><label for="log-filter-rtr">ROUTER</label>
<input type="checkbox" name="logFilter" checked id="log-filter-bdc" onclick="logFilter();" /><label for="log-filter-bdc">BROADCAST</label>
</div>
<div id="ctrl-stats" class="show">
<select id="stats-dir" name="statsDir" onchange="doStats();">
<option value="all" selected>BOTH WAYS</option>
<option value="in">INCOMING</option>
<option value="out">OUTGOING</option>
<option value="no">IGNORE WAY</option>
</select>
<select id="stats-iface" name="statsIface" onchange="doStats();">
<option value="all" selected>ALL INTERFACES</option>
<option value="wan">WAN</option>
<option value="vpn">VPN</option>
<option value="no">IGNORE INTERFACE</option>
</select>
<input type="checkbox" name="statsKeys" id="stats-keys-proto" value="proto" onclick="doStats();" /><label for="stats-keys-proto">PROTOCOL</label>
<span class="ext">REMOTE:</span>
<input type="checkbox" name="statsKeys" id="stats-keys-rip" value="rip" onclick="doStats();" checked /><label for="stats-keys-rip">IP</label>
<input type="checkbox" name="statsKeys" id="stats-keys-rpt" value="rpt" onclick="doStats();" /><label for="stats-keys-rpt">PORT</label>
<span class="int">LOCAL:</span>
<input type="checkbox" name="statsKeys" id="stats-keys-loc" value="loc" onclick="doStats();" /><label for="stats-keys-loc">DEVICE</label>
<input type="checkbox" name="statsKeys" id="stats-keys-lip" value="lip" onclick="doStats();" /><label for="stats-keys-lip">IP</label>
<input type="checkbox" name="statsKeys" id="stats-keys-lpt" value="lpt" onclick="doStats();" /><label for="stats-keys-lpt">PORT</label>
</div>
<div id="ctrl-lists" class="show list">
<select id="lists-list" name="listList" onchange="doList(document.getElementById('lists-list').value);">
<option value="-" selected disabled>PLEASE SELECT A LIST</option>
<optgroup label="Global lists">
<option value="src">Blocklists Sources</option>
<option value="abl">Custom global blacklist</option>
<option value="awl">Custom global whitelist</option>
</optgroup><optgroup label="WAN only lists">
<option value="wbl">Custom WAN blacklist</option>
<option value="wwl">Custom WAN whitelist</option>
</optgroup><optgroup label="VPN only lists">
<option value="tbl">Custom VPN blacklist</option>
<option value="twl">Custom VPN whitelist</option>
</optgroup>
</select>
<input type="button" value="Reload list" onclick="doList(document.getElementById('lists-list').value);" />
<input type="button" value="Save list" onclick="sendList(document.getElementById('lists-list').value);" />
<div id="lists-info"></div>
</div>
<div id="ctrl-upgrade" class="show">
<div id="vers-message"></div>
<select id="vers-cmd" name="versCmd">
<option value="upgrade">UPGRADE (WITHOUT RESTARTING AEGIS SHIELD)</option>
<option value="unset-upgrade-up" selected>UNSET, UPGRADE THEN RESTART[RECOMMENDED]</option>
</select>
<input type="submit" value="Submit" onclick="doUpgrade();" />
</div>
<div id="ctrl-debug"></div>
<div id="ctrl-doc" class="show">
<input type="button" value="Aegis Read Me" onclick="doDoc('README');" />
<input type="button" value="Web Companion" onclick="doDoc('WEB.README');" />
<input type="button" value="Change Log" onclick="doDoc('CHANGELOG');" />
<input type="button" value="Links" onclick="doDoc('LINKS');" />
</div>
</div>
<div id="main">
<div id="main-status" class="scroll"></div>
<pre id="main-command" class="scroll"></pre>
<div id="main-log" class="scroll"><div class="overlay"><div class="title"></div><div class="message"></div><input type="button" value="OK" onclick="hideIpInfo('log');" /></div><div id="logbox"></div></div>
<div id="main-stats" class="scroll"><div class="overlay"><div class="title"></div><div class="message"></div><input type="button" value="OK" onclick="hideIpInfo('stats');" /></div><div id="statsbox"></div></div>
<div id="main-tools" class="scroll"></div>
<textarea id="main-lists" class="list"></textarea>
<textarea id="main-debug" class="list" readonly></textarea>
<div id="main-doc" class="scroll"></div>
<pre id="main-upgrade" class="scroll"></pre>
</div>
</section>
</body>
</html>