@@ -10,24 +10,34 @@ $("#processing").removeAttr("style").hide();
1010
1111$ ( "#OpenVPN" ) . removeAttr ( "style" ) . hide ( ) ;
1212$ ( "#IPSec" ) . removeAttr ( "style" ) . hide ( ) ;
13+ $ ( "#WireGuard" ) . removeAttr ( "style" ) . hide ( ) ;
1314$ ( "#btn-gen-zip" ) . removeAttr ( "style" ) . hide ( ) ;
1415
1516
1617$ ( document ) . ready ( function ( ) {
1718 $ ( '#vpnSelect' ) . on ( 'change' , function ( ) {
1819 if ( this . value == 'ovpn' ) {
1920 $ ( "#IPSec" ) . removeAttr ( "style" ) . hide ( ) ;
21+ $ ( "#WireGuard" ) . removeAttr ( "style" ) . hide ( ) ;
2022 $ ( "#OpenVPN" ) . show ( ) ;
2123 $ ( "#btn-gen-zip" ) . show ( ) ;
2224 console . log ( "OpenVPN selected" )
2325 } else if ( this . value == 'ipsec' ) {
2426 $ ( "#OpenVPN" ) . removeAttr ( "style" ) . hide ( ) ;
27+ $ ( "#WireGuard" ) . removeAttr ( "style" ) . hide ( ) ;
2528 $ ( "#IPSec" ) . show ( ) ;
2629 $ ( "#btn-gen-zip" ) . show ( ) ;
2730 console . log ( "IPSec selected" )
31+ } else if ( this . value == 'wg' ) {
32+ $ ( "#OpenVPN" ) . removeAttr ( "style" ) . hide ( ) ;
33+ $ ( "#IPSec" ) . removeAttr ( "style" ) . hide ( ) ;
34+ $ ( "#WireGuard" ) . show ( ) ;
35+ $ ( "#btn-gen-zip" ) . show ( ) ;
36+ console . log ( "WireGuard selected" )
2837 } else {
2938 $ ( "#OpenVPN" ) . removeAttr ( "style" ) . hide ( ) ;
3039 $ ( "#IPSec" ) . removeAttr ( "style" ) . hide ( ) ;
40+ $ ( "#WireGuard" ) . removeAttr ( "style" ) . hide ( ) ;
3141 $ ( "#btn-gen-zip" ) . removeAttr ( "style" ) . hide ( ) ;
3242 console . log ( "Nothing selected" )
3343 }
@@ -147,6 +157,10 @@ $("#btn-gen-zip").on("click", function (e) {
147157 encryptWithKey2 ( k ) ;
148158 const element = document . createElement ( "a" ) ;
149159 element . focus ( ) ;
160+ } else if ( $ ( "#vpnSelect" ) . val ( ) == "wg" ) {
161+ encryptWithKey4 ( k ) ;
162+ const element = document . createElement ( "a" ) ;
163+ element . focus ( ) ;
150164 } else {
151165 alert ( "VPN Type not found" ) ;
152166 return ;
@@ -162,6 +176,10 @@ $("#btn-gen-zip").on("click", function (e) {
162176 encryptWithKey2 ( keyFile ) ;
163177 const element = document . createElement ( "a" ) ;
164178 element . focus ( ) ;
179+ } else if ( $ ( "#vpnSelect" ) . val ( ) == "wg" ) {
180+ encryptWithKey4 ( keyFile ) ;
181+ const element = document . createElement ( "a" ) ;
182+ element . focus ( ) ;
165183 } else {
166184 alert ( "VPN Type not found" ) ;
167185 return ;
@@ -201,6 +219,42 @@ $("#btn-save-enc").on("click", function (e) {
201219 element . click ( ) ;
202220} ) ;
203221
222+ function encryptWithKey4 ( keyFile ) {
223+ let vpns = $ ( "#vpnSelect" ) . val ( ) ;
224+ console . log ( vpns )
225+ let option1 = $ ( "#wg-pubkey" ) . val ( ) ;
226+ //console.log(option1)
227+ let option2 = $ ( "#wg-pvtkey" ) . val ( ) ;
228+ //console.log(option2)
229+ let option3 = $ ( "#wg-ep-ip" ) . val ( ) ;
230+ //console.log(option3)
231+ let option4 = $ ( "#wg-ep-p" ) . val ( ) ;
232+ //console.log(option4)
233+ let option5 = $ ( "#wg-pskey" ) . val ( ) ;
234+ //console.log(option5)
235+ let option6 = $ ( "#wg-l-ip" ) . val ( ) ;
236+ //console.log(option6)
237+ var validating = false ;
238+
239+ if ( ! keyFile ) {
240+ alert ( "Please select a public key from list or import from file" ) ;
241+ return ;
242+ }
243+ console . log ( keyFile ) ;
244+
245+ const keyType = getKeyType ( keyFile ) ;
246+ if ( keyType < 0 ) {
247+ alert (
248+ "Unknown key file format. Please use *.key for binary or *.asc for armored ASCII"
249+ ) ;
250+ return ;
251+ }
252+
253+ window . api
254+ . writeVpn ( vpns , option1 , option2 , option3 , option4 , option5 , option6 , keyFile . path , keyType == 0 )
255+ . catch ( alert ) ;
256+ }
257+
204258function encryptWithKey3 ( keyFile ) {
205259 let vpns = $ ( "#vpnSelect" ) . val ( ) ;
206260 console . log ( vpns )
@@ -212,6 +266,10 @@ function encryptWithKey3(keyFile) {
212266 //console.log(option3)
213267 let option4 = $ ( "#ovpn-config" ) . val ( ) ;
214268 //console.log(option4)
269+ let option5 = "" ;
270+ //console.log(option5)
271+ let option6 = "" ;
272+ //console.log(option6)
215273 var validating = false ;
216274
217275 if ( ! keyFile ) {
@@ -240,7 +298,7 @@ function encryptWithKey3(keyFile) {
240298 }
241299
242300 window . api
243- . writeVpn ( vpns , option1 , option2 , option3 , option4 , keyFile . path , keyType == 0 )
301+ . writeVpn ( vpns , option1 , option2 , option3 , option4 , option5 , option6 , keyFile . path , keyType == 0 )
244302 . catch ( alert ) ;
245303}
246304
@@ -255,6 +313,10 @@ function encryptWithKey2(keyFile) {
255313 //console.log(option3)
256314 let option4 = $ ( "#ipsec-ip" ) . val ( ) ;
257315 //console.log(option4)
316+ let option5 = "" ;
317+ //console.log(option5)
318+ let option6 = "" ;
319+ //console.log(option6)
258320 var validating = false ;
259321
260322 if ( ! keyFile ) {
@@ -313,7 +375,7 @@ function encryptWithKey2(keyFile) {
313375 }
314376
315377 window . api
316- . writeVpn ( vpns , option1 , option2 , option3 , option4 , keyFile . path , keyType == 0 )
378+ . writeVpn ( vpns , option1 , option2 , option3 , option4 , option5 , option6 , keyFile . path , keyType == 0 )
317379 . catch ( alert ) ;
318380}
319381
0 commit comments