Skip to content

Commit c53862f

Browse files
committed
Adjusting VPN configs
1 parent 6f41c82 commit c53862f

File tree

3 files changed

+174
-25
lines changed

3 files changed

+174
-25
lines changed

main/io.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,15 @@ exports.addVpn = (vpns, input1, input2, input3, input4, input5, input6, path, ty
107107
var zipLoc = tsDir
108108
var zipWrite = (zipLoc + "\\" + zipName);
109109
var nl = "\n"
110-
if (vpns == "ovpn") {
110+
if (vpns == "ovpn1") {
111111
var block = nl
112-
var com = input1+block+input2+block+input3
112+
var tag = "[ovpn-auth-user-pass]"
113+
var com = tag+block+input1+block+input2+block+input3
114+
}
115+
if (vpns == "ovpn2") {
116+
var block = nl
117+
var tag = "[ovpn-auth-user-pass-with-cert-key]"
118+
var com = tag+block+input1+block+input2+block+input3+block+input4
113119
}
114120
if (vpns == "pritunl") {
115121
var block = "[pritunl]"
@@ -121,7 +127,7 @@ exports.addVpn = (vpns, input1, input2, input3, input4, input5, input6, path, ty
121127
}
122128
if (vpns == "wg") {
123129
var block = "[wg]"
124-
var com = input1+block+input2+block+input3+block+input4+block+input5+block+input6
130+
var com = input1+block+input2+block+input3+block+input4+block+input5+block+input6+block
125131
}
126132
var zip = new AdmZip();
127133
zip.addFile("config.txt", Buffer.from(com, "utf8"), "");

renderer/js/vpn.js

Lines changed: 116 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ $("#pw").removeAttr("style").hide();
88
$("#processing").removeAttr("style").hide();
99

1010

11-
$("#OpenVPN").removeAttr("style").hide();
11+
$("#OpenVPN1").removeAttr("style").hide();
12+
$("#OpenVPN2").removeAttr("style").hide();
1213
$("#Pritunl").removeAttr("style").hide();
1314
$("#IPSec").removeAttr("style").hide();
1415
$("#WireGuard").removeAttr("style").hide();
@@ -17,36 +18,49 @@ $("#btn-gen-zip").removeAttr("style").hide();
1718

1819
$(document).ready(function(){
1920
$('#vpnSelect').on('change', function() {
20-
if ( this.value == 'ovpn') {
21+
if ( this.value == 'ovpn1') {
22+
$("#OpenVPN2").removeAttr("style").hide();
2123
$("#Pritunl").removeAttr("style").hide();
2224
$("#IPSec").removeAttr("style").hide();
2325
$("#WireGuard").removeAttr("style").hide();
24-
$("#OpenVPN").show();
26+
$("#OpenVPN1").show();
2527
$("#btn-gen-zip").show();
26-
console.log("OpenVPN selected")
28+
console.log("OpenVPN1 selected")
29+
} else if ( this.value == 'ovpn2') {
30+
$("#OpenVPN1").removeAttr("style").hide();
31+
$("#Pritunl").removeAttr("style").hide();
32+
$("#IPSec").removeAttr("style").hide();
33+
$("#WireGuard").removeAttr("style").hide();
34+
$("#OpenVPN2").show();
35+
$("#btn-gen-zip").show();
36+
console.log("OpenVPN2 selected")
2737
} else if( this.value == 'pritunl') {
28-
$("#OpenVPN").removeAttr("style").hide();
38+
$("#OpenVPN1").removeAttr("style").hide();
39+
$("#OpenVPN2").removeAttr("style").hide();
2940
$("#IPSec").removeAttr("style").hide();
3041
$("#WireGuard").removeAttr("style").hide();
3142
$("#Pritunl").show();
3243
$("#btn-gen-zip").show();
3344
console.log("Pritunl selected")
3445
} else if( this.value == 'ipsec') {
35-
$("#OpenVPN").removeAttr("style").hide();
46+
$("#OpenVPN1").removeAttr("style").hide();
47+
$("#OpenVPN2").removeAttr("style").hide();
3648
$("#Pritunl").removeAttr("style").hide();
3749
$("#WireGuard").removeAttr("style").hide();
3850
$("#IPSec").show();
3951
$("#btn-gen-zip").show();
4052
console.log("IPSec selected")
4153
} else if( this.value == 'wg') {
42-
$("#OpenVPN").removeAttr("style").hide();
54+
$("#OpenVPN1").removeAttr("style").hide();
55+
$("#OpenVPN2").removeAttr("style").hide();
4356
$("#Pritunl").removeAttr("style").hide();
4457
$("#IPSec").removeAttr("style").hide();
4558
$("#WireGuard").show();
4659
$("#btn-gen-zip").show();
4760
console.log("WireGuard selected")
4861
} else {
49-
$("#OpenVPN").removeAttr("style").hide();
62+
$("#OpenVPN1").removeAttr("style").hide();
63+
$("#OpenVPN2").removeAttr("style").hide();
5064
$("#Pritunl").removeAttr("style").hide();
5165
$("#IPSec").removeAttr("style").hide();
5266
$("#WireGuard").removeAttr("style").hide();
@@ -161,10 +175,14 @@ $("#btn-gen-zip").on("click", function (e) {
161175
.findPublicKey2(keyFile.name)
162176
.then((k) => {
163177
//console.log(k);
164-
if ($("#vpnSelect").val() == "ovpn") {
178+
if ($("#vpnSelect").val() == "ovpn1") {
165179
encryptWithKey3(k);
166180
const element = document.createElement("a");
167181
element.focus();
182+
} else if ($("#vpnSelect").val() == "ovpn2") {
183+
encryptWithKey6(k);
184+
const element = document.createElement("a");
185+
element.focus();
168186
} else if ($("#vpnSelect").val() == "pritunl") {
169187
encryptWithKey5(k);
170188
const element = document.createElement("a");
@@ -184,10 +202,14 @@ $("#btn-gen-zip").on("click", function (e) {
184202
})
185203
.catch(alert);
186204
} else {
187-
if ($("#vpnSelect").val() == "ovpn") {
205+
if ($("#vpnSelect").val() == "ovpn1") {
188206
encryptWithKey3(keyFile);
189207
const element = document.createElement("a");
190208
element.focus();
209+
} else if ($("#vpnSelect").val() == "ovpn2") {
210+
encryptWithKey6(keyFile);
211+
const element = document.createElement("a");
212+
element.focus();
191213
} else if ($("#vpnSelect").val() == "pritunl") {
192214
encryptWithKey5(keyFile);
193215
const element = document.createElement("a");
@@ -239,6 +261,64 @@ $("#btn-save-enc").on("click", function (e) {
239261
element.click();
240262
});
241263

264+
function encryptWithKey6(keyFile) {
265+
let vpns = $("#vpnSelect").val();
266+
console.log(vpns)
267+
let option1 = $("#ovpn-un2").val();
268+
//console.log(option1)
269+
let option2 = $("#ovpn-pw2").val();
270+
//console.log(option2)
271+
let option3 = $("#ovpn-key2").val();
272+
//console.log(option3)
273+
let option4 = $("#ovpn-config2").val();
274+
//console.log(option4)
275+
let option5 = "";
276+
//console.log(option5)
277+
let option6 = "";
278+
//console.log(option6)
279+
var validating = false;
280+
281+
if (!keyFile) {
282+
alert("Please select a public key from list or import from file");
283+
return;
284+
}
285+
console.log(keyFile);
286+
287+
const keyType = getKeyType(keyFile);
288+
if (keyType < 0) {
289+
alert(
290+
"Unknown key file format. Please use *.key for binary or *.asc for armored ASCII"
291+
);
292+
return;
293+
}
294+
295+
if (option3 == "") {
296+
alert(
297+
"Certificate Password is required"
298+
);
299+
setTimeout(function(){
300+
$("#ovpn-key2").focus();
301+
validating = false;
302+
}, 1);
303+
return;
304+
}
305+
306+
if (option4 == "") {
307+
alert(
308+
"Config is required"
309+
);
310+
setTimeout(function(){
311+
$("#ovpn-config2").focus();
312+
validating = false;
313+
}, 1);
314+
return;
315+
}
316+
317+
window.api
318+
.writeVpn(vpns, option1, option2, option3, option4, option5, option6, keyFile.path, keyType == 0)
319+
.catch(alert);
320+
}
321+
242322
function encryptWithKey5(keyFile) {
243323
let vpns = $("#vpnSelect").val();
244324
console.log(vpns)
@@ -325,11 +405,11 @@ function encryptWithKey4(keyFile) {
325405
function encryptWithKey3(keyFile) {
326406
let vpns = $("#vpnSelect").val();
327407
console.log(vpns)
328-
let option1 = $("#ovpn-un").val();
408+
let option1 = $("#ovpn-un1").val();
329409
//console.log(option1)
330-
let option2 = $("#ovpn-pw").val();
410+
let option2 = $("#ovpn-pw1").val();
331411
//console.log(option2)
332-
let option3 = $("#ovpn-config").val();
412+
let option3 = $("#ovpn-config1").val();
333413
//console.log(option3)
334414
let option4 = "";
335415
//console.log(option4)
@@ -353,12 +433,34 @@ function encryptWithKey3(keyFile) {
353433
return;
354434
}
355435

436+
if (option1 == "") {
437+
alert(
438+
"Username is required"
439+
);
440+
setTimeout(function(){
441+
$("#ovpn-un1").focus();
442+
validating = false;
443+
}, 1);
444+
return;
445+
}
446+
447+
if (option2 == "") {
448+
alert(
449+
"Password is required"
450+
);
451+
setTimeout(function(){
452+
$("#ovpn-pw1").focus();
453+
validating = false;
454+
}, 1);
455+
return;
456+
}
457+
356458
if (option3 == "") {
357459
alert(
358460
"Config is required"
359461
);
360462
setTimeout(function(){
361-
$("#ovpn-config").focus();
463+
$("#ovpn-config1").focus();
362464
validating = false;
363465
}, 1);
364466
return;

renderer/views/vpn.html

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,76 @@ <h4>VPN Config Encryption:</h4>
2929
<label for="vpnSelect" class="form-label mt-4">Select VPN Type</label>
3030
<select class="form-select" id="vpnSelect">
3131
<option selected>VPN Type...</option>
32-
<option value="ovpn">OpenVPN</option>
32+
<option value="ovpn1">OpenVPN</option>
33+
<option value="ovpn2">OpenVPN w/Certificate Password</option>
3334
<option value="pritunl">Pritunl</option>
3435
<option value="ipsec">IPSec</option>
3536
<option value="wg">WireGuard</option>
3637
</select>
3738
<hr>
38-
<div id="OpenVPN">
39-
<label for="ovpn-un" class="form-label">Please enter your vpn username (optional): </label>
39+
<div id="OpenVPN1">
40+
<label for="ovpn-un1" class="form-label">Please enter your vpn username (required): </label>
4041
<input class="form-control"
4142
type="text"
4243
name="full-name"
43-
id="ovpn-un"
44+
id="ovpn-un1"
4445
placeholder="OpenVPN Username"
4546
required
4647
/><br />
47-
<label for="ovpn-pw" class="form-label">Please enter your vpn password (optional): </label>
48+
<label for="ovpn-pw1" class="form-label">Please enter your vpn password (required): </label>
4849
<input class="form-control"
4950
type="password"
5051
name="full-name"
51-
id="ovpn-pw"
52+
id="ovpn-pw1"
5253
placeholder="OpenVPN Password"
5354
required
5455
/><br />
55-
<label for="ovpn-config">Please paste your vpn config (required): </label><br />
56+
<label for="ovpn-config1">Please paste your vpn config (required): </label><br />
5657
<textarea
5758
class="form-control"
5859
rows="5"
5960
cols="30"
60-
id="ovpn-config"
61+
id="ovpn-config1"
62+
placeholder="VPN Config"
63+
autofocus
64+
required
65+
></textarea>
66+
<br /><br />
67+
<!-- <div>
68+
<button class="btn btn-primary btn-lg" id="btn-gen-zip">Generate & Save Config</button>
69+
</div> -->
70+
</div>
71+
<div id="OpenVPN2">
72+
<label for="ovpn-un2" class="form-label">Please enter your vpn username (optional): </label>
73+
<input class="form-control"
74+
type="text"
75+
name="full-name"
76+
id="ovpn-un2"
77+
placeholder="OpenVPN Username"
78+
required
79+
/><br />
80+
<label for="ovpn-pw2" class="form-label">Please enter your vpn password (optional): </label>
81+
<input class="form-control"
82+
type="password"
83+
name="full-name"
84+
id="ovpn-pw2"
85+
placeholder="OpenVPN Password"
86+
required
87+
/><br />
88+
<label for="ovpn-key2" class="form-label">Please enter your vpn certificate password (required): </label>
89+
<input class="form-control"
90+
type="password"
91+
name="full-name"
92+
id="ovpn-key2"
93+
placeholder="OpenVPN Certificate Password"
94+
required
95+
/><br />
96+
<label for="ovpn-config2">Please paste your vpn config (required): </label><br />
97+
<textarea
98+
class="form-control"
99+
rows="5"
100+
cols="30"
101+
id="ovpn-config2"
61102
placeholder="VPN Config"
62103
autofocus
63104
required

0 commit comments

Comments
 (0)