From 40cad2637f88d8835b2ab16848b951816f228d4f Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Sat, 21 Sep 2024 00:08:37 +0800 Subject: [PATCH] Fixed auth req = false not working --- src/dashboard.py | 4 ++-- src/static/app/dist/assets/index.js | 2 +- src/static/app/src/router/index.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index 159297d..31a66d1 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -1505,8 +1505,8 @@ def API_ValidateAPIKey(): @app.route(f'{APP_PREFIX}/api/validateAuthentication', methods=["GET"]) def API_ValidateAuthentication(): if DashboardConfig.GetConfig("Server", "auth_req")[1]: - token = request.cookies.get("authToken") + "" - if (token == "" or "username" not in session or session["username"] != token): + token = request.cookies.get("authToken") + if (token is None or token == "" or "username" not in session or session["username"] != token): return ResponseObject(False, "Invalid authentication.") return ResponseObject(True) diff --git a/src/static/app/dist/assets/index.js b/src/static/app/dist/assets/index.js index 1fe3c79..405cf97 100644 --- a/src/static/app/dist/assets/index.js +++ b/src/static/app/dist/assets/index.js @@ -65,4 +65,4 @@ The chosen QR Code version cannot contain this amount of data. Minimum version required to store current data is: `+o+`. `);const r=yW(t,n,i),a=Cu.getSymbolSize(t),l=new cW(a);return gW(l,t),mW(l),_W(l,t),Dd(l,n,0),t>=7&&vW(l,t),bW(l,r),isNaN(s)&&(s=Mh.getBestMask(l,Dd.bind(null,l,n))),Mh.applyMask(s,l),Dd(l,n,s),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:s,segments:i}}T1.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let s=Md.M,i,o;return typeof n<"u"&&(s=Md.from(n.errorCorrectionLevel,Md.M),i=Yc.from(n.version),o=Mh.from(n.maskPattern),n.toSJISFunc&&Cu.setToSJISFunction(n.toSJISFunc)),xW(t,i,s,o)};var z1={},cp={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(o){return[o,o]}))),s.length===6&&s.push("F","F");const i=parseInt(s.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const i=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,o=s.width&&s.width>=21?s.width:void 0,r=s.scale||4;return{width:o,scale:o?4:r,margin:i,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,i){return i.width&&i.width>=s+i.margin*2?i.width/(s+i.margin*2):i.scale},e.getImageWidth=function(s,i){const o=e.getScale(s,i);return Math.floor((s+i.margin*2)*o)},e.qrToImageData=function(s,i,o){const r=i.modules.size,a=i.modules.data,l=e.getScale(r,o),c=Math.floor((r+o.margin*2)*l),u=o.margin*l,d=[o.color.light,o.color.dark];for(let f=0;f=u&&p>=u&&f"u"&&(!r||!r.getContext)&&(l=r,r=void 0),r||(c=s()),l=t.getOptions(l);const u=t.getImageWidth(o.modules.size,l),d=c.getContext("2d"),f=d.createImageData(u,u);return t.qrToImageData(f.data,o,l),n(d,c,u),d.putImageData(f,0,0),c},e.renderToDataURL=function(o,r,a){let l=a;typeof l>"u"&&(!r||!r.getContext)&&(l=r,r=void 0),l||(l={});const c=e.render(o,r,l),u=l.type||"image/png",d=l.rendererOpts||{};return c.toDataURL(u,d.quality)}})(z1);var Y1={};const kW=cp;function mv(e,t){const n=e.a/255,s=t+'="'+e.hex+'"';return n<1?s+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':s}function Od(e,t,n){let s=e+t;return typeof n<"u"&&(s+=" "+n),s}function SW(e,t,n){let s="",i=0,o=!1,r=0;for(let a=0;a0&&l>0&&e[a-1]||(s+=o?Od("M",l+n,.5+c+n):Od("m",i,0),i=0,o=!1),l+1':"",c="',u='viewBox="0 0 '+a+" "+a+'"',f=''+l+c+` `;return typeof s=="function"&&s(null,f),f};const $W=Fj,Dh=T1,K1=z1,AW=Y1;function up(e,t,n,s,i){const o=[].slice.call(arguments,1),r=o.length,a=typeof o[r-1]=="function";if(!a&&!$W())throw new Error("Callback required as last argument");if(a){if(r<2)throw new Error("Too few arguments provided");r===2?(i=n,n=t,t=s=void 0):r===3&&(t.getContext&&typeof i>"u"?(i=s,s=void 0):(i=s,s=n,n=t,t=void 0))}else{if(r<1)throw new Error("Too few arguments provided");return r===1?(n=t,t=s=void 0):r===2&&!t.getContext&&(s=n,n=t,t=void 0),new Promise(function(l,c){try{const u=Dh.create(n,s);l(e(u,t,s))}catch(u){c(u)}})}try{const l=Dh.create(n,s);i(null,e(l,t,s))}catch(l){i(l)}}Bo.create=Dh.create;Bo.toCanvas=up.bind(null,K1.render);Bo.toDataURL=up.bind(null,K1.renderToDataURL);Bo.toString=up.bind(null,function(e,t,n){return AW.render(e,n)});const CW={name:"peerQRCode",props:{peerConfigData:String},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfigData,e=>{e&&console.error(e)})}},EW={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0"},PW={class:"container d-flex h-100 w-100"},MW={class:"m-auto modal-dialog-centered dashboardModal justify-content-center"},TW={class:"card rounded-3 shadow"},DW={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},OW=h("h4",{class:"mb-0"},"QR Code",-1),IW={class:"card-body"},RW={id:"qrcode",class:"rounded-3 shadow",ref:"qrcode"};function LW(e,t,n,s,i,o){return D(),F("div",EW,[h("div",PW,[h("div",MW,[h("div",TW,[h("div",DW,[OW,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=r=>this.$emit("close"))})]),h("div",IW,[h("canvas",RW,null,512)])])])])])}const NW=ze(CW,[["render",LW]]),FW={name:"nameInput",props:{bulk:Boolean,data:Object,saving:Boolean}},BW=h("label",{for:"peer_name_textbox",class:"form-label"},[h("small",{class:"text-muted"},"Name")],-1),VW=["disabled"];function HW(e,t,n,s,i,o){return D(),F("div",{class:Ee({inactiveField:this.bulk})},[BW,Re(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving||this.bulk,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.name=r),id:"peer_name_textbox",placeholder:""},null,8,VW),[[We,this.data.name]])],2)}const jW=ze(FW,[["render",HW]]),WW={name:"privatePublicKeyInput",props:{data:Object,saving:Boolean,bulk:Boolean},setup(){return{dashboardStore:et()}},data(){return{keypair:{publicKey:"",privateKey:"",presharedKey:""},editKey:!1,error:!1}},methods:{genKeyPair(){this.editKey=!1,this.keypair=window.wireguard.generateKeypair(),this.data.private_key=this.keypair.privateKey,this.data.public_key=this.keypair.publicKey},testKey(e){return/^[A-Za-z0-9+/]{43}=?=?$/.test(e)},checkMatching(){try{this.keypair.privateKey&&this.testKey(this.keypair.privateKey)&&(this.keypair.publicKey=window.wireguard.generatePublicKey(this.keypair.privateKey),window.wireguard.generatePublicKey(this.keypair.privateKey)!==this.keypair.publicKey?(this.error=!0,this.dashboardStore.newMessage("WGDashboard","Private Key and Public Key does not match.","danger")):(this.data.private_key=this.keypair.privateKey,this.data.public_key=this.keypair.publicKey))}catch{this.error=!0,this.data.private_key="",this.data.public_key=""}}},mounted(){this.genKeyPair()},watch:{keypair:{deep:!0,handler(){this.error=!1,this.checkMatching()}}}},zW=h("label",{for:"peer_private_key_textbox",class:"form-label"},[h("small",{class:"text-muted"},[ye("Private Key "),h("code",null,"(Required for QR Code and Download)")])],-1),YW={class:"input-group"},KW=["disabled"],UW=["disabled"],qW=h("i",{class:"bi bi-arrow-repeat"},null,-1),GW=[qW],JW={class:"d-flex"},XW=h("label",{for:"public_key",class:"form-label"},[h("small",{class:"text-muted"},[ye("Public Key "),h("code",null,"(Required)")])],-1),QW={class:"form-check form-switch ms-auto"},ZW=["disabled"],ez=h("label",{class:"form-check-label",for:"enablePublicKeyEdit"},[h("small",null,"Edit")],-1),tz=["disabled"];function nz(e,t,n,s,i,o){return D(),F("div",{class:Ee(["d-flex gap-2 flex-column",{inactiveField:this.bulk}])},[h("div",null,[zW,h("div",YW,[Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-start-3",{"is-invalid":this.error}]),"onUpdate:modelValue":t[0]||(t[0]=r=>this.keypair.privateKey=r),disabled:!this.editKey||this.bulk,onBlur:t[1]||(t[1]=r=>this.checkMatching()),id:"peer_private_key_textbox"},null,42,KW),[[We,this.keypair.privateKey]]),h("button",{class:"btn btn-outline-info btn-sm rounded-end-3",onClick:t[2]||(t[2]=r=>this.genKeyPair()),disabled:this.bulk,type:"button",id:"button-addon2"},GW,8,UW)])]),h("div",null,[h("div",JW,[XW,h("div",QW,[Re(h("input",{class:"form-check-input",type:"checkbox",role:"switch",disabled:this.bulk,id:"enablePublicKeyEdit","onUpdate:modelValue":t[3]||(t[3]=r=>this.editKey=r)},null,8,ZW),[[In,this.editKey]]),ez])]),Re(h("input",{class:Ee(["form-control-sm form-control rounded-3",{"is-invalid":this.error}]),"onUpdate:modelValue":t[4]||(t[4]=r=>this.keypair.publicKey=r),onBlur:t[5]||(t[5]=r=>this.checkMatching()),disabled:!this.editKey||this.bulk,type:"text",id:"public_key"},null,42,tz),[[We,this.keypair.publicKey]])])],2)}const sz=ze(WW,[["render",nz]]),iz={name:"allowedIPsInput",props:{data:Object,saving:Boolean,bulk:Boolean,availableIp:void 0},data(){return{allowedIp:[],availableIpSearchString:"",customAvailableIp:"",allowedIpFormatError:!1}},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},computed:{searchAvailableIps(){return this.availableIpSearchString?this.availableIp.filter(e=>e.includes(this.availableIpSearchString)&&!this.data.allowed_ips.includes(e)):this.availableIp.filter(e=>!this.data.allowed_ips.includes(e))}},methods:{addAllowedIp(e){return this.store.checkCIDR(e)?(this.data.allowed_ips.push(e),this.customAvailableIp="",!0):(this.allowedIpFormatError=!0,this.dashboardStore.newMessage("WGDashboard","Allowed IP is invalid","danger"),!1)}},watch:{customAvailableIp(){this.allowedIpFormatError=!1},availableIp(){this.availableIp!==void 0&&this.availableIp.length>0&&this.addAllowedIp(this.availableIp[0])}},mounted(){}},pl=e=>(Ut("data-v-f69c864a"),e=e(),qt(),e),oz=pl(()=>h("label",{for:"peer_allowed_ip_textbox",class:"form-label"},[h("small",{class:"text-muted"},[ye("Allowed IPs "),h("code",null,"(Required)")])],-1)),rz=["onClick"],az=pl(()=>h("i",{class:"bi bi-x-circle-fill ms-1"},null,-1)),lz=[az],cz={class:"d-flex gap-2 align-items-center"},uz={class:"input-group"},dz=["disabled"],hz=["disabled"],fz=pl(()=>h("i",{class:"bi bi-plus-lg"},null,-1)),pz=[fz],gz=pl(()=>h("small",{class:"text-muted"},"or",-1)),mz={class:"dropdown flex-grow-1"},_z=["disabled"],vz=pl(()=>h("i",{class:"bi bi-filter-circle me-2"},null,-1)),bz={key:0,class:"dropdown-menu mt-2 shadow w-100 dropdown-menu-end rounded-3",style:{"overflow-y":"scroll","max-height":"270px",width:"300px !important"}},yz={class:"px-3 pb-2 pt-1"},wz=["onClick"],xz={class:"me-auto"},kz={key:0},Sz={class:"px-3 text-muted"};function $z(e,t,n,s,i,o){return D(),F("div",{class:Ee({inactiveField:this.bulk})},[oz,h("div",{class:Ee(["d-flex gap-2 flex-wrap",{"mb-2":this.data.allowed_ips.length>0}])},[$e(Wi,{name:"list"},{default:Me(()=>[(D(!0),F(Te,null,Ue(this.data.allowed_ips,(r,a)=>(D(),F("span",{class:"badge rounded-pill text-bg-success",key:r},[ye(_e(r)+" ",1),h("a",{role:"button",onClick:l=>this.data.allowed_ips.splice(a,1)},lz,8,rz)]))),128))]),_:1})],2),h("div",cz,[h("div",uz,[Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-start-3",{"is-invalid":this.allowedIpFormatError}]),placeholder:"Enter IP Address/CIDR","onUpdate:modelValue":t[0]||(t[0]=r=>i.customAvailableIp=r),disabled:n.bulk},null,10,dz),[[We,i.customAvailableIp]]),h("button",{class:"btn btn-outline-success btn-sm rounded-end-3",disabled:n.bulk||!this.customAvailableIp,onClick:t[1]||(t[1]=r=>this.addAllowedIp(this.customAvailableIp)),type:"button",id:"button-addon2"},pz,8,hz)]),gz,h("div",mz,[h("button",{class:"btn btn-outline-secondary btn-sm dropdown-toggle rounded-3 w-100",disabled:!n.availableIp||n.bulk,"data-bs-auto-close":"outside",type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[vz,ye(" Pick Available IP ")],8,_z),this.availableIp?(D(),F("ul",bz,[h("li",null,[h("div",yz,[Re(h("input",{class:"form-control form-control-sm rounded-3","onUpdate:modelValue":t[2]||(t[2]=r=>this.availableIpSearchString=r),placeholder:"Search..."},null,512),[[We,this.availableIpSearchString]])])]),(D(!0),F(Te,null,Ue(this.searchAvailableIps,r=>(D(),F("li",null,[h("a",{class:"dropdown-item d-flex",role:"button",onClick:a=>this.addAllowedIp(r)},[h("span",xz,[h("small",null,_e(r),1)])],8,wz)]))),256)),this.searchAvailableIps.length===0?(D(),F("li",kz,[h("small",Sz,'No available IP containing "'+_e(this.availableIpSearchString)+'"',1)])):re("",!0)])):re("",!0)])])],2)}const Az=ze(iz,[["render",$z],["__scopeId","data-v-f69c864a"]]),Cz={name:"dnsInput",props:{data:Object,saving:Boolean},data(){return{error:!1,dns:JSON.parse(JSON.stringify(this.data.DNS))}},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},methods:{checkDNS(){if(this.dns){let e=this.dns.split(",").map(t=>t.replaceAll(" ",""));for(let t in e)if(!this.store.regexCheckIP(e[t])){this.error||this.dashboardStore.newMessage("WGDashboard","DNS is invalid","danger"),this.error=!0,this.data.DNS="";return}this.error=!1,this.data.DNS=this.dns}}},watch:{dns(){this.checkDNS()}}},Ez=h("label",{for:"peer_DNS_textbox",class:"form-label"},[h("small",{class:"text-muted"},"DNS")],-1),Pz=["disabled"];function Mz(e,t,n,s,i,o){return D(),F("div",null,[Ez,Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-3",{"is-invalid":this.error}]),disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.dns=r),id:"peer_DNS_textbox"},null,10,Pz),[[We,this.dns]])])}const Tz=ze(Cz,[["render",Mz]]),Dz={name:"endpointAllowedIps",props:{data:Object,saving:Boolean},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},data(){return{endpointAllowedIps:JSON.parse(JSON.stringify(this.data.endpoint_allowed_ip)),error:!1}},methods:{checkAllowedIP(){let e=this.endpointAllowedIps.split(",").map(t=>t.replaceAll(" ",""));for(let t in e)if(!this.store.checkCIDR(e[t])){this.error||this.dashboardStore.newMessage("WGDashboard","Endpoint Allowed IP is invalid.","danger"),this.data.endpoint_allowed_ip="",this.error=!0;return}this.error=!1,this.data.endpoint_allowed_ip=this.endpointAllowedIps}},watch:{endpointAllowedIps(){this.checkAllowedIP()}}},Oz=h("label",{for:"peer_endpoint_allowed_ips",class:"form-label"},[h("small",{class:"text-muted"},[ye("Endpoint Allowed IPs "),h("code",null,"(Required)")])],-1),Iz=["disabled"];function Rz(e,t,n,s,i,o){return D(),F("div",null,[Oz,Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-3",{"is-invalid":i.error}]),disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.endpointAllowedIps=r),onBlur:t[1]||(t[1]=r=>this.checkAllowedIP()),id:"peer_endpoint_allowed_ips"},null,42,Iz),[[We,this.endpointAllowedIps]])])}const Lz=ze(Dz,[["render",Rz]]),Nz={name:"presharedKeyInput",props:{data:Object,saving:Boolean}},Fz=h("label",{for:"peer_preshared_key_textbox",class:"form-label"},[h("small",{class:"text-muted"},"Pre-Shared Key")],-1),Bz=["disabled"];function Vz(e,t,n,s,i,o){return D(),F("div",null,[Fz,Re(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.preshared_key=r),id:"peer_preshared_key_textbox"},null,8,Bz),[[We,this.data.preshared_key]])])}const Hz=ze(Nz,[["render",Vz]]),jz={name:"mtuInput",props:{data:Object,saving:Boolean}},Wz=h("label",{for:"peer_mtu",class:"form-label"},[h("small",{class:"text-muted"},"MTU")],-1),zz=["disabled"];function Yz(e,t,n,s,i,o){return D(),F("div",null,[Wz,Re(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.mtu=r),id:"peer_mtu"},null,8,zz),[[We,this.data.mtu]])])}const Kz=ze(jz,[["render",Yz]]),Uz={name:"persistentKeepAliveInput",props:{data:Object,saving:Boolean}},qz=h("label",{for:"peer_keep_alive",class:"form-label"},[h("small",{class:"text-muted"},"Persistent Keepalive")],-1),Gz=["disabled"];function Jz(e,t,n,s,i,o){return D(),F("div",null,[qz,Re(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.keepalive=r),id:"peer_keep_alive"},null,8,Gz),[[We,this.data.keepalive]])])}const Xz=ze(Uz,[["render",Jz]]),Qz={name:"bulkAdd",props:{saving:Boolean,data:Object,availableIp:void 0}},Zz={class:"form-check form-switch"},eY=["disabled"],tY=h("label",{class:"form-check-label me-2",for:"bulk_add"},[h("small",null,[h("strong",null,"Bulk Add")])],-1),nY=h("small",{class:"text-muted d-block"}," By adding peers by bulk, each peer's name will be auto generated, and Allowed IP will be assign to the next available IP. ",-1),sY=[nY],iY={key:0,class:"form-group"},oY=["max"],rY={class:"text-muted"};function aY(e,t,n,s,i,o){return D(),F("div",null,[h("div",Zz,[Re(h("input",{class:"form-check-input",type:"checkbox",role:"switch",disabled:!this.availableIp,id:"bulk_add","onUpdate:modelValue":t[0]||(t[0]=r=>this.data.bulkAdd=r)},null,8,eY),[[In,this.data.bulkAdd]]),tY]),h("p",{class:Ee({"mb-0":!this.data.bulkAdd})},sY,2),this.data.bulkAdd?(D(),F("div",iY,[Re(h("input",{class:"form-control form-control-sm rounded-3 mb-1",type:"number",min:"1",max:this.availableIp.length,"onUpdate:modelValue":t[1]||(t[1]=r=>this.data.bulkAddAmount=r),placeholder:"How many peers you want to add?"},null,8,oY),[[We,this.data.bulkAddAmount]]),h("small",rY,[ye(" You can add up to "),h("strong",null,_e(this.availableIp.length),1),ye(" peers ")])])):re("",!0)])}const lY=ze(Qz,[["render",aY]]),cY={name:"peerCreate",components:{BulkAdd:lY,PersistentKeepAliveInput:Xz,MtuInput:Kz,PresharedKeyInput:Hz,EndpointAllowedIps:Lz,DnsInput:Tz,AllowedIPsInput:Az,PrivatePublicKeyInput:sz,NameInput:jW},data(){return{data:{bulkAdd:!1,bulkAddAmount:"",name:"",allowed_ips:[],private_key:"",public_key:"",DNS:this.dashboardStore.Configuration.Peers.peer_global_dns,endpoint_allowed_ip:this.dashboardStore.Configuration.Peers.peer_endpoint_allowed_ip,keepalive:parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive),mtu:parseInt(this.dashboardStore.Configuration.Peers.peer_mtu),preshared_key:""},availableIp:void 0,availableIpSearchString:"",saving:!1,allowedIpDropdown:void 0}},mounted(){xt("/api/getAvailableIPs/"+this.$route.params.id,{},e=>{e.status&&(this.availableIp=e.data)})},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},methods:{peerCreate(){this.saving=!0,ft("/api/addPeers/"+this.$route.params.id,this.data,e=>{e.status?(this.$router.push(`/configuration/${this.$route.params.id}/peers`),this.dashboardStore.newMessage("Server","Peer create successfully","success")):this.dashboardStore.newMessage("Server",e.message,"danger"),this.saving=!1})}},computed:{allRequireFieldsFilled(){let e=!0;return this.data.bulkAdd?(this.data.bulkAddAmount.length===0||this.data.bulkAddAmount>this.availableIp.length)&&(e=!1):["allowed_ips","private_key","public_key","endpoint_allowed_ip","keepalive","mtu"].forEach(n=>{this.data[n].length===0&&(e=!1)}),e}},watch:{bulkAdd(e){e||(this.data.bulkAddAmount="")},"data.bulkAddAmount"(){this.data.bulkAddAmount>this.availableIp.length&&(this.data.bulkAddAmount=this.availableIp.length)}}},Eu=e=>(Ut("data-v-68bb9bc5"),e=e(),qt(),e),uY={class:"container"},dY={class:"mb-4"},hY=Eu(()=>h("h3",{class:"mb-0 text-body"},[h("i",{class:"bi bi-chevron-left"})],-1)),fY=Eu(()=>h("h3",{class:"text-body mb-0"},"Add Peers",-1)),pY={class:"d-flex flex-column gap-2"},gY=Eu(()=>h("hr",{class:"mb-0 mt-2"},null,-1)),mY=Eu(()=>h("hr",{class:"mb-0 mt-2"},null,-1)),_Y={class:"row"},vY={key:0,class:"col-sm"},bY={class:"col-sm"},yY={class:"col-sm"},wY={class:"d-flex mt-2"},xY=["disabled"],kY={key:0,class:"bi bi-plus-circle-fill me-2"};function SY(e,t,n,s,i,o){const r=je("RouterLink"),a=je("BulkAdd"),l=je("NameInput"),c=je("PrivatePublicKeyInput"),u=je("AllowedIPsInput"),d=je("EndpointAllowedIps"),f=je("DnsInput"),p=je("PresharedKeyInput"),m=je("MtuInput"),_=je("PersistentKeepAliveInput");return D(),F("div",uY,[h("div",dY,[$e(r,{to:"peers",is:"div",class:"d-flex align-items-center gap-4 text-decoration-none"},{default:Me(()=>[hY,fY]),_:1})]),h("div",pY,[$e(a,{saving:i.saving,data:this.data,availableIp:this.availableIp},null,8,["saving","data","availableIp"]),gY,this.data.bulkAdd?re("",!0):(D(),Ne(l,{key:0,saving:i.saving,data:this.data},null,8,["saving","data"])),this.data.bulkAdd?re("",!0):(D(),Ne(c,{key:1,saving:i.saving,data:i.data},null,8,["saving","data"])),this.data.bulkAdd?re("",!0):(D(),Ne(u,{key:2,availableIp:this.availableIp,saving:i.saving,data:i.data},null,8,["availableIp","saving","data"])),$e(d,{saving:i.saving,data:i.data},null,8,["saving","data"]),$e(f,{saving:i.saving,data:i.data},null,8,["saving","data"]),mY,h("div",_Y,[this.data.bulkAdd?re("",!0):(D(),F("div",vY,[$e(p,{saving:i.saving,data:i.data,bulk:this.data.bulkAdd},null,8,["saving","data","bulk"])])),h("div",bY,[$e(m,{saving:i.saving,data:i.data},null,8,["saving","data"])]),h("div",yY,[$e(_,{saving:i.saving,data:i.data},null,8,["saving","data"])])]),h("div",wY,[h("button",{class:"ms-auto btn btn-dark btn-brand rounded-3 px-3 py-2 shadow",disabled:!this.allRequireFieldsFilled||this.saving,onClick:t[0]||(t[0]=b=>this.peerCreate())},[this.saving?re("",!0):(D(),F("i",kY)),ye(" "+_e(this.saving?"Saving...":"Add"),1)],8,xY)])])])}const U1=ze(cY,[["render",SY],["__scopeId","data-v-68bb9bc5"]]),$Y={name:"scheduleDropdown",props:{options:Array,data:String,edit:!1},setup(e){e.data===void 0&&this.$emit("update",this.options[0].value)},computed:{currentSelection(){return this.options.find(e=>e.value===this.data)}}},AY={class:"dropdown scheduleDropdown"},CY={class:"dropdown-menu rounded-3 shadow",style:{"font-size":"0.875rem",width:"200px"}},EY=["onClick"],PY={key:0,class:"bi bi-check ms-auto"};function MY(e,t,n,s,i,o){return D(),F("div",AY,[h("button",{class:Ee(["btn btn-sm btn-outline-primary rounded-3",{"disabled border-transparent":!n.edit}]),type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[h("samp",null,_e(this.currentSelection.display),1)],2),h("ul",CY,[n.edit?(D(!0),F(Te,{key:0},Ue(this.options,r=>(D(),F("li",null,[h("a",{class:"dropdown-item d-flex align-items-center",role:"button",onClick:a=>e.$emit("update",r.value)},[h("samp",null,_e(r.display),1),r.value===this.currentSelection.value?(D(),F("i",PY)):re("",!0)],8,EY)]))),256)):re("",!0)])])}const q1=ze($Y,[["render",MY],["__scopeId","data-v-6a5aba2a"]]),TY={name:"schedulePeerJob",components:{VueDatePicker:ll,ScheduleDropdown:q1},props:{dropdowns:Array[Object],pjob:Object,viewOnly:!1},setup(e){const t=be({}),n=be(!1),s=be(!1);t.value=JSON.parse(JSON.stringify(e.pjob)),t.value.CreationDate||(n.value=!0,s.value=!0);const i=et();return{job:t,edit:n,newJob:s,store:i}},data(){return{inputType:void 0}},watch:{pjob:{deep:!0,immediate:!0,handler(e){this.edit||(this.job=JSON.parse(JSON.stringify(e)))}}},methods:{save(){this.job.Field&&this.job.Operator&&this.job.Action&&this.job.Value?ft("/api/savePeerScheduleJob/",{Job:this.job},e=>{e.status?(this.edit=!1,this.store.newMessage("Server","Job Saved!","success"),console.log(e.data),this.$emit("refresh",e.data[0]),this.newJob=!1):this.store.newMessage("Server",e.message,"danger")}):this.alert()},alert(){let e="animate__flash",t=this.$el.querySelectorAll(".scheduleDropdown"),n=this.$el.querySelectorAll("input");t.forEach(s=>s.classList.add("animate__animated",e)),n.forEach(s=>s.classList.add("animate__animated",e)),setTimeout(()=>{t.forEach(s=>s.classList.remove("animate__animated",e)),n.forEach(s=>s.classList.remove("animate__animated",e))},2e3)},reset(){this.job.CreationDate?(this.job=JSON.parse(JSON.stringify(this.pjob)),this.edit=!1):this.$emit("delete")},delete(){this.job.CreationDate&&ft("/api/deletePeerScheduleJob/",{Job:this.job},e=>{e.status?this.store.newMessage("Server","Job Deleted!","success"):(this.store.newMessage("Server",e.message,"danger"),this.$emit("delete"))}),this.$emit("delete")},parseTime(e){e&&(this.job.Value=Cn(e).format("YYYY-MM-DD HH:mm:ss"))}}},jr=e=>(Ut("data-v-811b149e"),e=e(),qt(),e),DY={class:"card-header bg-transparent text-muted border-0"},OY={key:0,class:"d-flex"},IY=jr(()=>h("strong",{class:"me-auto"},"Job ID",-1)),RY={key:1},LY=jr(()=>h("span",{class:"badge text-bg-warning"},"Unsaved Job",-1)),NY=[LY],FY={class:"card-body pt-1",style:{"font-family":"var(--bs-font-monospace)"}},BY={class:"d-flex gap-2 align-items-center mb-2"},VY=jr(()=>h("samp",null," if ",-1)),HY=jr(()=>h("samp",null," is ",-1)),jY=["disabled"],WY={class:"px-5 d-flex gap-2 align-items-center"},zY=jr(()=>h("samp",null,"then",-1)),YY={class:"d-flex gap-3"},KY=jr(()=>h("samp",null,"}",-1)),UY={key:0,class:"ms-auto d-flex gap-3"},qY={key:1,class:"ms-auto d-flex gap-3"};function GY(e,t,n,s,i,o){var l;const r=je("ScheduleDropdown"),a=je("VueDatePicker");return D(),F("div",{class:Ee(["card shadow-sm rounded-3 mb-2",{"border-warning-subtle":this.newJob}])},[h("div",DY,[this.newJob?(D(),F("small",RY,NY)):(D(),F("small",OY,[IY,h("samp",null,_e(this.job.JobID),1)]))]),h("div",FY,[h("div",BY,[VY,$e(r,{edit:s.edit,options:this.dropdowns.Field,data:this.job.Field,onUpdate:t[0]||(t[0]=c=>{this.job.Field=c})},null,8,["edit","options","data"]),HY,$e(r,{edit:s.edit,options:this.dropdowns.Operator,data:this.job.Operator,onUpdate:t[1]||(t[1]=c=>this.job.Operator=c)},null,8,["edit","options","data"]),this.job.Field==="date"?(D(),Ne(a,{key:0,is24:!0,"min-date":new Date,"model-value":this.job.Value,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",clearable:!1,disabled:!s.edit,dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","disabled","dark"])):Re((D(),F("input",{key:1,class:"form-control form-control-sm form-control-dark rounded-3 flex-grow-1",disabled:!s.edit,"onUpdate:modelValue":t[2]||(t[2]=c=>this.job.Value=c),style:{width:"auto"}},null,8,jY)),[[We,this.job.Value]]),h("samp",null,_e((l=this.dropdowns.Field.find(c=>c.value===this.job.Field))==null?void 0:l.unit)+" { ",1)]),h("div",WY,[zY,$e(r,{edit:s.edit,options:this.dropdowns.Action,data:this.job.Action,onUpdate:t[3]||(t[3]=c=>this.job.Action=c)},null,8,["edit","options","data"])]),h("div",YY,[KY,this.edit?(D(),F("div",qY,[h("a",{role:"button",class:"text-secondary text-decoration-none",onClick:t[6]||(t[6]=c=>this.reset())},"[C] Cancel"),h("a",{role:"button",class:"text-primary ms-auto text-decoration-none",onClick:t[7]||(t[7]=c=>this.save())},"[S] Save")])):(D(),F("div",UY,[h("a",{role:"button",class:"ms-auto text-decoration-none",onClick:t[4]||(t[4]=c=>this.edit=!0)},"[E] Edit"),h("a",{role:"button",onClick:t[5]||(t[5]=c=>this.delete()),class:"text-danger text-decoration-none"},"[D] Delete")]))])])],2)}const G1=ze(TY,[["render",GY],["__scopeId","data-v-811b149e"]]),JY={name:"peerJobs",setup(){return{store:Bn()}},props:{selectedPeer:Object},components:{SchedulePeerJob:G1,ScheduleDropdown:q1},data(){return{}},methods:{deleteJob(e){this.selectedPeer.jobs=this.selectedPeer.jobs.filter(t=>t.JobID!==e.JobID)},addJob(){this.selectedPeer.jobs.unshift(JSON.parse(JSON.stringify({JobID:Ts().toString(),Configuration:this.selectedPeer.configuration.Name,Peer:this.selectedPeer.id,Field:this.store.PeerScheduleJobs.dropdowns.Field[0].value,Operator:this.store.PeerScheduleJobs.dropdowns.Operator[0].value,Value:"",CreationDate:"",ExpireDate:"",Action:this.store.PeerScheduleJobs.dropdowns.Action[0].value})))}}},dp=e=>(Ut("data-v-31a1606a"),e=e(),qt(),e),XY={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},QY={class:"container d-flex h-100 w-100"},ZY={class:"m-auto modal-dialog-centered dashboardModal"},eK={class:"card rounded-3 shadow",style:{width:"700px"}},tK={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},nK=dp(()=>h("h4",{class:"mb-0 fw-normal"},[ye("Schedule Jobs "),h("strong")],-1)),sK={class:"card-body px-4 pb-4 pt-2 position-relative"},iK={class:"d-flex align-items-center mb-3"},oK=dp(()=>h("i",{class:"bi bi-plus-lg me-2"},null,-1)),rK={class:"card shadow-sm",key:"none",style:{height:"153px"}},aK=dp(()=>h("div",{class:"card-body text-muted text-center d-flex"},[h("h6",{class:"m-auto"},"This peer does not have any job yet.")],-1)),lK=[aK];function cK(e,t,n,s,i,o){const r=je("SchedulePeerJob");return D(),F("div",XY,[h("div",QY,[h("div",ZY,[h("div",eK,[h("div",tK,[nK,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),h("div",sK,[h("div",iK,[h("button",{class:"btn bg-primary-subtle border-1 border-primary-subtle text-primary-emphasis rounded-3 shadow",onClick:t[1]||(t[1]=a=>this.addJob())},[oK,ye(" Job ")])]),$e(Wi,{name:"schedulePeerJobTransition",tag:"div",class:"position-relative"},{default:Me(()=>[(D(!0),F(Te,null,Ue(this.selectedPeer.jobs,(a,l)=>(D(),Ne(r,{onRefresh:t[2]||(t[2]=c=>this.$emit("refresh")),onDelete:c=>this.deleteJob(a),dropdowns:this.store.PeerScheduleJobs.dropdowns,key:a.JobID,pjob:a},null,8,["onDelete","dropdowns","pjob"]))),128)),this.selectedPeer.jobs.length===0?(D(),F("div",rK,lK)):re("",!0)]),_:1})])])])])])}const uK=ze(JY,[["render",cK],["__scopeId","data-v-31a1606a"]]),dK={name:"peerJobsAllModal",setup(){return{store:Bn()}},components:{SchedulePeerJob:G1},props:{configurationPeers:Array[Object]},methods:{getuuid(){return Ts()}},computed:{getAllJobs(){return this.configurationPeers.filter(e=>e.jobs.length>0)}}},hK={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},fK={class:"container d-flex h-100 w-100"},pK={class:"m-auto modal-dialog-centered dashboardModal"},gK={class:"card rounded-3 shadow",style:{width:"700px"}},mK={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},_K=h("h4",{class:"mb-0 fw-normal"},"All Active Jobs ",-1),vK={class:"card-body px-4 pb-4 pt-2"},bK={key:0,class:"accordion",id:"peerJobsLogsModalAccordion"},yK={class:"accordion-header"},wK=["data-bs-target"],xK={key:0},kK={class:"text-muted"},SK=["id"],$K={class:"accordion-body"},AK={key:1,class:"card shadow-sm",style:{height:"153px"}},CK=h("div",{class:"card-body text-muted text-center d-flex"},[h("h6",{class:"m-auto"},"No active job at the moment.")],-1),EK=[CK];function PK(e,t,n,s,i,o){const r=je("SchedulePeerJob");return D(),F("div",hK,[h("div",fK,[h("div",pK,[h("div",gK,[h("div",mK,[_K,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),h("div",vK,[this.getAllJobs.length>0?(D(),F("div",bK,[(D(!0),F(Te,null,Ue(this.getAllJobs,(a,l)=>(D(),F("div",{class:"accordion-item",key:a.id},[h("h2",yK,[h("button",{class:"accordion-button collapsed",type:"button","data-bs-toggle":"collapse","data-bs-target":"#collapse_"+l},[h("small",null,[h("strong",null,[a.name?(D(),F("span",xK,_e(a.name)+" • ",1)):re("",!0),h("samp",kK,_e(a.id),1)])])],8,wK)]),h("div",{id:"collapse_"+l,class:"accordion-collapse collapse","data-bs-parent":"#peerJobsLogsModalAccordion"},[h("div",$K,[(D(!0),F(Te,null,Ue(a.jobs,c=>(D(),Ne(r,{onDelete:t[1]||(t[1]=u=>this.$emit("refresh")),onRefresh:t[2]||(t[2]=u=>this.$emit("refresh")),dropdowns:this.store.PeerScheduleJobs.dropdowns,viewOnly:!0,key:c.JobID,pjob:c},null,8,["dropdowns","pjob"]))),128))])],8,SK)]))),128))])):(D(),F("div",AK,EK))])])])])])}const MK=ze(dK,[["render",PK]]),TK={name:"peerJobsLogsModal",props:{configurationInfo:Object},data(){return{dataLoading:!0,data:[],logFetchTime:void 0,showLogID:!1,showJobID:!0,showSuccessJob:!0,showFailedJob:!0,showLogAmount:10}},async mounted(){await this.fetchLog()},methods:{async fetchLog(){this.dataLoading=!0,await xt(`/api/getPeerScheduleJobLogs/${this.configurationInfo.Name}`,{},e=>{this.data=e.data,this.logFetchTime=Cn().format("YYYY-MM-DD HH:mm:ss"),this.dataLoading=!1})}},computed:{getLogs(){return this.data.filter(e=>this.showSuccessJob&&e.Status==="1"||this.showFailedJob&&e.Status==="0")},showLogs(){return this.getLogs.slice(0,this.showLogAmount)}}},DK={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},OK={class:"container-fluid d-flex h-100 w-100"},IK={class:"m-auto mt-0 modal-dialog-centered dashboardModal",style:{width:"100%"}},RK={class:"card rounded-3 shadow w-100"},LK={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},NK=h("h4",{class:"mb-0"},"Jobs Logs",-1),FK={class:"card-body px-4 pb-4 pt-2"},BK={key:0},VK={class:"mb-2 d-flex gap-3"},HK=h("i",{class:"bi bi-arrow-clockwise me-2"},null,-1),jK={class:"d-flex gap-3 align-items-center"},WK=h("span",{class:"text-muted"},"Filter",-1),zK={class:"form-check"},YK=h("label",{class:"form-check-label",for:"jobLogsShowSuccessCheck"},[h("span",{class:"badge text-success-emphasis bg-success-subtle"},"Success")],-1),KK={class:"form-check"},UK=h("label",{class:"form-check-label",for:"jobLogsShowFailedCheck"},[h("span",{class:"badge text-danger-emphasis bg-danger-subtle"},"Failed")],-1),qK={class:"d-flex gap-3 align-items-center ms-auto"},GK=h("span",{class:"text-muted"},"Display",-1),JK={class:"form-check"},XK=h("label",{class:"form-check-label",for:"jobLogsShowJobIDCheck"}," Job ID ",-1),QK={class:"form-check"},ZK=h("label",{class:"form-check-label",for:"jobLogsShowLogIDCheck"}," Log ID ",-1),eU={class:"table"},tU=h("th",{scope:"col"},"Date",-1),nU={key:0,scope:"col"},sU={key:1,scope:"col"},iU=h("th",{scope:"col"},"Status",-1),oU=h("th",{scope:"col"},"Message",-1),rU={style:{"font-size":"0.875rem"}},aU={scope:"row"},lU={key:0},cU={class:"text-muted"},uU={key:1},dU={class:"text-muted"},hU={class:"d-flex gap-2"},fU=h("i",{class:"bi bi-chevron-down me-2"},null,-1),pU=h("i",{class:"bi bi-chevron-up me-2"},null,-1),gU={key:1,class:"d-flex align-items-center flex-column"},mU=h("div",{class:"spinner-border text-body",role:"status"},[h("span",{class:"visually-hidden"},"Loading...")],-1),_U=[mU];function vU(e,t,n,s,i,o){return D(),F("div",DK,[h("div",OK,[h("div",IK,[h("div",RK,[h("div",LK,[NK,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=r=>this.$emit("close"))})]),h("div",FK,[this.dataLoading?(D(),F("div",gU,_U)):(D(),F("div",BK,[h("p",null,"Updated at: "+_e(this.logFetchTime),1),h("div",VK,[h("button",{onClick:t[1]||(t[1]=r=>this.fetchLog()),class:"btn btn-sm rounded-3 shadow-sm text-info-emphasis bg-info-subtle border-1 border-info-subtle me-1"},[HK,ye(" Refresh ")]),h("div",jK,[WK,h("div",zK,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[2]||(t[2]=r=>this.showSuccessJob=r),id:"jobLogsShowSuccessCheck"},null,512),[[In,this.showSuccessJob]]),YK]),h("div",KK,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[3]||(t[3]=r=>this.showFailedJob=r),id:"jobLogsShowFailedCheck"},null,512),[[In,this.showFailedJob]]),UK])]),h("div",qK,[GK,h("div",JK,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[4]||(t[4]=r=>i.showJobID=r),id:"jobLogsShowJobIDCheck"},null,512),[[In,i.showJobID]]),XK]),h("div",QK,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[5]||(t[5]=r=>i.showLogID=r),id:"jobLogsShowLogIDCheck"},null,512),[[In,i.showLogID]]),ZK])])]),h("table",eU,[h("thead",null,[h("tr",null,[tU,i.showLogID?(D(),F("th",nU,"Log ID")):re("",!0),i.showJobID?(D(),F("th",sU,"Job ID")):re("",!0),iU,oU])]),h("tbody",null,[(D(!0),F(Te,null,Ue(this.showLogs,r=>(D(),F("tr",rU,[h("th",aU,_e(r.LogDate),1),i.showLogID?(D(),F("td",lU,[h("samp",cU,_e(r.LogID),1)])):re("",!0),i.showJobID?(D(),F("td",uU,[h("samp",dU,_e(r.JobID),1)])):re("",!0),h("td",null,[h("span",{class:Ee(["badge",[r.Status==="1"?"text-success-emphasis bg-success-subtle":"text-danger-emphasis bg-danger-subtle"]])},_e(r.Status==="1"?"Success":"Failed"),3)]),h("td",null,_e(r.Message),1)]))),256))])]),h("div",hU,[this.getLogs.length>this.showLogAmount?(D(),F("button",{key:0,onClick:t[6]||(t[6]=r=>this.showLogAmount+=20),class:"btn btn-sm rounded-3 shadow-sm text-primary-emphasis bg-primary-subtle border-1 border-primary-subtle"},[fU,ye(" Show More ")])):re("",!0),this.showLogAmount>20?(D(),F("button",{key:1,onClick:t[7]||(t[7]=r=>this.showLogAmount=20),class:"btn btn-sm rounded-3 shadow-sm text-primary-emphasis bg-primary-subtle border-1 border-primary-subtle"},[pU,ye(" Collapse ")])):re("",!0)])]))])])])])])}const bU=ze(TK,[["render",vU]]),yU={name:"peerShareLinkModal",props:{peer:Object},components:{VueDatePicker:ll},data(){return{dataCopy:void 0,loading:!1}},setup(){return{store:et()}},mounted(){this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0)},watch:{"peer.ShareLink":{deep:!0,handler(e,t){t.length!==e.length&&(this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0))}}},methods:{startSharing(){this.loading=!0,ft("/api/sharePeer/create",{Configuration:this.peer.configuration.Name,Peer:this.peer.id,ExpireDate:Cn().add(7,"d").format("YYYY-MM-DD HH:mm:ss")},e=>{e.status?(this.peer.ShareLink=e.data,this.dataCopy=e.data.at(0),this.store.newMessage("Server","Share link created successfully","success")):this.store.newMessage("Server","Share link failed to create. Reason: "+e.message,"danger"),this.loading=!1})},updateLinkExpireDate(){ft("/api/sharePeer/update",this.dataCopy,e=>{e.status?(this.dataCopy=e.data.at(0),this.peer.ShareLink=e.data,this.store.newMessage("Server","Link expire date updated","success")):this.store.newMessage("Server","Link expire date failed to update. Reason: "+e.message,"danger"),this.loading=!1})},stopSharing(){this.loading=!0,this.dataCopy.ExpireDate=Cn().format("YYYY-MM-DD HH:mm:ss"),this.updateLinkExpireDate()},parseTime(e){e?this.dataCopy.ExpireDate=Cn(e).format("YYYY-MM-DD HH:mm:ss"):this.dataCopy.ExpireDate=void 0,this.updateLinkExpireDate()}},computed:{getUrl(){const e=this.store.getActiveCrossServer();return e?`${e.host}/${this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}`:window.location.origin+window.location.pathname+this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}}},wU={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},xU={class:"container d-flex h-100 w-100"},kU={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"500px"}},SU={class:"card rounded-3 shadow flex-grow-1"},$U={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},AU=h("h4",{class:"mb-0"},"Share Peer",-1),CU={key:0,class:"card-body px-4 pb-4"},EU={key:0},PU=h("h6",{class:"mb-3 text-muted"}," Currently the peer is not sharing ",-1),MU=["disabled"],TU=h("i",{class:"bi bi-send-fill me-2"},null,-1),DU=[TU],OU={key:1},IU={class:"d-flex gap-2 mb-4"},RU=h("i",{class:"bi bi-link-45deg"},null,-1),LU=["href"],NU={class:"d-flex flex-column gap-2 mb-3"},FU=h("small",null,[h("i",{class:"bi bi-calendar me-2"}),ye(" Expire Date ")],-1),BU=["disabled"],VU=h("i",{class:"bi bi-send-slash-fill me-2"},null,-1),HU=[VU];function jU(e,t,n,s,i,o){const r=je("VueDatePicker");return D(),F("div",wU,[h("div",xU,[h("div",kU,[h("div",SU,[h("div",$U,[AU,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),this.peer.ShareLink?(D(),F("div",CU,[this.dataCopy?(D(),F("div",OU,[h("div",IU,[RU,h("a",{href:this.getUrl,class:"text-decoration-none",target:"_blank"},_e(o.getUrl),9,LU)]),h("div",NU,[FU,$e(r,{is24:!0,"min-date":new Date,"model-value":this.dataCopy.ExpireDate,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","dark"])]),h("button",{onClick:t[2]||(t[2]=a=>this.stopSharing()),disabled:this.loading,class:"w-100 btn bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle rounded-3 shadow-sm"},[h("span",{class:Ee({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},HU,2),ye(" "+_e(this.loading?"Stop Sharing...":"Stop Sharing"),1)],8,BU)])):(D(),F("div",EU,[PU,h("button",{onClick:t[1]||(t[1]=a=>this.startSharing()),disabled:this.loading,class:"w-100 btn bg-success-subtle text-success-emphasis border-1 border-success-subtle rounded-3 shadow-sm"},[h("span",{class:Ee({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},DU,2),ye(" "+_e(this.loading?"Sharing...":"Start Sharing"),1)],8,MU)]))])):re("",!0)])])])])}const WU=ze(yU,[["render",jU]]);xu.register(da,Ai,wc,yc,Ma,pc,or,Ta,hh,gc,mc,_c,vh,bh,yh,fa,Za,xh,z6,uH,mH,vH,AH);const zU={name:"peerList",components:{PeerShareLinkModal:WU,PeerJobsLogsModal:bU,PeerJobsAllModal:MK,PeerJobs:uK,PeerCreate:U1,PeerQRCode:NW,PeerSettings:Nj,PeerSearch:oF,Peer:tB,Line:s8,Bar:n8},setup(){const e=et(),t=Bn(),n=be(void 0);return{dashboardConfigurationStore:e,wireguardConfigurationStore:t,interval:n}},data(){return{configurationToggling:!1,loading:!1,error:null,configurationInfo:[],configurationPeers:[],historyDataSentDifference:[],historyDataReceivedDifference:[],historySentData:{labels:[],datasets:[{label:"Data Sent",data:[],fill:!1,borderColor:"#198754",tension:0}]},historyReceiveData:{labels:[],datasets:[{label:"Data Received",data:[],fill:!1,borderColor:"#0d6efd",tension:0}]},peerSetting:{modalOpen:!1,selectedPeer:void 0},peerScheduleJobs:{modalOpen:!1,selectedPeer:void 0},peerQRCode:{modalOpen:!1,peerConfigData:void 0},peerCreate:{modalOpen:!1},peerScheduleJobsAll:{modalOpen:!1},peerScheduleJobsLogs:{modalOpen:!1},peerShare:{modalOpen:!1,selectedPeer:void 0}}},mounted(){},watch:{$route:{immediate:!0,handler(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval),this.loading=!0;let e=this.$route.params.id;this.configurationInfo=[],this.configurationPeers=[],e&&(this.getPeers(e),this.setPeerInterval())}},"dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval"(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval),this.setPeerInterval()}},beforeRouteLeave(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval)},methods:{toggle(){this.configurationToggling=!0,xt("/api/toggleWireguardConfiguration/",{configurationName:this.configurationInfo.Name},e=>{e.status?this.dashboardConfigurationStore.newMessage("Server",`${this.configurationInfo.Name} is - ${e.data?"is on":"is off"}`,"Success"):this.dashboardConfigurationStore.newMessage("Server",e.message,"danger"),this.configurationInfo.Status=e.data,this.configurationToggling=!1})},getPeers(e=this.$route.params.id){xt("/api/getWireguardConfigurationInfo",{configurationName:e},t=>{if(this.configurationInfo=t.data.configurationInfo,this.configurationPeers=t.data.configurationPeers,this.configurationPeers.forEach(n=>{n.restricted=!1}),t.data.configurationRestrictedPeers.forEach(n=>{n.restricted=!0,this.configurationPeers.push(n)}),this.loading=!1,this.configurationPeers.length>0){const n=this.configurationPeers.map(i=>i.total_sent+i.cumu_sent).reduce((i,o)=>i+o).toFixed(4),s=this.configurationPeers.map(i=>i.total_receive+i.cumu_receive).reduce((i,o)=>i+o).toFixed(4);this.historyDataSentDifference[this.historyDataSentDifference.length-1]!==n&&(this.historyDataSentDifference.length>0&&(this.historySentData={labels:[...this.historySentData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Sent",data:[...this.historySentData.datasets[0].data,((n-this.historyDataSentDifference[this.historyDataSentDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#198754",tension:0}]}),this.historyDataSentDifference.push(n)),this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1]!==s&&(this.historyDataReceivedDifference.length>0&&(this.historyReceiveData={labels:[...this.historyReceiveData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Received",data:[...this.historyReceiveData.datasets[0].data,((s-this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#0d6efd",tension:0}]}),this.historyDataReceivedDifference.push(s))}})},setPeerInterval(){this.dashboardConfigurationStore.Peers.RefreshInterval=setInterval(()=>{this.getPeers()},parseInt(this.dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval))}},computed:{configurationSummary(){return{connectedPeers:this.configurationPeers.filter(t=>t.status==="running").length,totalUsage:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_data+t.cumu_data).reduce((t,n)=>t+n,0).toFixed(4):0,totalReceive:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_receive+t.cumu_receive).reduce((t,n)=>t+n,0).toFixed(4):0,totalSent:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_sent+t.cumu_sent).reduce((t,n)=>t+n,0).toFixed(4):0}},receiveData(){return this.historyReceiveData},sentData(){return this.historySentData},individualDataUsage(){return{labels:this.configurationPeers.map(e=>e.name?e.name:`Untitled Peer - ${e.id}`),datasets:[{label:"Total Data Usage",data:this.configurationPeers.map(e=>e.cumu_data+e.total_data),backgroundColor:this.configurationPeers.map(e=>"#0dcaf0"),tooltip:{callbacks:{label:e=>`${e.formattedValue} GB`}}}]}},individualDataUsageChartOption(){return{responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} GB`},grid:{display:!1}}}}},chartOptions(){return{responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:e=>`${e.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} MB/s`},grid:{display:!1}}}}},searchPeers(){const e=new Hr(this.configurationPeers,{keys:["name","id","allowed_ip"]}),t=this.wireguardConfigurationStore.searchString?e.search(this.wireguardConfigurationStore.searchString).map(n=>n.item):this.configurationPeers;return this.dashboardConfigurationStore.Configuration.Server.dashboard_sort==="restricted"?t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?-1:0):t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?1:0)}}},pn=e=>(Ut("data-v-6d78ad0a"),e=e(),qt(),e),YU={key:0,class:"container-md"},KU={class:"d-flex align-items-center"},UU=pn(()=>h("small",{CLASS:"text-muted"},"CONFIGURATION",-1)),qU={class:"d-flex align-items-center gap-3"},GU={class:"mb-0"},JU={class:"card rounded-3 bg-transparent shadow-sm ms-auto"},XU={class:"card-body py-2 d-flex align-items-center"},QU=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Status")],-1)),ZU={class:"form-check form-switch ms-auto"},e7=["for"],t7={key:0,class:"spinner-border spinner-border-sm","aria-hidden":"true"},n7=["disabled","id"],s7={class:"row mt-3 gy-2 gx-2 mb-2"},i7={class:"col-6 col-lg-3"},o7={class:"card rounded-3 bg-transparent shadow-sm"},r7={class:"card-body py-2"},a7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),l7={class:"col-6 col-lg-3"},c7={class:"card rounded-3 bg-transparent shadow-sm"},u7={class:"card-body py-2"},d7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Listen Port")],-1)),h7={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},f7={class:"card rounded-3 bg-transparent shadow-sm"},p7={class:"card-body py-2"},g7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Public Key")],-1)),m7={class:"row gx-2 gy-2 mb-2"},_7={class:"col-6 col-lg-3"},v7={class:"card rounded-3 bg-transparent shadow-sm"},b7={class:"card-body d-flex"},y7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Connected Peers")],-1)),w7={class:"h4"},x7=pn(()=>h("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1)),k7={class:"col-6 col-lg-3"},S7={class:"card rounded-3 bg-transparent shadow-sm"},$7={class:"card-body d-flex"},A7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Usage")],-1)),C7={class:"h4"},E7=pn(()=>h("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1)),P7={class:"col-6 col-lg-3"},M7={class:"card rounded-3 bg-transparent shadow-sm"},T7={class:"card-body d-flex"},D7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Received")],-1)),O7={class:"h4 text-primary"},I7=pn(()=>h("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1)),R7={class:"col-6 col-lg-3"},L7={class:"card rounded-3 bg-transparent shadow-sm"},N7={class:"card-body d-flex"},F7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Sent")],-1)),B7={class:"h4 text-success"},V7=pn(()=>h("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1)),H7={class:"row gx-2 gy-2 mb-3"},j7={class:"col-12 col-lg-6"},W7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},z7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Peers Total Data Usage")],-1)),Y7={class:"card-body pt-1"},K7={class:"col-sm col-lg-3"},U7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},q7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Received Data Usage")],-1)),G7={class:"card-body pt-1"},J7={class:"col-sm col-lg-3"},X7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},Q7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Sent Data Usage")],-1)),Z7={class:"card-body pt-1"},e9={class:"mb-3"};function t9(e,t,n,s,i,o){const r=je("Bar"),a=je("Line"),l=je("PeerSearch"),c=je("Peer"),u=je("PeerSettings"),d=je("PeerQRCode"),f=je("PeerJobs"),p=je("PeerJobsAllModal"),m=je("PeerJobsLogsModal"),_=je("PeerShareLinkModal");return this.loading?re("",!0):(D(),F("div",YU,[h("div",KU,[h("div",null,[UU,h("div",qU,[h("h1",GU,[h("samp",null,_e(this.configurationInfo.Name),1)])])]),h("div",JU,[h("div",XU,[h("div",null,[QU,h("div",ZU,[h("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+this.configurationInfo.id},[ye(_e(this.configurationToggling?"Turning ":"")+" "+_e(this.configurationInfo.Status?"On":"Off")+" ",1),this.configurationToggling?(D(),F("span",t7)):re("",!0)],8,e7),Re(h("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+this.configurationInfo.id,onChange:t[0]||(t[0]=b=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=b=>this.configurationInfo.Status=b)},null,40,n7),[[In,this.configurationInfo.Status]])])]),h("div",{class:Ee(["dot ms-5",{active:this.configurationInfo.Status}])},null,2)])])]),h("div",s7,[h("div",i7,[h("div",o7,[h("div",r7,[a7,ye(" "+_e(this.configurationInfo.Address),1)])])]),h("div",l7,[h("div",c7,[h("div",u7,[d7,ye(" "+_e(this.configurationInfo.ListenPort),1)])])]),h("div",h7,[h("div",f7,[h("div",p7,[g7,h("samp",null,_e(this.configurationInfo.PublicKey),1)])])])]),h("div",m7,[h("div",_7,[h("div",v7,[h("div",b7,[h("div",null,[y7,h("strong",w7,_e(o.configurationSummary.connectedPeers),1)]),x7])])]),h("div",k7,[h("div",S7,[h("div",$7,[h("div",null,[A7,h("strong",C7,_e(o.configurationSummary.totalUsage)+" GB",1)]),E7])])]),h("div",P7,[h("div",M7,[h("div",T7,[h("div",null,[D7,h("strong",O7,_e(o.configurationSummary.totalReceive)+" GB",1)]),I7])])]),h("div",R7,[h("div",L7,[h("div",N7,[h("div",null,[F7,h("strong",B7,_e(o.configurationSummary.totalSent)+" GB",1)]),V7])])])]),h("div",H7,[h("div",j7,[h("div",W7,[z7,h("div",Y7,[$e(r,{data:o.individualDataUsage,options:o.individualDataUsageChartOption,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),h("div",K7,[h("div",U7,[q7,h("div",G7,[$e(a,{options:o.chartOptions,data:o.receiveData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),h("div",J7,[h("div",X7,[Q7,h("div",Z7,[$e(a,{options:o.chartOptions,data:o.sentData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]),h("div",e9,[$e(l,{onJobsAll:t[2]||(t[2]=b=>this.peerScheduleJobsAll.modalOpen=!0),onJobLogs:t[3]||(t[3]=b=>this.peerScheduleJobsLogs.modalOpen=!0),configuration:this.configurationInfo},null,8,["configuration"]),$e(Wi,{name:"list",tag:"div",class:"row gx-2 gy-2 z-0"},{default:Me(()=>[(D(!0),F(Te,null,Ue(this.searchPeers,b=>(D(),F("div",{class:"col-12 col-lg-6 col-xl-4",key:b.id},[$e(c,{Peer:b,onShare:w=>{this.peerShare.selectedPeer=b.id,this.peerShare.modalOpen=!0},onRefresh:t[4]||(t[4]=w=>this.getPeers()),onJobs:w=>{i.peerScheduleJobs.modalOpen=!0,i.peerScheduleJobs.selectedPeer=this.configurationPeers.find($=>$.id===b.id)},onSetting:w=>{i.peerSetting.modalOpen=!0,i.peerSetting.selectedPeer=this.configurationPeers.find($=>$.id===b.id)},onQrcode:t[5]||(t[5]=w=>{this.peerQRCode.peerConfigData=w,this.peerQRCode.modalOpen=!0})},null,8,["Peer","onShare","onJobs","onSetting"])]))),128))]),_:1})]),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerSetting.modalOpen?(D(),Ne(u,{key:"settings",selectedPeer:this.peerSetting.selectedPeer,onRefresh:t[6]||(t[6]=b=>this.getPeers()),onClose:t[7]||(t[7]=b=>this.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[i.peerQRCode.modalOpen?(D(),Ne(d,{peerConfigData:this.peerQRCode.peerConfigData,key:"qrcode",onClose:t[8]||(t[8]=b=>this.peerQRCode.modalOpen=!1)},null,8,["peerConfigData"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerScheduleJobs.modalOpen?(D(),Ne(f,{key:0,onRefresh:t[9]||(t[9]=b=>this.getPeers()),selectedPeer:this.peerScheduleJobs.selectedPeer,onClose:t[10]||(t[10]=b=>this.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerScheduleJobsAll.modalOpen?(D(),Ne(p,{key:0,onRefresh:t[11]||(t[11]=b=>this.getPeers()),onClose:t[12]||(t[12]=b=>this.peerScheduleJobsAll.modalOpen=!1),configurationPeers:this.configurationPeers},null,8,["configurationPeers"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerScheduleJobsLogs.modalOpen?(D(),Ne(m,{key:0,onClose:t[13]||(t[13]=b=>this.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerShare.modalOpen?(D(),Ne(_,{key:0,onClose:t[14]||(t[14]=b=>{this.peerShare.modalOpen=!1,this.peerShare.selectedPeer=void 0}),peer:this.configurationPeers.find(b=>b.id===this.peerShare.selectedPeer)},null,8,["peer"])):re("",!0)]),_:1})]))}const n9=ze(zU,[["render",t9],["__scopeId","data-v-6d78ad0a"]]),s9={name:"ping",data(){return{loading:!1,cips:{},selectedConfiguration:void 0,selectedPeer:void 0,selectedIp:void 0,count:4,pingResult:void 0,pinging:!1}},setup(){return{store:et()}},mounted(){xt("/api/ping/getAllPeersIpAddress",{},e=>{e.status&&(this.loading=!0,this.cips=e.data,console.log(this.cips))})},methods:{execute(){this.selectedIp&&(this.pinging=!0,this.pingResult=void 0,xt("/api/ping/execute",{ipAddress:this.selectedIp,count:this.count},e=>{e.status?this.pingResult=e.data:this.store.newMessage("Server",e.message,"danger")}))}},watch:{selectedConfiguration(){this.selectedPeer=void 0,this.selectedIp=void 0},selectedPeer(){this.selectedIp=void 0}}},Hn=e=>(Ut("data-v-7b32cdf7"),e=e(),qt(),e),i9={class:"mt-md-5 mt-3 text-body"},o9={class:"container"},r9=Hn(()=>h("h3",{class:"mb-3 text-body"},"Ping",-1)),a9={class:"row"},l9={class:"col-sm-4 d-flex gap-2 flex-column"},c9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"configuration"},[h("small",null,"Configuration")],-1)),u9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Configuration...",-1)),d9=["value"],h9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"peer"},[h("small",null,"Peer")],-1)),f9=["disabled"],p9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Peer...",-1)),g9=["value"],m9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"ip"},[h("small",null,"IP Address")],-1)),_9=["disabled"],v9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a IP...",-1)),b9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"count"},[h("small",null,"Ping Count")],-1)),y9=["disabled"],w9=Hn(()=>h("i",{class:"bi bi-person-walking me-2"},null,-1)),x9={class:"col-sm-8"},k9={key:"pingPlaceholder"},S9={key:"pingResult",class:"d-flex flex-column gap-2 w-100"},$9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.15s"}},A9={class:"card-body"},C9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),E9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.3s"}},P9={class:"card-body"},M9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Is Alive")],-1)),T9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.45s"}},D9={class:"card-body"},O9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Average / Min / Max Round Trip Time")],-1)),I9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.6s"}},R9={class:"card-body"},L9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Sent / Received / Lost Package")],-1));function N9(e,t,n,s,i,o){return D(),F("div",i9,[h("div",o9,[r9,h("div",a9,[h("div",l9,[h("div",null,[c9,Re(h("select",{class:"form-select","onUpdate:modelValue":t[0]||(t[0]=r=>this.selectedConfiguration=r)},[u9,(D(!0),F(Te,null,Ue(this.cips,(r,a)=>(D(),F("option",{value:a},_e(a),9,d9))),256))],512),[[hc,this.selectedConfiguration]])]),h("div",null,[h9,Re(h("select",{id:"peer",class:"form-select","onUpdate:modelValue":t[1]||(t[1]=r=>this.selectedPeer=r),disabled:this.selectedConfiguration===void 0},[p9,this.selectedConfiguration!==void 0?(D(!0),F(Te,{key:0},Ue(this.cips[this.selectedConfiguration],(r,a)=>(D(),F("option",{value:a},_e(a),9,g9))),256)):re("",!0)],8,f9),[[hc,this.selectedPeer]])]),h("div",null,[m9,Re(h("select",{id:"ip",class:"form-select","onUpdate:modelValue":t[2]||(t[2]=r=>this.selectedIp=r),disabled:this.selectedPeer===void 0},[v9,this.selectedPeer!==void 0?(D(!0),F(Te,{key:0},Ue(this.cips[this.selectedConfiguration][this.selectedPeer].allowed_ips,r=>(D(),F("option",null,_e(r),1))),256)):re("",!0)],8,_9),[[hc,this.selectedIp]])]),h("div",null,[b9,Re(h("input",{class:"form-control",type:"number","onUpdate:modelValue":t[3]||(t[3]=r=>this.count=r),min:"1",id:"count",placeholder:"How many times you want to ping?"},null,512),[[We,this.count]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.selectedIp,onClick:t[4]||(t[4]=r=>this.execute())},[w9,ye("Go! ")],8,y9)]),h("div",x9,[$e(Wi,{name:"ping"},{default:Me(()=>[this.pingResult?(D(),F("div",S9,[h("div",$9,[h("div",A9,[C9,ye(" "+_e(this.pingResult.address),1)])]),h("div",E9,[h("div",P9,[M9,h("span",{class:Ee([this.pingResult.is_alive?"text-success":"text-danger"])},[h("i",{class:Ee(["bi me-1",[this.pingResult.is_alive?"bi-check-circle-fill":"bi-x-circle-fill"]])},null,2),ye(" "+_e(this.pingResult.is_alive?"Yes":"No"),1)],2)])]),h("div",T9,[h("div",D9,[O9,h("samp",null,_e(this.pingResult.avg_rtt)+"ms / "+_e(this.pingResult.min_rtt)+"ms / "+_e(this.pingResult.max_rtt)+"ms ",1)])]),h("div",I9,[h("div",R9,[L9,h("samp",null,_e(this.pingResult.package_sent)+" / "+_e(this.pingResult.package_received)+" / "+_e(this.pingResult.package_loss),1)])])])):(D(),F("div",k9,[(D(),F(Te,null,Ue(4,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.pinging}]),style:Wt({"animation-delay":`${r*.15}s`})},null,6)),64))]))]),_:1})])])])])}const F9=ze(s9,[["render",N9],["__scopeId","data-v-7b32cdf7"]]),B9={name:"traceroute",data(){return{tracing:!1,ipAddress:void 0,tracerouteResult:void 0}},setup(){return{store:Bn()}},methods:{execute(){this.ipAddress&&(this.tracing=!0,this.tracerouteResult=void 0,xt("/api/traceroute/execute",{ipAddress:this.ipAddress},e=>{e.status?this.tracerouteResult=e.data:this.store.newMessage("Server",e.message,"danger"),this.tracing=!1}))}}},Pu=e=>(Ut("data-v-606c2c93"),e=e(),qt(),e),V9={class:"mt-md-5 mt-3 text-body"},H9={class:"container-md"},j9=Pu(()=>h("h3",{class:"mb-3 text-body"},"Traceroute",-1)),W9={class:"row"},z9={class:"col-sm-4 d-flex gap-2 flex-column"},Y9=Pu(()=>h("label",{class:"mb-1 text-muted",for:"ipAddress"},[h("small",null,"IP Address")],-1)),K9=["disabled"],U9=Pu(()=>h("i",{class:"bi bi-bullseye me-2"},null,-1)),q9={class:"col-sm-8 position-relative"},G9={key:"pingPlaceholder"},J9={key:"table",class:"w-100"},X9={class:"table table-borderless rounded-3 w-100"},Q9=Pu(()=>h("thead",null,[h("tr",null,[h("th",{scope:"col"},"Hop"),h("th",{scope:"col"},"IP Address"),h("th",{scope:"col"},"Average / Min / Max Round Trip Time")])],-1));function Z9(e,t,n,s,i,o){return D(),F("div",V9,[h("div",H9,[j9,h("div",W9,[h("div",z9,[h("div",null,[Y9,Re(h("input",{id:"ipAddress",class:"form-control","onUpdate:modelValue":t[0]||(t[0]=r=>this.ipAddress=r),type:"text",placeholder:"Enter an IP Address you want to trace :)"},null,512),[[We,this.ipAddress]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.store.regexCheckIP(this.ipAddress)||this.tracing,onClick:t[1]||(t[1]=r=>this.execute())},[U9,ye(" "+_e(this.tracing?"Tracing...":"Trace It!"),1)],8,K9)]),h("div",q9,[$e(Wi,{name:"ping"},{default:Me(()=>[this.tracerouteResult?(D(),F("div",J9,[h("table",X9,[Q9,h("tbody",null,[(D(!0),F(Te,null,Ue(this.tracerouteResult,(r,a)=>(D(),F("tr",{class:"animate__fadeInUp animate__animated",style:Wt({"animation-delay":`${a*.05}s`})},[h("td",null,_e(r.hop),1),h("td",null,_e(r.ip),1),h("td",null,_e(r.avg_rtt)+" / "+_e(r.min_rtt)+" / "+_e(r.max_rtt),1)],4))),256))])])])):(D(),F("div",G9,[(D(),F(Te,null,Ue(10,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.tracing}]),style:Wt({"animation-delay":`${r*.05}s`})},null,6)),64))]))]),_:1})])])])])}const eq=ze(B9,[["render",Z9],["__scopeId","data-v-606c2c93"]]),tq={name:"totp",async setup(){const e=et();let t="";return await xt("/api/Welcome_GetTotpLink",{},n=>{n.status&&(t=n.data)}),{l:t,store:e}},mounted(){this.l&&Bo.toCanvas(document.getElementById("qrcode"),this.l,function(e){})},data(){return{totp:"",totpInvalidMessage:"",verified:!1}},methods:{validateTotp(){}},watch:{totp(e){const t=document.querySelector("#totp");t.classList.remove("is-invalid","is-valid"),e.length===6&&(console.log(e),/[0-9]{6}/.test(e)?ft("/api/Welcome_VerifyTotpLink",{totp:e},n=>{n.status?(this.verified=!0,t.classList.add("is-valid"),this.$emit("verified")):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP does not match.")}):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP can only contain numbers"))}}},nq=["data-bs-theme"],sq={class:"m-auto text-body",style:{width:"500px"}},iq={class:"d-flex flex-column"},oq=h("h1",{class:"dashboardLogo display-4"},"Multi-Factor Authentication",-1),rq=h("p",{class:"mb-2"},[h("small",{class:"text-muted"},"1. Please scan the following QR Code to generate TOTP")],-1),aq=h("canvas",{id:"qrcode",class:"rounded-3 mb-2"},null,-1),lq={class:"p-3 bg-body-secondary rounded-3 border mb-3"},cq=h("p",{class:"text-muted mb-0"},[h("small",null,"Or you can click the link below:")],-1),uq=["href"],dq={style:{"line-break":"anywhere"}},hq=h("label",{for:"totp",class:"mb-2"},[h("small",{class:"text-muted"},"2. Enter the TOTP generated by your authenticator to verify")],-1),fq={class:"form-group mb-2"},pq=["disabled"],gq={class:"invalid-feedback"},mq=h("div",{class:"valid-feedback"}," TOTP verified! ",-1),_q=h("div",{class:"alert alert-warning rounded-3"},[h("i",{class:"bi bi-exclamation-triangle-fill me-2"}),ye(" If you ever lost your TOTP and can't login, please follow instruction on "),h("a",{href:"https://github.com/donaldzou/WGDashboard",target:"_blank"},"readme.md"),ye(" to reset. ")],-1),vq=h("hr",null,null,-1),bq={class:"d-flex gap-3 mt-5 flex-column"},yq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1),wq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1);function xq(e,t,n,s,i,o){const r=je("RouterLink");return D(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.store.Configuration.Server.dashboard_theme},[h("div",sq,[h("div",iq,[h("div",null,[oq,rq,aq,h("div",lq,[cq,h("a",{href:this.l},[h("code",dq,_e(this.l),1)],8,uq)]),hq,h("div",fq,[Re(h("input",{class:"form-control text-center totp",id:"totp",maxlength:"6",type:"text",inputmode:"numeric",autocomplete:"one-time-code","onUpdate:modelValue":t[0]||(t[0]=a=>this.totp=a),disabled:this.verified},null,8,pq),[[We,this.totp]]),h("div",gq,_e(this.totpInvalidMessage),1),mq]),_q]),vq,h("div",bq,[this.verified?(D(),Ne(r,{key:1,to:"/",class:"btn btn-dark btn-lg d-flex btn-brand shadow align-items-center flex-grow-1 rounded-3"},{default:Me(()=>[ye(" Complete "),wq]),_:1})):(D(),Ne(r,{key:0,to:"/",class:"btn bg-secondary-subtle text-secondary-emphasis rounded-3 flex-grow-1 btn-lg border-1 border-secondary-subtle shadow d-flex"},{default:Me(()=>[ye(" I don't need MFA "),yq]),_:1}))])])])],8,nq)}const kq=ze(tq,[["render",xq]]),Sq={name:"share",async setup(){const e=tP(),t=be(!1),n=et(),s=be(""),i=be(""),o=be(new Blob);await xt("/api/getDashboardTheme",{},a=>{s.value=a.data});const r=e.query.ShareID;return r===void 0||r.length===0?(i.value=void 0,t.value=!0):await xt("/api/sharePeer/get",{ShareID:r},a=>{a.status?(i.value=a.data,o.value=new Blob([i.value.file],{type:"text/plain"})):i.value=void 0,t.value=!0}),{store:n,theme:s,peerConfiguration:i,blob:o}},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfiguration.file,e=>{e&&console.error(e)})},methods:{download(){const e=new Blob([this.peerConfiguration.file],{type:"text/plain"}),t=URL.createObjectURL(e),n=`${this.peerConfiguration.fileName}.conf`,s=document.createElement("a");s.href=t,s.download=n,s.click()}},computed:{getBlob(){return URL.createObjectURL(this.blob)}}},hp=e=>(Ut("data-v-99d4b06a"),e=e(),qt(),e),$q=["data-bs-theme"],Aq={class:"m-auto text-body",style:{width:"500px"}},Cq={key:0,class:"text-center position-relative",style:{}},Eq=QA('

Oh no... This link is either expired or invalid.

',2),Pq=[Eq],Mq={key:1,class:"d-flex align-items-center flex-column gap-3"},Tq=hp(()=>h("div",{class:"h1 dashboardLogo text-center animate__animated animate__fadeInUp"},[h("h6",null,"WGDashboard"),ye(" Scan QR Code from the WireGuard App ")],-1)),Dq={id:"qrcode",class:"rounded-3 shadow animate__animated animate__fadeInUp mb-3",ref:"qrcode"},Oq=hp(()=>h("p",{class:"text-muted animate__animated animate__fadeInUp mb-1",style:{"animation-delay":"0.2s"}},[ye("or click the button below to download the "),h("samp",null,".conf"),ye(" file")],-1)),Iq=["download","href"],Rq=hp(()=>h("i",{class:"bi bi-download"},null,-1)),Lq=[Rq];function Nq(e,t,n,s,i,o){return D(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.theme},[h("div",Aq,[this.peerConfiguration?(D(),F("div",Mq,[Tq,h("canvas",Dq,null,512),Oq,h("a",{download:this.peerConfiguration.fileName+".conf",href:o.getBlob,class:"btn btn-lg bg-primary-subtle text-primary-emphasis border-1 border-primary-subtle animate__animated animate__fadeInUp shadow-sm",style:{"animation-delay":"0.25s"}},Lq,8,Iq)])):(D(),F("div",Cq,Pq))])],8,$q)}const Fq=ze(Sq,[["render",Nq],["__scopeId","data-v-99d4b06a"]]),Bq=async()=>{let e=!1;return await xt("/api/validateAuthentication",{},t=>{e=t.status}),e},gl=ZE({history:mE(),routes:[{name:"Index",path:"/",component:GP,meta:{requiresAuth:!0},children:[{name:"Configuration List",path:"",component:IT,meta:{title:"WireGuard Configurations"}},{name:"Settings",path:"/settings",component:L3,meta:{title:"Settings"}},{path:"/ping",name:"Ping",component:F9},{path:"/traceroute",name:"Traceroute",component:eq},{name:"New Configuration",path:"/new_configuration",component:v5,meta:{title:"New Configuration"}},{name:"Configuration",path:"/configuration/:id",component:x5,meta:{title:"Configuration"},children:[{name:"Peers List",path:"peers",component:n9},{name:"Peers Create",path:"create",component:U1}]}]},{path:"/signin",component:ZM,meta:{title:"Sign In"}},{path:"/welcome",component:iN,meta:{requiresAuth:!0,title:"Welcome to WGDashboard"}},{path:"/2FASetup",component:kq,meta:{requiresAuth:!0,title:"Multi-Factor Authentication Setup"}},{path:"/share",component:Fq,meta:{title:"Share"}}]});gl.beforeEach(async(e,t,n)=>{const s=Bn(),i=et();e.meta.title?e.params.id?document.title=e.params.id+" | WGDashboard":document.title=e.meta.title+" | WGDashboard":document.title="WGDashboard",i.ShowNavBar=!1;const o=await Bq();e.meta.requiresAuth&&!o?i.getActiveCrossServer()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),n()):nP.getCookie("authToken")&&o?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),i.Redirect=void 0,n()):(i.Redirect=e,n("/signin"),i.newMessage("WGDashboard","Session Ended","warning")):(await i.getConfiguration(),e.path==="/signin"?n("/"):n())});const J1=()=>{let e={"content-type":"application/json"};const n=et().getActiveCrossServer();return n&&(e["wg-dashboard-apikey"]=n.apiKey),e},X1=e=>{const n=et().getActiveCrossServer();return n?`${n.host}${e}`:`${window.location.protocol}//${(window.location.host+window.location.pathname+e).replace(/\/\//g,"/")}`},xt=async(e,t=void 0,n=void 0)=>{const s=new URLSearchParams(t);await fetch(`${X1(e)}?${s.toString()}`,{headers:J1()}).then(i=>{const o=et();if(i.ok)return i.json();if(i.status!==200)throw i.status===401&&o.newMessage("WGDashboard","Session Ended","warning"),new Error(i.statusText)}).then(i=>n?n(i):void 0).catch(i=>{console.log(i),gl.push({path:"/signin"})})},ft=async(e,t,n)=>{await fetch(`${X1(e)}`,{headers:J1(),method:"POST",body:JSON.stringify(t)}).then(s=>{const i=et();if(s.ok)return s.json();if(s.status!==200)throw s.status===401&&i.newMessage("WGDashboard","Session Ended","warning"),new Error(s.statusText)}).then(s=>n?n(s):void 0).catch(s=>{console.log(s),gl.push({path:"/signin"})})},et=bf("DashboardConfigurationStore",{state:()=>({Redirect:void 0,Configuration:void 0,Messages:[],Peers:{Selecting:!1,RefreshInterval:void 0},CrossServerConfiguration:{Enable:!1,ServerList:{}},ActiveServerConfiguration:void 0,IsElectronApp:!1,ShowNavBar:!1}),actions:{initCrossServerConfiguration(){const e=localStorage.getItem("CrossServerConfiguration");localStorage.getItem("ActiveCrossServerConfiguration")!==null&&(this.ActiveServerConfiguration=localStorage.getItem("ActiveCrossServerConfiguration")),e===null?window.localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration)):this.CrossServerConfiguration=JSON.parse(e)},syncCrossServerConfiguration(){window.localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration))},addCrossServerConfiguration(){this.CrossServerConfiguration.ServerList[Ts().toString()]={host:"",apiKey:"",active:!1}},deleteCrossServerConfiguration(e){delete this.CrossServerConfiguration.ServerList[e]},getActiveCrossServer(){const e=localStorage.getItem("ActiveCrossServerConfiguration");if(e!==null)return this.CrossServerConfiguration.ServerList[e]},setActiveCrossServer(e){this.ActiveServerConfiguration=e,localStorage.setItem("ActiveCrossServerConfiguration",e)},removeActiveCrossServer(){this.ActiveServerConfiguration=void 0,localStorage.removeItem("ActiveCrossServerConfiguration")},async getConfiguration(){await xt("/api/getDashboardConfiguration",{},e=>{e.status&&(this.Configuration=e.data)})},async signOut(){await xt("/api/signout",{},e=>{this.removeActiveCrossServer(),this.$router.go("/signin")})},newMessage(e,t,n){this.Messages.push({id:Ts(),from:e,content:t,type:n,show:!0})}}}),fp=e=>(Ut("data-v-a29399d4"),e=e(),qt(),e),Vq={class:"navbar bg-dark sticky-top","data-bs-theme":"dark"},Hq={class:"container-fluid d-flex text-body align-items-center"},jq=fp(()=>h("span",{class:"navbar-brand mb-0 h1"},"WGDashboard",-1)),Wq={key:0,class:"ms-auto text-muted"},zq=fp(()=>h("i",{class:"bi bi-server me-2"},null,-1)),Yq=fp(()=>h("i",{class:"bi bi-list"},null,-1)),Kq=[Yq],Uq={__name:"App",setup(e){const t=et();t.initCrossServerConfiguration(),window.IS_WGDASHBOARD_DESKTOP&&(t.IsElectronApp=!0,t.CrossServerConfiguration.Enable=!0),Vt(t.CrossServerConfiguration,()=>{t.syncCrossServerConfiguration()},{deep:!0});const n=ve(()=>{if(t.ActiveServerConfiguration)return t.CrossServerConfiguration.ServerList[t.ActiveServerConfiguration]});return(s,i)=>(D(),F(Te,null,[h("nav",Vq,[h("div",Hq,[jq,n.value!==void 0?(D(),F("small",Wq,[zq,ye(_e(n.value.host),1)])):re("",!0),h("a",{role:"button",class:"navbarBtn text-body",onClick:i[0]||(i[0]=o=>q(t).ShowNavBar=!q(t).ShowNavBar),style:{"line-height":"0","font-size":"2rem"}},Kq)])]),(D(),Ne(uf,null,{default:Me(()=>[$e(q(ky),null,{default:Me(({Component:o})=>[$e(Ct,{name:"app",mode:"out-in"},{default:Me(()=>[(D(),Ne(Io(o)))]),_:2},1024)]),_:1})]),_:1}))],64))}},qq=ze(Uq,[["__scopeId","data-v-a29399d4"]]),pp=jC(qq);pp.use(gl);const Q1=KC();Q1.use(({store:e})=>{e.$router=tu(gl)});pp.use(Q1);pp.mount("#app"); + ${e.data?"is on":"is off"}`,"Success"):this.dashboardConfigurationStore.newMessage("Server",e.message,"danger"),this.configurationInfo.Status=e.data,this.configurationToggling=!1})},getPeers(e=this.$route.params.id){xt("/api/getWireguardConfigurationInfo",{configurationName:e},t=>{if(this.configurationInfo=t.data.configurationInfo,this.configurationPeers=t.data.configurationPeers,this.configurationPeers.forEach(n=>{n.restricted=!1}),t.data.configurationRestrictedPeers.forEach(n=>{n.restricted=!0,this.configurationPeers.push(n)}),this.loading=!1,this.configurationPeers.length>0){const n=this.configurationPeers.map(i=>i.total_sent+i.cumu_sent).reduce((i,o)=>i+o).toFixed(4),s=this.configurationPeers.map(i=>i.total_receive+i.cumu_receive).reduce((i,o)=>i+o).toFixed(4);this.historyDataSentDifference[this.historyDataSentDifference.length-1]!==n&&(this.historyDataSentDifference.length>0&&(this.historySentData={labels:[...this.historySentData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Sent",data:[...this.historySentData.datasets[0].data,((n-this.historyDataSentDifference[this.historyDataSentDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#198754",tension:0}]}),this.historyDataSentDifference.push(n)),this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1]!==s&&(this.historyDataReceivedDifference.length>0&&(this.historyReceiveData={labels:[...this.historyReceiveData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Received",data:[...this.historyReceiveData.datasets[0].data,((s-this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#0d6efd",tension:0}]}),this.historyDataReceivedDifference.push(s))}})},setPeerInterval(){this.dashboardConfigurationStore.Peers.RefreshInterval=setInterval(()=>{this.getPeers()},parseInt(this.dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval))}},computed:{configurationSummary(){return{connectedPeers:this.configurationPeers.filter(t=>t.status==="running").length,totalUsage:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_data+t.cumu_data).reduce((t,n)=>t+n,0).toFixed(4):0,totalReceive:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_receive+t.cumu_receive).reduce((t,n)=>t+n,0).toFixed(4):0,totalSent:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_sent+t.cumu_sent).reduce((t,n)=>t+n,0).toFixed(4):0}},receiveData(){return this.historyReceiveData},sentData(){return this.historySentData},individualDataUsage(){return{labels:this.configurationPeers.map(e=>e.name?e.name:`Untitled Peer - ${e.id}`),datasets:[{label:"Total Data Usage",data:this.configurationPeers.map(e=>e.cumu_data+e.total_data),backgroundColor:this.configurationPeers.map(e=>"#0dcaf0"),tooltip:{callbacks:{label:e=>`${e.formattedValue} GB`}}}]}},individualDataUsageChartOption(){return{responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} GB`},grid:{display:!1}}}}},chartOptions(){return{responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:e=>`${e.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} MB/s`},grid:{display:!1}}}}},searchPeers(){const e=new Hr(this.configurationPeers,{keys:["name","id","allowed_ip"]}),t=this.wireguardConfigurationStore.searchString?e.search(this.wireguardConfigurationStore.searchString).map(n=>n.item):this.configurationPeers;return this.dashboardConfigurationStore.Configuration.Server.dashboard_sort==="restricted"?t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?-1:0):t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?1:0)}}},pn=e=>(Ut("data-v-6d78ad0a"),e=e(),qt(),e),YU={key:0,class:"container-md"},KU={class:"d-flex align-items-center"},UU=pn(()=>h("small",{CLASS:"text-muted"},"CONFIGURATION",-1)),qU={class:"d-flex align-items-center gap-3"},GU={class:"mb-0"},JU={class:"card rounded-3 bg-transparent shadow-sm ms-auto"},XU={class:"card-body py-2 d-flex align-items-center"},QU=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Status")],-1)),ZU={class:"form-check form-switch ms-auto"},e7=["for"],t7={key:0,class:"spinner-border spinner-border-sm","aria-hidden":"true"},n7=["disabled","id"],s7={class:"row mt-3 gy-2 gx-2 mb-2"},i7={class:"col-6 col-lg-3"},o7={class:"card rounded-3 bg-transparent shadow-sm"},r7={class:"card-body py-2"},a7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),l7={class:"col-6 col-lg-3"},c7={class:"card rounded-3 bg-transparent shadow-sm"},u7={class:"card-body py-2"},d7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Listen Port")],-1)),h7={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},f7={class:"card rounded-3 bg-transparent shadow-sm"},p7={class:"card-body py-2"},g7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Public Key")],-1)),m7={class:"row gx-2 gy-2 mb-2"},_7={class:"col-6 col-lg-3"},v7={class:"card rounded-3 bg-transparent shadow-sm"},b7={class:"card-body d-flex"},y7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Connected Peers")],-1)),w7={class:"h4"},x7=pn(()=>h("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1)),k7={class:"col-6 col-lg-3"},S7={class:"card rounded-3 bg-transparent shadow-sm"},$7={class:"card-body d-flex"},A7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Usage")],-1)),C7={class:"h4"},E7=pn(()=>h("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1)),P7={class:"col-6 col-lg-3"},M7={class:"card rounded-3 bg-transparent shadow-sm"},T7={class:"card-body d-flex"},D7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Received")],-1)),O7={class:"h4 text-primary"},I7=pn(()=>h("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1)),R7={class:"col-6 col-lg-3"},L7={class:"card rounded-3 bg-transparent shadow-sm"},N7={class:"card-body d-flex"},F7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Sent")],-1)),B7={class:"h4 text-success"},V7=pn(()=>h("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1)),H7={class:"row gx-2 gy-2 mb-3"},j7={class:"col-12 col-lg-6"},W7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},z7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Peers Total Data Usage")],-1)),Y7={class:"card-body pt-1"},K7={class:"col-sm col-lg-3"},U7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},q7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Received Data Usage")],-1)),G7={class:"card-body pt-1"},J7={class:"col-sm col-lg-3"},X7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},Q7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Sent Data Usage")],-1)),Z7={class:"card-body pt-1"},e9={class:"mb-3"};function t9(e,t,n,s,i,o){const r=je("Bar"),a=je("Line"),l=je("PeerSearch"),c=je("Peer"),u=je("PeerSettings"),d=je("PeerQRCode"),f=je("PeerJobs"),p=je("PeerJobsAllModal"),m=je("PeerJobsLogsModal"),_=je("PeerShareLinkModal");return this.loading?re("",!0):(D(),F("div",YU,[h("div",KU,[h("div",null,[UU,h("div",qU,[h("h1",GU,[h("samp",null,_e(this.configurationInfo.Name),1)])])]),h("div",JU,[h("div",XU,[h("div",null,[QU,h("div",ZU,[h("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+this.configurationInfo.id},[ye(_e(this.configurationToggling?"Turning ":"")+" "+_e(this.configurationInfo.Status?"On":"Off")+" ",1),this.configurationToggling?(D(),F("span",t7)):re("",!0)],8,e7),Re(h("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+this.configurationInfo.id,onChange:t[0]||(t[0]=b=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=b=>this.configurationInfo.Status=b)},null,40,n7),[[In,this.configurationInfo.Status]])])]),h("div",{class:Ee(["dot ms-5",{active:this.configurationInfo.Status}])},null,2)])])]),h("div",s7,[h("div",i7,[h("div",o7,[h("div",r7,[a7,ye(" "+_e(this.configurationInfo.Address),1)])])]),h("div",l7,[h("div",c7,[h("div",u7,[d7,ye(" "+_e(this.configurationInfo.ListenPort),1)])])]),h("div",h7,[h("div",f7,[h("div",p7,[g7,h("samp",null,_e(this.configurationInfo.PublicKey),1)])])])]),h("div",m7,[h("div",_7,[h("div",v7,[h("div",b7,[h("div",null,[y7,h("strong",w7,_e(o.configurationSummary.connectedPeers),1)]),x7])])]),h("div",k7,[h("div",S7,[h("div",$7,[h("div",null,[A7,h("strong",C7,_e(o.configurationSummary.totalUsage)+" GB",1)]),E7])])]),h("div",P7,[h("div",M7,[h("div",T7,[h("div",null,[D7,h("strong",O7,_e(o.configurationSummary.totalReceive)+" GB",1)]),I7])])]),h("div",R7,[h("div",L7,[h("div",N7,[h("div",null,[F7,h("strong",B7,_e(o.configurationSummary.totalSent)+" GB",1)]),V7])])])]),h("div",H7,[h("div",j7,[h("div",W7,[z7,h("div",Y7,[$e(r,{data:o.individualDataUsage,options:o.individualDataUsageChartOption,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),h("div",K7,[h("div",U7,[q7,h("div",G7,[$e(a,{options:o.chartOptions,data:o.receiveData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),h("div",J7,[h("div",X7,[Q7,h("div",Z7,[$e(a,{options:o.chartOptions,data:o.sentData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]),h("div",e9,[$e(l,{onJobsAll:t[2]||(t[2]=b=>this.peerScheduleJobsAll.modalOpen=!0),onJobLogs:t[3]||(t[3]=b=>this.peerScheduleJobsLogs.modalOpen=!0),configuration:this.configurationInfo},null,8,["configuration"]),$e(Wi,{name:"list",tag:"div",class:"row gx-2 gy-2 z-0"},{default:Me(()=>[(D(!0),F(Te,null,Ue(this.searchPeers,b=>(D(),F("div",{class:"col-12 col-lg-6 col-xl-4",key:b.id},[$e(c,{Peer:b,onShare:w=>{this.peerShare.selectedPeer=b.id,this.peerShare.modalOpen=!0},onRefresh:t[4]||(t[4]=w=>this.getPeers()),onJobs:w=>{i.peerScheduleJobs.modalOpen=!0,i.peerScheduleJobs.selectedPeer=this.configurationPeers.find($=>$.id===b.id)},onSetting:w=>{i.peerSetting.modalOpen=!0,i.peerSetting.selectedPeer=this.configurationPeers.find($=>$.id===b.id)},onQrcode:t[5]||(t[5]=w=>{this.peerQRCode.peerConfigData=w,this.peerQRCode.modalOpen=!0})},null,8,["Peer","onShare","onJobs","onSetting"])]))),128))]),_:1})]),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerSetting.modalOpen?(D(),Ne(u,{key:"settings",selectedPeer:this.peerSetting.selectedPeer,onRefresh:t[6]||(t[6]=b=>this.getPeers()),onClose:t[7]||(t[7]=b=>this.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[i.peerQRCode.modalOpen?(D(),Ne(d,{peerConfigData:this.peerQRCode.peerConfigData,key:"qrcode",onClose:t[8]||(t[8]=b=>this.peerQRCode.modalOpen=!1)},null,8,["peerConfigData"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerScheduleJobs.modalOpen?(D(),Ne(f,{key:0,onRefresh:t[9]||(t[9]=b=>this.getPeers()),selectedPeer:this.peerScheduleJobs.selectedPeer,onClose:t[10]||(t[10]=b=>this.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerScheduleJobsAll.modalOpen?(D(),Ne(p,{key:0,onRefresh:t[11]||(t[11]=b=>this.getPeers()),onClose:t[12]||(t[12]=b=>this.peerScheduleJobsAll.modalOpen=!1),configurationPeers:this.configurationPeers},null,8,["configurationPeers"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerScheduleJobsLogs.modalOpen?(D(),Ne(m,{key:0,onClose:t[13]||(t[13]=b=>this.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):re("",!0)]),_:1}),$e(Ct,{name:"zoom"},{default:Me(()=>[this.peerShare.modalOpen?(D(),Ne(_,{key:0,onClose:t[14]||(t[14]=b=>{this.peerShare.modalOpen=!1,this.peerShare.selectedPeer=void 0}),peer:this.configurationPeers.find(b=>b.id===this.peerShare.selectedPeer)},null,8,["peer"])):re("",!0)]),_:1})]))}const n9=ze(zU,[["render",t9],["__scopeId","data-v-6d78ad0a"]]),s9={name:"ping",data(){return{loading:!1,cips:{},selectedConfiguration:void 0,selectedPeer:void 0,selectedIp:void 0,count:4,pingResult:void 0,pinging:!1}},setup(){return{store:et()}},mounted(){xt("/api/ping/getAllPeersIpAddress",{},e=>{e.status&&(this.loading=!0,this.cips=e.data,console.log(this.cips))})},methods:{execute(){this.selectedIp&&(this.pinging=!0,this.pingResult=void 0,xt("/api/ping/execute",{ipAddress:this.selectedIp,count:this.count},e=>{e.status?this.pingResult=e.data:this.store.newMessage("Server",e.message,"danger")}))}},watch:{selectedConfiguration(){this.selectedPeer=void 0,this.selectedIp=void 0},selectedPeer(){this.selectedIp=void 0}}},Hn=e=>(Ut("data-v-7b32cdf7"),e=e(),qt(),e),i9={class:"mt-md-5 mt-3 text-body"},o9={class:"container"},r9=Hn(()=>h("h3",{class:"mb-3 text-body"},"Ping",-1)),a9={class:"row"},l9={class:"col-sm-4 d-flex gap-2 flex-column"},c9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"configuration"},[h("small",null,"Configuration")],-1)),u9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Configuration...",-1)),d9=["value"],h9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"peer"},[h("small",null,"Peer")],-1)),f9=["disabled"],p9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Peer...",-1)),g9=["value"],m9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"ip"},[h("small",null,"IP Address")],-1)),_9=["disabled"],v9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a IP...",-1)),b9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"count"},[h("small",null,"Ping Count")],-1)),y9=["disabled"],w9=Hn(()=>h("i",{class:"bi bi-person-walking me-2"},null,-1)),x9={class:"col-sm-8"},k9={key:"pingPlaceholder"},S9={key:"pingResult",class:"d-flex flex-column gap-2 w-100"},$9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.15s"}},A9={class:"card-body"},C9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),E9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.3s"}},P9={class:"card-body"},M9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Is Alive")],-1)),T9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.45s"}},D9={class:"card-body"},O9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Average / Min / Max Round Trip Time")],-1)),I9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.6s"}},R9={class:"card-body"},L9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Sent / Received / Lost Package")],-1));function N9(e,t,n,s,i,o){return D(),F("div",i9,[h("div",o9,[r9,h("div",a9,[h("div",l9,[h("div",null,[c9,Re(h("select",{class:"form-select","onUpdate:modelValue":t[0]||(t[0]=r=>this.selectedConfiguration=r)},[u9,(D(!0),F(Te,null,Ue(this.cips,(r,a)=>(D(),F("option",{value:a},_e(a),9,d9))),256))],512),[[hc,this.selectedConfiguration]])]),h("div",null,[h9,Re(h("select",{id:"peer",class:"form-select","onUpdate:modelValue":t[1]||(t[1]=r=>this.selectedPeer=r),disabled:this.selectedConfiguration===void 0},[p9,this.selectedConfiguration!==void 0?(D(!0),F(Te,{key:0},Ue(this.cips[this.selectedConfiguration],(r,a)=>(D(),F("option",{value:a},_e(a),9,g9))),256)):re("",!0)],8,f9),[[hc,this.selectedPeer]])]),h("div",null,[m9,Re(h("select",{id:"ip",class:"form-select","onUpdate:modelValue":t[2]||(t[2]=r=>this.selectedIp=r),disabled:this.selectedPeer===void 0},[v9,this.selectedPeer!==void 0?(D(!0),F(Te,{key:0},Ue(this.cips[this.selectedConfiguration][this.selectedPeer].allowed_ips,r=>(D(),F("option",null,_e(r),1))),256)):re("",!0)],8,_9),[[hc,this.selectedIp]])]),h("div",null,[b9,Re(h("input",{class:"form-control",type:"number","onUpdate:modelValue":t[3]||(t[3]=r=>this.count=r),min:"1",id:"count",placeholder:"How many times you want to ping?"},null,512),[[We,this.count]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.selectedIp,onClick:t[4]||(t[4]=r=>this.execute())},[w9,ye("Go! ")],8,y9)]),h("div",x9,[$e(Wi,{name:"ping"},{default:Me(()=>[this.pingResult?(D(),F("div",S9,[h("div",$9,[h("div",A9,[C9,ye(" "+_e(this.pingResult.address),1)])]),h("div",E9,[h("div",P9,[M9,h("span",{class:Ee([this.pingResult.is_alive?"text-success":"text-danger"])},[h("i",{class:Ee(["bi me-1",[this.pingResult.is_alive?"bi-check-circle-fill":"bi-x-circle-fill"]])},null,2),ye(" "+_e(this.pingResult.is_alive?"Yes":"No"),1)],2)])]),h("div",T9,[h("div",D9,[O9,h("samp",null,_e(this.pingResult.avg_rtt)+"ms / "+_e(this.pingResult.min_rtt)+"ms / "+_e(this.pingResult.max_rtt)+"ms ",1)])]),h("div",I9,[h("div",R9,[L9,h("samp",null,_e(this.pingResult.package_sent)+" / "+_e(this.pingResult.package_received)+" / "+_e(this.pingResult.package_loss),1)])])])):(D(),F("div",k9,[(D(),F(Te,null,Ue(4,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.pinging}]),style:Wt({"animation-delay":`${r*.15}s`})},null,6)),64))]))]),_:1})])])])])}const F9=ze(s9,[["render",N9],["__scopeId","data-v-7b32cdf7"]]),B9={name:"traceroute",data(){return{tracing:!1,ipAddress:void 0,tracerouteResult:void 0}},setup(){return{store:Bn()}},methods:{execute(){this.ipAddress&&(this.tracing=!0,this.tracerouteResult=void 0,xt("/api/traceroute/execute",{ipAddress:this.ipAddress},e=>{e.status?this.tracerouteResult=e.data:this.store.newMessage("Server",e.message,"danger"),this.tracing=!1}))}}},Pu=e=>(Ut("data-v-606c2c93"),e=e(),qt(),e),V9={class:"mt-md-5 mt-3 text-body"},H9={class:"container-md"},j9=Pu(()=>h("h3",{class:"mb-3 text-body"},"Traceroute",-1)),W9={class:"row"},z9={class:"col-sm-4 d-flex gap-2 flex-column"},Y9=Pu(()=>h("label",{class:"mb-1 text-muted",for:"ipAddress"},[h("small",null,"IP Address")],-1)),K9=["disabled"],U9=Pu(()=>h("i",{class:"bi bi-bullseye me-2"},null,-1)),q9={class:"col-sm-8 position-relative"},G9={key:"pingPlaceholder"},J9={key:"table",class:"w-100"},X9={class:"table table-borderless rounded-3 w-100"},Q9=Pu(()=>h("thead",null,[h("tr",null,[h("th",{scope:"col"},"Hop"),h("th",{scope:"col"},"IP Address"),h("th",{scope:"col"},"Average / Min / Max Round Trip Time")])],-1));function Z9(e,t,n,s,i,o){return D(),F("div",V9,[h("div",H9,[j9,h("div",W9,[h("div",z9,[h("div",null,[Y9,Re(h("input",{id:"ipAddress",class:"form-control","onUpdate:modelValue":t[0]||(t[0]=r=>this.ipAddress=r),type:"text",placeholder:"Enter an IP Address you want to trace :)"},null,512),[[We,this.ipAddress]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.store.regexCheckIP(this.ipAddress)||this.tracing,onClick:t[1]||(t[1]=r=>this.execute())},[U9,ye(" "+_e(this.tracing?"Tracing...":"Trace It!"),1)],8,K9)]),h("div",q9,[$e(Wi,{name:"ping"},{default:Me(()=>[this.tracerouteResult?(D(),F("div",J9,[h("table",X9,[Q9,h("tbody",null,[(D(!0),F(Te,null,Ue(this.tracerouteResult,(r,a)=>(D(),F("tr",{class:"animate__fadeInUp animate__animated",style:Wt({"animation-delay":`${a*.05}s`})},[h("td",null,_e(r.hop),1),h("td",null,_e(r.ip),1),h("td",null,_e(r.avg_rtt)+" / "+_e(r.min_rtt)+" / "+_e(r.max_rtt),1)],4))),256))])])])):(D(),F("div",G9,[(D(),F(Te,null,Ue(10,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.tracing}]),style:Wt({"animation-delay":`${r*.05}s`})},null,6)),64))]))]),_:1})])])])])}const eq=ze(B9,[["render",Z9],["__scopeId","data-v-606c2c93"]]),tq={name:"totp",async setup(){const e=et();let t="";return await xt("/api/Welcome_GetTotpLink",{},n=>{n.status&&(t=n.data)}),{l:t,store:e}},mounted(){this.l&&Bo.toCanvas(document.getElementById("qrcode"),this.l,function(e){})},data(){return{totp:"",totpInvalidMessage:"",verified:!1}},methods:{validateTotp(){}},watch:{totp(e){const t=document.querySelector("#totp");t.classList.remove("is-invalid","is-valid"),e.length===6&&(console.log(e),/[0-9]{6}/.test(e)?ft("/api/Welcome_VerifyTotpLink",{totp:e},n=>{n.status?(this.verified=!0,t.classList.add("is-valid"),this.$emit("verified")):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP does not match.")}):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP can only contain numbers"))}}},nq=["data-bs-theme"],sq={class:"m-auto text-body",style:{width:"500px"}},iq={class:"d-flex flex-column"},oq=h("h1",{class:"dashboardLogo display-4"},"Multi-Factor Authentication",-1),rq=h("p",{class:"mb-2"},[h("small",{class:"text-muted"},"1. Please scan the following QR Code to generate TOTP")],-1),aq=h("canvas",{id:"qrcode",class:"rounded-3 mb-2"},null,-1),lq={class:"p-3 bg-body-secondary rounded-3 border mb-3"},cq=h("p",{class:"text-muted mb-0"},[h("small",null,"Or you can click the link below:")],-1),uq=["href"],dq={style:{"line-break":"anywhere"}},hq=h("label",{for:"totp",class:"mb-2"},[h("small",{class:"text-muted"},"2. Enter the TOTP generated by your authenticator to verify")],-1),fq={class:"form-group mb-2"},pq=["disabled"],gq={class:"invalid-feedback"},mq=h("div",{class:"valid-feedback"}," TOTP verified! ",-1),_q=h("div",{class:"alert alert-warning rounded-3"},[h("i",{class:"bi bi-exclamation-triangle-fill me-2"}),ye(" If you ever lost your TOTP and can't login, please follow instruction on "),h("a",{href:"https://github.com/donaldzou/WGDashboard",target:"_blank"},"readme.md"),ye(" to reset. ")],-1),vq=h("hr",null,null,-1),bq={class:"d-flex gap-3 mt-5 flex-column"},yq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1),wq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1);function xq(e,t,n,s,i,o){const r=je("RouterLink");return D(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.store.Configuration.Server.dashboard_theme},[h("div",sq,[h("div",iq,[h("div",null,[oq,rq,aq,h("div",lq,[cq,h("a",{href:this.l},[h("code",dq,_e(this.l),1)],8,uq)]),hq,h("div",fq,[Re(h("input",{class:"form-control text-center totp",id:"totp",maxlength:"6",type:"text",inputmode:"numeric",autocomplete:"one-time-code","onUpdate:modelValue":t[0]||(t[0]=a=>this.totp=a),disabled:this.verified},null,8,pq),[[We,this.totp]]),h("div",gq,_e(this.totpInvalidMessage),1),mq]),_q]),vq,h("div",bq,[this.verified?(D(),Ne(r,{key:1,to:"/",class:"btn btn-dark btn-lg d-flex btn-brand shadow align-items-center flex-grow-1 rounded-3"},{default:Me(()=>[ye(" Complete "),wq]),_:1})):(D(),Ne(r,{key:0,to:"/",class:"btn bg-secondary-subtle text-secondary-emphasis rounded-3 flex-grow-1 btn-lg border-1 border-secondary-subtle shadow d-flex"},{default:Me(()=>[ye(" I don't need MFA "),yq]),_:1}))])])])],8,nq)}const kq=ze(tq,[["render",xq]]),Sq={name:"share",async setup(){const e=tP(),t=be(!1),n=et(),s=be(""),i=be(""),o=be(new Blob);await xt("/api/getDashboardTheme",{},a=>{s.value=a.data});const r=e.query.ShareID;return r===void 0||r.length===0?(i.value=void 0,t.value=!0):await xt("/api/sharePeer/get",{ShareID:r},a=>{a.status?(i.value=a.data,o.value=new Blob([i.value.file],{type:"text/plain"})):i.value=void 0,t.value=!0}),{store:n,theme:s,peerConfiguration:i,blob:o}},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfiguration.file,e=>{e&&console.error(e)})},methods:{download(){const e=new Blob([this.peerConfiguration.file],{type:"text/plain"}),t=URL.createObjectURL(e),n=`${this.peerConfiguration.fileName}.conf`,s=document.createElement("a");s.href=t,s.download=n,s.click()}},computed:{getBlob(){return URL.createObjectURL(this.blob)}}},hp=e=>(Ut("data-v-99d4b06a"),e=e(),qt(),e),$q=["data-bs-theme"],Aq={class:"m-auto text-body",style:{width:"500px"}},Cq={key:0,class:"text-center position-relative",style:{}},Eq=QA('

Oh no... This link is either expired or invalid.

',2),Pq=[Eq],Mq={key:1,class:"d-flex align-items-center flex-column gap-3"},Tq=hp(()=>h("div",{class:"h1 dashboardLogo text-center animate__animated animate__fadeInUp"},[h("h6",null,"WGDashboard"),ye(" Scan QR Code from the WireGuard App ")],-1)),Dq={id:"qrcode",class:"rounded-3 shadow animate__animated animate__fadeInUp mb-3",ref:"qrcode"},Oq=hp(()=>h("p",{class:"text-muted animate__animated animate__fadeInUp mb-1",style:{"animation-delay":"0.2s"}},[ye("or click the button below to download the "),h("samp",null,".conf"),ye(" file")],-1)),Iq=["download","href"],Rq=hp(()=>h("i",{class:"bi bi-download"},null,-1)),Lq=[Rq];function Nq(e,t,n,s,i,o){return D(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.theme},[h("div",Aq,[this.peerConfiguration?(D(),F("div",Mq,[Tq,h("canvas",Dq,null,512),Oq,h("a",{download:this.peerConfiguration.fileName+".conf",href:o.getBlob,class:"btn btn-lg bg-primary-subtle text-primary-emphasis border-1 border-primary-subtle animate__animated animate__fadeInUp shadow-sm",style:{"animation-delay":"0.25s"}},Lq,8,Iq)])):(D(),F("div",Cq,Pq))])],8,$q)}const Fq=ze(Sq,[["render",Nq],["__scopeId","data-v-99d4b06a"]]),Bq=async()=>{let e=!1;return await xt("/api/validateAuthentication",{},t=>{e=t.status}),e},gl=ZE({history:mE(),routes:[{name:"Index",path:"/",component:GP,meta:{requiresAuth:!0},children:[{name:"Configuration List",path:"",component:IT,meta:{title:"WireGuard Configurations"}},{name:"Settings",path:"/settings",component:L3,meta:{title:"Settings"}},{path:"/ping",name:"Ping",component:F9},{path:"/traceroute",name:"Traceroute",component:eq},{name:"New Configuration",path:"/new_configuration",component:v5,meta:{title:"New Configuration"}},{name:"Configuration",path:"/configuration/:id",component:x5,meta:{title:"Configuration"},children:[{name:"Peers List",path:"peers",component:n9},{name:"Peers Create",path:"create",component:U1}]}]},{path:"/signin",component:ZM,meta:{title:"Sign In"}},{path:"/welcome",component:iN,meta:{requiresAuth:!0,title:"Welcome to WGDashboard"}},{path:"/2FASetup",component:kq,meta:{requiresAuth:!0,title:"Multi-Factor Authentication Setup"}},{path:"/share",component:Fq,meta:{title:"Share"}}]});gl.beforeEach(async(e,t,n)=>{const s=Bn(),i=et();e.meta.title?e.params.id?document.title=e.params.id+" | WGDashboard":document.title=e.meta.title+" | WGDashboard":document.title="WGDashboard",i.ShowNavBar=!1;const o=await Bq();e.meta.requiresAuth&&!o?i.getActiveCrossServer()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),n()):nP.getCookie("authToken")&&o?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),i.Redirect=void 0,n()):(i.Redirect=e,n("/signin"),i.newMessage("WGDashboard","Session Ended","warning")):(await i.getConfiguration(),e.path==="/signin"&&o?n("/"):n())});const J1=()=>{let e={"content-type":"application/json"};const n=et().getActiveCrossServer();return n&&(e["wg-dashboard-apikey"]=n.apiKey),e},X1=e=>{const n=et().getActiveCrossServer();return n?`${n.host}${e}`:`${window.location.protocol}//${(window.location.host+window.location.pathname+e).replace(/\/\//g,"/")}`},xt=async(e,t=void 0,n=void 0)=>{const s=new URLSearchParams(t);await fetch(`${X1(e)}?${s.toString()}`,{headers:J1()}).then(i=>{const o=et();if(i.ok)return i.json();if(i.status!==200)throw i.status===401&&o.newMessage("WGDashboard","Session Ended","warning"),new Error(i.statusText)}).then(i=>n?n(i):void 0).catch(i=>{console.log(i),gl.push({path:"/signin"})})},ft=async(e,t,n)=>{await fetch(`${X1(e)}`,{headers:J1(),method:"POST",body:JSON.stringify(t)}).then(s=>{const i=et();if(s.ok)return s.json();if(s.status!==200)throw s.status===401&&i.newMessage("WGDashboard","Session Ended","warning"),new Error(s.statusText)}).then(s=>n?n(s):void 0).catch(s=>{console.log(s),gl.push({path:"/signin"})})},et=bf("DashboardConfigurationStore",{state:()=>({Redirect:void 0,Configuration:void 0,Messages:[],Peers:{Selecting:!1,RefreshInterval:void 0},CrossServerConfiguration:{Enable:!1,ServerList:{}},ActiveServerConfiguration:void 0,IsElectronApp:!1,ShowNavBar:!1}),actions:{initCrossServerConfiguration(){const e=localStorage.getItem("CrossServerConfiguration");localStorage.getItem("ActiveCrossServerConfiguration")!==null&&(this.ActiveServerConfiguration=localStorage.getItem("ActiveCrossServerConfiguration")),e===null?window.localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration)):this.CrossServerConfiguration=JSON.parse(e)},syncCrossServerConfiguration(){window.localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration))},addCrossServerConfiguration(){this.CrossServerConfiguration.ServerList[Ts().toString()]={host:"",apiKey:"",active:!1}},deleteCrossServerConfiguration(e){delete this.CrossServerConfiguration.ServerList[e]},getActiveCrossServer(){const e=localStorage.getItem("ActiveCrossServerConfiguration");if(e!==null)return this.CrossServerConfiguration.ServerList[e]},setActiveCrossServer(e){this.ActiveServerConfiguration=e,localStorage.setItem("ActiveCrossServerConfiguration",e)},removeActiveCrossServer(){this.ActiveServerConfiguration=void 0,localStorage.removeItem("ActiveCrossServerConfiguration")},async getConfiguration(){await xt("/api/getDashboardConfiguration",{},e=>{e.status&&(this.Configuration=e.data)})},async signOut(){await xt("/api/signout",{},e=>{this.removeActiveCrossServer(),this.$router.go("/signin")})},newMessage(e,t,n){this.Messages.push({id:Ts(),from:e,content:t,type:n,show:!0})}}}),fp=e=>(Ut("data-v-a29399d4"),e=e(),qt(),e),Vq={class:"navbar bg-dark sticky-top","data-bs-theme":"dark"},Hq={class:"container-fluid d-flex text-body align-items-center"},jq=fp(()=>h("span",{class:"navbar-brand mb-0 h1"},"WGDashboard",-1)),Wq={key:0,class:"ms-auto text-muted"},zq=fp(()=>h("i",{class:"bi bi-server me-2"},null,-1)),Yq=fp(()=>h("i",{class:"bi bi-list"},null,-1)),Kq=[Yq],Uq={__name:"App",setup(e){const t=et();t.initCrossServerConfiguration(),window.IS_WGDASHBOARD_DESKTOP&&(t.IsElectronApp=!0,t.CrossServerConfiguration.Enable=!0),Vt(t.CrossServerConfiguration,()=>{t.syncCrossServerConfiguration()},{deep:!0});const n=ve(()=>{if(t.ActiveServerConfiguration)return t.CrossServerConfiguration.ServerList[t.ActiveServerConfiguration]});return(s,i)=>(D(),F(Te,null,[h("nav",Vq,[h("div",Hq,[jq,n.value!==void 0?(D(),F("small",Wq,[zq,ye(_e(n.value.host),1)])):re("",!0),h("a",{role:"button",class:"navbarBtn text-body",onClick:i[0]||(i[0]=o=>q(t).ShowNavBar=!q(t).ShowNavBar),style:{"line-height":"0","font-size":"2rem"}},Kq)])]),(D(),Ne(uf,null,{default:Me(()=>[$e(q(ky),null,{default:Me(({Component:o})=>[$e(Ct,{name:"app",mode:"out-in"},{default:Me(()=>[(D(),Ne(Io(o)))]),_:2},1024)]),_:1})]),_:1}))],64))}},qq=ze(Uq,[["__scopeId","data-v-a29399d4"]]),pp=jC(qq);pp.use(gl);const Q1=KC();Q1.use(({store:e})=>{e.$router=tu(gl)});pp.use(Q1);pp.mount("#app"); diff --git a/src/static/app/src/router/index.js b/src/static/app/src/router/index.js index cebf371..ee50232 100644 --- a/src/static/app/src/router/index.js +++ b/src/static/app/src/router/index.js @@ -164,7 +164,7 @@ router.beforeEach(async (to, from, next) => { } }else { await dashboardConfigurationStore.getConfiguration() - if (to.path === "/signin"){ + if (to.path === "/signin" && auth){ next("/") }else{ next()