File tree 1 file changed +16
-4
lines changed
src/static/app/src/components/configurationComponents/newPeersComponents
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,24 @@ export default {
30
30
this .data .private_key = this .keypair .privateKey ;
31
31
this .data .public_key = this .keypair .publicKey ;
32
32
},
33
+ testKey (key ){
34
+ const reg = / ^ [A-Za-z0-9 +/] {43} =? =? $ / ;
35
+ return reg .test (key)
36
+ },
33
37
checkMatching (){
34
38
try {
35
- if (window .wireguard .generatePublicKey (this .keypair .privateKey )
36
- !== this .keypair .publicKey ){
37
- this .error = true ;
38
- this .dashboardStore .newMessage (" WGDashboard" , " Private Key and Public Key does not match." , " danger" );
39
+ if (this .keypair .privateKey ){
40
+ if (this .testKey (this .keypair .privateKey )){
41
+ this .keypair .publicKey = window .wireguard .generatePublicKey (this .keypair .privateKey )
42
+ if (window .wireguard .generatePublicKey (this .keypair .privateKey )
43
+ !== this .keypair .publicKey ){
44
+ this .error = true ;
45
+ this .dashboardStore .newMessage (" WGDashboard" , " Private Key and Public Key does not match." , " danger" );
46
+ }else {
47
+ this .data .private_key = this .keypair .privateKey
48
+ this .data .public_key = this .keypair .publicKey
49
+ }
50
+ }
39
51
}
40
52
}catch (e){
41
53
this .error = true ;
You can’t perform that action at this time.
0 commit comments