-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.html
615 lines (559 loc) · 23.6 KB
/
config.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
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
<!DOCTYPE html>
<html>
<head>
<title>VPN TV Configuration</title>
<style>
body {
display: flex;
justify-content: center;
max-width: 900px; /* Set the maximum width of the body content */
margin: 0 auto; /* Center the body content horizontally */
padding: 0 5%; /* Add padding to both left and right sides */
}
input, label, span, table, h1 {
font-family: monospace;
}
span {
color: #636262;
}
p {
font-family: monospace;
color: #000000;
margin-top: 0px;
margin-bottom: 0px;
}
h1 {
margin-bottom: 5px;
}
/* Add padding to both left and right sides for high-resolution screens */
@media only screen and (min-width: 1000px) {
body {
padding: 0;
}
}
details {
user-select: none;
}
details>summary span.icon {
width: 24px;
height: 24px;
transition: all 0.3s;
margin-left: 10px;
margin-top: -3px;
}
details[open] summary span.icon {
transform: rotate(90deg);
}
summary {
display: flex;
cursor: pointer;
}
summary::-webkit-details-marker {
display: none;
}
</style>
</head>
<body>
<div class="container">
<pre>
_____ _____ _____ _____ _____
| | | _ | | | |_ _| | |
| | | __| | | |_ | | | | |
\___/|__| |_|___|_| |_| \___/ </pre>
<h1>Main Configuration</h1>
<p>Standard configuration definitions.</p>
<form id="config-form1" method="POST" action="/save">
<table>
<tr>
<td></td>
<td>
<label for="ur_timezone" title="Your timezone for all services.">
<b>Timezone:</b>
</label>
<input type="text" name="ur_timezone" title="Your timezone for all services." placeholder="Local Timezone" value="{{.Config.URTimezone}}">
<span>  Define your <a href="https://ipapi.co/timezone" target="_blank">Time Zone</a></span>
</td>
</tr>
<tr>
<td></td>
<td>
<span>Local VPNTV Timezone. Used for various containers</span>
</td>
</tr>
<tr>
<td>
</td>
<td>
<label for="vpntv_ansible_user" title="The username used by Ansible to connect to the VPNTV.">
<b>Ansible User:</b>
</label>
<input type="text" name="vpntv_ansible_user" title="The username used by Ansible to connect to the VPNTV." placeholder="Current Linux username" value="{{.InventoryConfig.All.Hosts.Vpntv.AnsibleUser}}">
</td>
</tr>
<tr>
<td></td>
<td>
<span>Keep default, which is "pi". In most cases should be your local Linux user</span>
</td>
</tr>
</table>
<details>
<summary style="font-family: monospace; color: #000000;">
<span class="icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path d="m15.146 12.354-5.792 5.792a.5.5 0 0 1-.854-.353V6.207a.5.5 0 0 1 .854-.353l5.792 5.792a.5.5 0 0 1 0 .708Z"></path>
</svg>
</span> Additional Ansible parameters
</summary>
<table style="margin-left: 20px;">
<tr>
<td>
<input type="checkbox" style="visibility: hidden;" disabled>
</td>
<td>
<label for="vpntv_ansible_connection" title="The connection type used by Ansible to connect to the VPNTV">
<b>Ansible Connection:</b>
</label>
<input type="text" name="vpntv_ansible_connection" title="The connection type used by Ansible to connect to the VPNTV" placeholder="Local or ssh" value="{{.InventoryConfig.All.Hosts.Vpntv.AnsibleConnection}}">
</td>
</tr>
<tr>
<td></td>
<td>
<span>Keep default - "local", for local installations, or "ssh" for remote</span>
</td>
</tr>
<tr ansible-host="not-local">
<td>
<input type="checkbox" style="visibility: hidden;" disabled>
</td>
<td>
<label for="vpntv_ip" title="The IP address of the VPNTV">
<b>Ansible host IP:</b>
</label>
<input type="text" name="vpntv_ip" title="The IP address of the VPNTV" placeholder="IP of remote server" value="{{.InventoryConfig.All.Hosts.Vpntv.IP}}">
</td>
</tr>
<tr ansible-host="not-local">
<td></td>
<td>
<span>For "local" installations - does not make sense, for remote - set remote VPNTV IP</span>
</td>
</tr>
<tr>
<td>
 
