@@ -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+
242322function encryptWithKey5 ( keyFile ) {
243323 let vpns = $ ( "#vpnSelect" ) . val ( ) ;
244324 console . log ( vpns )
@@ -325,11 +405,11 @@ function encryptWithKey4(keyFile) {
325405function 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 ;
0 commit comments