Skip to content

Commit

Permalink
Merge pull request #386 from donaldzou/v4.0.3-fix
Browse files Browse the repository at this point in the history
Update privatePublicKeyInput.vue
  • Loading branch information
donaldzou authored Sep 14, 2024
2 parents d35bd6e + b3edff9 commit 6f681db
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,24 @@ export default {
this.data.private_key = this.keypair.privateKey;
this.data.public_key = this.keypair.publicKey;
},
testKey(key){
const reg = /^[A-Za-z0-9+/]{43}=?=?$/;
return reg.test(key)
},
checkMatching(){
try{
if (window.wireguard.generatePublicKey(this.keypair.privateKey)
!== this.keypair.publicKey){
this.error = true;
this.dashboardStore.newMessage("WGDashboard", "Private Key and Public Key does not match.", "danger");
if(this.keypair.privateKey){
if(this.testKey(this.keypair.privateKey)){
this.keypair.publicKey = window.wireguard.generatePublicKey(this.keypair.privateKey)
if (window.wireguard.generatePublicKey(this.keypair.privateKey)
!== this.keypair.publicKey){
this.error = true;
this.dashboardStore.newMessage("WGDashboard", "Private Key and Public Key does not match.", "danger");
}else{
this.data.private_key = this.keypair.privateKey
this.data.public_key = this.keypair.publicKey
}
}
}
}catch (e){
this.error = true;
Expand Down

0 comments on commit 6f681db

Please sign in to comment.