</td>
<td>
<!-- Ansible Use -->
<label for="ansible_use" style="visibility: hidden;">o</label>
<input type="text" id="vpntv_ansible_use" name="vpntv_ansible_use" value="{{.InventoryConfig.All.Hosts.Vpntv.AnsibleUse}}" style="visibility: hidden;" >
</td>
</tr>
</table>
</details>
<h1>OpenVPN Client</h1>
<p>Classic OpenVPN Client Setup</p>
<table>
<tr>
<td>
<input type="checkbox" name="ovpn_client_enable" id="ovpn_client_enable" title="Enables OpenVPN Client container" {{if .Config.OpenVPNClient}}checked{{end}}>
</td>
<td>
<label for="ovpn_client_enable" title="Enables OpenVPN Client container"><b>Install OpenVPN Client</b></label>
</td>
<td>
<input type="checkbox" name="ovpnclient_remove" id="ovpnclient_remove" title="Removes OpenVPN Client container" {{if .Config.OvpnClientRemove}}checked{{end}}>
</td>
<td>
<label for="ovpnclient_remove" title="Removes OpenVPN Client container">Uninstall OpenVPN Client</label>
</td>
</tr>
</table>
</form> <!-- config-form1 -->
<form id="upload-form" action="/upload?type=openvpn" method="post" enctype="multipart/form-data">
<table>
<tr openvpn-client="config">
<td>
<input type="checkbox" style="visibility: hidden;" disabled>
</td>
<td>
<b><label for="ovpn_client_cert" title="Client.ovpn OpenVPN configuration profile">OpenVPN Client Configuration file:</label> </b>
<input type="file" name="file">
<input type="submit" value="Upload">
<p id="ovpn-success-message" style="display: none; margin-left: 10px;">File uploaded as:
<span>vpntv/client-ovpn/client.ovpn</span></p>
</td>
</tr>
</table>
</form> <!-- upload-form -->
<form id="secret-form" action="/upload?type=openvpn-secret" method="post" enctype="multipart/form-data">
<table>
<tr openvpn-client="config">
<td>
<input type="checkbox" style="visibility: hidden;" disabled>
</td>
<td>
<label for="ovpn_client_secret" title="Text file with client user and password. Check documentation">OpenVPN Client Secret:</label>
<input type="file" name="file" title="Text file with client user and password. Check documentation">
<input type="submit" value="Upload">
<p id="secret-success-message" style="display: none; margin-left: 10px;">File uploaded as:
<span>vpntv/client-ovpn/credentials.txt</span></p>
</td>
</tr>
</table>
</form> <!-- secret-form -->
<form id="config-form2" method="POST" action="/save">
<h1>VPNTV Configuration</h1>
<p>VPNTV configuration</p>
<table>
<tr>
<td>
<input type="checkbox" name="wifi2ethernet_enable" id="wifi2ethernet_enable" title="Enables WiFi 2 Ethernet VPNTV Configuration" {{if .Config.Wifi2EthEnable}}checked{{end}}>
</td>
<td>
<label for="wifi2ethernet_enable" title="Enables WiFi 2 Ethernet VPNTV Configuration"><b>WiFi 2 Ethernet</b></label>
</td>
<td></td>
<td> TV connects to VPNTV with Ethernet port.</td>
</tr>
<tr>
<td>
<input type="checkbox" name="ethernet2wifi_enable" id="ethernet2wifi_enable" title="Enables Ethernet 2 WiFi VPNTV Configuration" {{if .Config.Eth2WifiEnable}}checked{{end}}>
</td>
<td>
<label for="ethernet2wifi_enable" title="Enables Ethernet 2 WiFi VPNTV Configuration"><b>Ethernet 2 WiFi</b></label>
</td>
<td></td>
<td> TV connects via VPNTV WiFi, wile VPNTV connects to router with its Ethernet.</td>
</tr>
<tr ethernet2wifi="config">
<td></td>
<td>
<label for="wifi_interface_t1" title="WiFi Interface (don't change without purpose).">
WiFi Interface Name(E2W):
</label>
<input type="text" name="wifi_interface_t1" id="wifi_interface_t1" title="WiFi Interface (don't change without purpose)." placeholder="wlan0" value="{{.Config.WifiIntT1}}" maxlength="6" style="width: 50px;">
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="wifi2wifi_enable" id="wifi2wifi_enable" title="Enables WiFi 2 WiFi VPNTV Configuration" {{if .Config.Wifi2Wifi}}checked{{end}}>
</td>
<td>
<label for="wifi2wifi_enable" title="Enables WiFi 2 WiFi VPNTV Configuration"><b>WiFi 2 WiFi</b></label>
</td>
<td></td>
<td> Bridged WiFi connection.</td>
</tr>
<tr wifi2wifi="config">
<td>
<input type="checkbox" name="wifi_mod_enable" id="wifi_mod_enable" title="Install Kernel modules for WiFi to WiFi setup" {{if .Config.WifiModEnable}}checked{{end}}>
</td>
<td>
<label for="wifi_mod_enable" title="Install Kernel modules for WiFi to WiFi setup">Install WiFi kernel modules</label>
</td>
<td>
<input type="checkbox" name="wifi_module_remove" id="wifi_module_remove" title="Removes WiFi Modules" {{if .Config.WifiModuleRemove}}checked{{end}}>
</td>
<td>
<label for="wifi_module_remove" title="Removes WiFi Modules">Uninstall WiFi modules</label>
</td>
</tr>
<tr wifi2wifi="config">
<td></td>
<td>
<label for="wifi_interface_t2" title="WiFi Interface (don't change without purpose).">
Interface Name(W2W):
</label>
<input type="text" name="wifi_interface_t2" title="WiFi Interface (don't change without purpose)." placeholder="wlan1" value="{{.Config.WifiIntT2}}" maxlength="6" style="width: 50px;">
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="wifi_config_remove" id="wifi_config_remove" title="removes all types of VPNTV connections configuration and stop the serives" {{if .Config.WifiConfigRemove}}checked{{end}}>
</td>
<td>
<label for="wifi_config_remove" title="removes all types of VPNTV connections configuration and stop the serives"><b>Remove VPNTV and stop services</b></label>
</td>
</tr>
</table>
<h1>WiFi Configuration</h1>
<p>VPNTV WiFi Access Point configuration</p>
<table>
<tr>
<td></td>
<td>
<label for="wifi_ssid" title="New VPNTV WiFi Network Name.">
<b>WiFi AP Network Name:</b>
</label>
<input type="text" name="wifi_ssid" title="New VPNTV WiFi Network Name." placeholder="vpntv" value="{{.Config.WifiSsid}}">
</td>
</tr>
<tr>
<td></td>
<td>
<span>New WiFi network name to connect your TV to</span>
</td>
</tr>
<tr>
<td>
</td>
<td>
<label for="wifi_password" title="WiFi Password for new vpntv WiFi Network.">
<b>WiFi AP Network Password:</b>
</label>
<input type="text" name="wifi_password" title="WiFi Password for new vpntv WiFi Network." placeholder="Glory2Ukraine!" value="{{.Config.WifiPass}}">
</td>
</tr>
<tr>
<td></td>
<td>
<span>New WiFi network password to connect your TV to</span>
</td>
</tr>
<tr>
<td>
</td>
<td>
<label for="wifi_channel" title="WiFi Network channel to use.">
<b>WiFi AP Network Channel:</b>
</label>
<input type="text" name="wifi_channel" title="WiFi Network channel to use." placeholder="7" value="{{.Config.WifiChannel}}">
</td>
</tr>
<tr>
<td></td>
<td>
<span>New WiFi network channel to use (don't change without purpose)</span>
</td>
</tr>
</table>
</form> <!-- config-form2 -->
<br><button id="submit-btn" style="font-family: monospace; font-size: 2em; width: 100px; height: 40px;">Save</button>
<span id="save-message" style="display: none;">Configuration has been saved.</span>
<h1>Installation</h1>
<p>The installation process will take some time.<br> Once that's done, it'll be like you have a new <a href="https://github.com/d3vilh/vpntv" target="_blank">VPNTV</a> up and running.</p>
<span>Latest installation log will be saved in ~/vpntv/webinstall.log</span><br><br>
<form id="install-form" method="POST" action="/install">
<input type="submit" value="Install" style="font-size: 2em; width: 160px; height: 40px;" onclick="return confirm('Are you sure you want to Install?');">
<input type="submit" value="Uninstall" style="font-size: 2em; width: 160px; height: 40px;" onclick="return confirm('Are you sure you want to Uninstall?');">
</form>
<br>
<iframe id="output-iframe" src="webinstall.log" width="100%" height="300" scrolling="yes"></iframe><br>
<table style="margin: auto; visibility: hidden;">
<tr style="visibility: hidden;">
<td><b>Portainer:</b></td>
<td><a href="http://{{ .Config.IPAddress }}:9000" target="_blank">http://{{.Config.IPAddress}}:9000</a></td>
<td><b>   Monitoring:</b></td>
<td><a href="http://{{ .Config.IPAddress }}:3030" target="_blank">http://{{.Config.IPAddress}}:3030</a></td>
<td><b>   Prometheus:</b></td>
<td><a href="http://{{ .Config.IPAddress }}:9090" target="_blank">http://{{.Config.IPAddress}}:9090</a></td>
<td></td>
</tr>
</table>
<span style="font-size: 0.8em; display: block; margin: auto; text-align: center;">2023 by <a href="https://github.com/d3vilh" target="_blank">d3vilh</a> for <a href="https://github.com/d3vilh/vpntv" target="_blank">vpntv</a>.</span><br>
<script>
// File upload logic for upload-form
const uploadForm = document.getElementById('upload-form');
const uploadSuccessMessage = document.getElementById('ovpn-success-message');
uploadForm.addEventListener('submit', (event) => {
event.preventDefault();
uploadSuccessMessage.style.display = 'block';
});
// File upload logic for secret-form
const secretForm = document.getElementById('secret-form');
const secretSuccessMessage = document.getElementById('secret-success-message');
secretForm.addEventListener('submit', (event) => {
event.preventDefault();
secretSuccessMessage.style.display = 'block';
});
// Combine config-form1, config-form2, and config-form3 into one form and submit it
const saveMessage = document.getElementById('save-message');
document.getElementById('submit-btn').addEventListener('click', function(event) {
event.preventDefault();
var formData1 = new FormData(document.getElementById('config-form1'));
var formData2 = new FormData(document.getElementById('config-form2'));
var formData = new FormData();
for (var pair of formData1.entries()) {
formData.append(pair[0], pair[1]);
}
for (var pair of formData2.entries()) {
formData.append(pair[0], pair[1]);
}
var xhr = new XMLHttpRequest();
xhr.open('POST', '/save');
xhr.onload = function() {
// handle success response
console.log(xhr.responseText);
saveMessage.style.display = 'inline-block';
//alert("New configuration have been saved.");
};
xhr.onerror = function() {
alert("Something went wrong.");
// handle error response
};
xhr.send(formData);
});
// Auto refresh iframe for webinstall.log
const outputIframe = document.getElementById('output-iframe');
setInterval(() => {
outputIframe.src = 'webinstall.log?' + new Date().getTime();
outputIframe.onload = () => {
outputIframe.contentWindow.scrollTo(0, outputIframe.contentWindow.document.body.scrollHeight);
};
}, 3000);
// Hide/show rows based on ansible_connection value
const ansibleConnectionInput = document.querySelector('input[name="vpntv_ansible_connection"]');
const gatewayIpRows = document.querySelectorAll('tr[ansible-host="not-local"]');
// Hide the gateway IP rows by default
gatewayIpRows.forEach(row => row.style.display = 'none');
ansibleConnectionInput.addEventListener('input', () => {
if (ansibleConnectionInput.value !== 'local') {
gatewayIpRows.forEach(row => row.style.display = '');
} else {
gatewayIpRows.forEach(row => row.style.display = 'none');
}
});
// Hide/show rows based on OpenVPN Client enable value
const OpenVPNClientEnable = document.getElementById('ovpn_client_enable');
const OpenVPNClientConfigRows = document.querySelectorAll('tr[openvpn-client="config"]');
const removeOvpnClient = document.getElementById('ovpnclient_remove');
// Hide the OpenVPN Client config rows by default
OpenVPNClientConfigRows.forEach(row => row.style.display = 'none');
OpenVPNClientEnable.addEventListener('change', () => {
if (OpenVPNClientEnable.checked) {
removeOvpnClient.checked = false;
wifiConfigRemove.checked = false;
OpenVPNClientConfigRows.forEach(row => row.style.display = '');
} else {
OpenVPNClientConfigRows.forEach(row => row.style.display = 'none');
}
});
removeOvpnClient.addEventListener('change', () => {
if (removeOvpnClient.checked) {
OpenVPNClientEnable.checked = false;
OpenVPNClientConfigRows.forEach(row => row.style.display = 'none');
}
});
// Hide the VPNTV config rows based by logic
const eth2WifiEnable = document.getElementById('ethernet2wifi_enable');
const eth2WiFiConfig = document.querySelectorAll('tr[ethernet2wifi="config"]');
const wifi2Wifi = document.getElementById('wifi2wifi_enable');
const wifi2WifiConfig = document.querySelectorAll('tr[wifi2wifi="config"]');
// checkbox logic consts
const wifiModEnable = document.getElementById('wifi_mod_enable');
const wifiModuleRemove = document.getElementById('wifi_module_remove');
const wifiIntT2 = document.getElementById('wifi_interface_t2');
const wifi2EthEnable = document.getElementById('wifi2ethernet_enable');
const wifiConfigRemove = document.getElementById('wifi_config_remove');
// Hide the VPNTV config rows by default
eth2WiFiConfig.forEach(row => row.style.display = 'none');
wifi2WifiConfig.forEach(row => row.style.display = 'none');
// eth2WifiEnable checked show/hide rest option and Checkbox logic
eth2WifiEnable.addEventListener('change', () => {
if (eth2WifiEnable.checked) {
eth2WifiEnable.checked = true;
eth2WiFiConfig.forEach(row => row.style.display = '');
// checkbox logic
wifi2Wifi.checked = false;
wifiModEnable.checked = false;
wifi2EthEnable.checked = false;
wifiConfigRemove.checked = false;
} else {
eth2WifiEnable.checked = false;
eth2WiFiConfig.forEach(row => row.style.display = 'none');
}
});
// WiFi2WiFi checked show/hide rest option and Checkbox logic
wifi2Wifi.addEventListener('change', () => {
if (wifi2Wifi.checked) {
wifi2Wifi.checked = true;
wifi2WifiConfig.forEach(row => row.style.display = '');
eth2WiFiConfig.forEach(row => row.style.display = 'none');
// checkbox logic
eth2WifiEnable.checked = false;
wifi2EthEnable.checked = false;
wifiConfigRemove.checked = false;
} else {
wifi2Wifi.checked = false;
wifi2WifiConfig.forEach(row => row.style.display = 'none');
wifiModEnable.checked = false;
}
});
// WiFi2Ethernet checked show/hide rest option and Checkbox logic
wifi2EthEnable.addEventListener('change', () => {
if (wifi2EthEnable.checked) {
wifi2EthEnable.checked = true;
wifi2WifiConfig.forEach(row => row.style.display = 'none');
eth2WiFiConfig.forEach(row => row.style.display = 'none');
// checkbox logic
eth2WifiEnable.checked = false;
wifi2Wifi.checked = false;
wifiConfigRemove.checked = false;
} else {
wifi2EthEnable.checked = false;
wifiModEnable.checked = false;
}
});
// Remove checked show/hide rest option and Checkbox logic
wifiConfigRemove.addEventListener('change', () => {
if (wifiConfigRemove.checked) {
wifiConfigRemove.checked = true;
wifi2WifiConfig.forEach(row => row.style.display = 'none');
eth2WiFiConfig.forEach(row => row.style.display = 'none');
// checkbox logic
eth2WifiEnable.checked = false;
wifi2Wifi.checked = false;
wifi2EthEnable.checked = false;
wifiModEnable.checked = false;
OpenVPNClientEnable.checked = false;
} else {
wifiConfigRemove.checked = false;
}
});
// OVPN configuration upload section
document.addEventListener('DOMContentLoaded', () => {
const openvpnForm = document.getElementById('upload-form');
const secretForm = document.getElementById('secret-form');
openvpnForm.addEventListener('submit', (event) => {
event.preventDefault();
console.log("DBG: OpenVPN form submitted");
const formData = new FormData(openvpnForm);
fetch('/upload?type=openvpn', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});
});
if (secretForm) {
secretForm.addEventListener('submit', (event) => {
event.preventDefault();
console.log("DBG: OVPN Secret form submitted");
const formData = new FormData(secretForm);
fetch('/upload?type=openvpn-secret', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});
});
} else {
console.error("secret-upload-form not found");
}
});
</script>
</div>
</body>
</html>