Dawnline 0.9.0
- Portal: Reconnect replaces New keys and the connection sheet (QR, Key,
File, and the menu's QR, key and .conf items). It gives the device new
keys, shows it as "Not set up yet" until it connects with them (in the
admin too) and opens the set-up sheet on the new configuration; "Update
the connection" goes the same way. Reconnect is orange in the menu
- iPhone: "Open in AmneziaVPN" is "Send to AmneziaVPN": the key goes in as
a .vpn file from the share sheet. AmneziaVPN takes vpn:// links only on
Android; on iOS Safari said the address was invalid, or another app that
claims vpn:// got the key. The desktop "Open in AmneziaVPN" link is gone
- A computer set up from a phone: get the app, add the connection, then
"Or open your link on the computer"; "Another app" offers AmneziaWG and
WireGuard there too and step 2 follows the pick. "Other" devices pick any
system (iPhone/iPad, Android, Windows, Mac, Linux); the page counts as the
device in hand only when the pick is its own system
- Import steps in each app's own words (iOS "+ → Create from file or
archive", Android "+ → Import from file or archive", Mac, Windows "Add
Tunnel → Import tunnel(s) from file"); Linux gets the awg-quick command
- Files are shared only on iOS (on Android the apps take no shared files:
a download there), and alone: with a title, "Save to Files" also wrote
the title as a .txt
- Files and tunnels are named after the server ("Outline Home" →
Outline-Home.conf and .vpn) in the form every client accepts: letters,
digits and "-", 15 characters, no Windows device names. The admin's
downloads keep the device in the name. The AmneziaVPN key's description
is the server's name alone
- The AmneziaVPN QR code holds the key without "vpn://": AmneziaVPN's
scanner decodes the text as it is and failed on the prefix
- "This device" also when the page is opened beside the tunnel: the apps
route the VPN's own address, which the portal shares, around their
tunnel, so the one online device whose tunnel comes from the page's
address is the one
- Fixed: "Already has AmneziaVPN?Copy the key" lost its space
This commit is contained in:
1 parent
7a6370aa9e
commit
739f027c91
22 files changed
+389
-474
No files matched your search
@@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-dawnline
|
PKG_NAME:=luci-app-dawnline
|
||||||
PKG_VERSION:=0.8.1
|
PKG_VERSION:=0.9.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ ${p.detail}`:""}`,where:Ot[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({
|
|||||||
`),hostName:i,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(r.port),protocol_version:o.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return r.dns[0]&&(l.dns1=r.dns[0]),r.dns[1]&&(l.dns2=r.dns[1]),l}function Zi(n){let e="";for(let r=0;r<n.length;r+=32768)e+=String.fromCharCode(...n.subarray(r,r+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Qi(n){let e=globalThis;if(typeof e.CompressionStream>"u")return null;try{let r=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),o=new Uint8Array(await new e.Response(r).arrayBuffer()),a=new Uint8Array(4+o.length);return new DataView(a.buffer).setUint32(0,n.length,!1),a.set(o,4),a}catch{return null}}async function to(n,e,r=!0){let o=new TextEncoder().encode(JSON.stringify(Yi(n,e))),a=r?await Qi(o):null;return`vpn://${Zi(a??o)}`}var mr=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"balanced",title:"Balanced",ic:"shield",stealth:3,speed:4,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],jt=n=>mr.find(e=>e.id===n),mn=n=>n.v3?"max":n.v2?"balanced":"off",Ut=n=>n==="standard"?"Standard (old)":n==="strong"?"Strong (old)":null,Xi={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},es={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function ur(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(r=>t("i",{class:r<n?"on":""})))])}function hn(n,e,r,o,a=!0){let i=t("div",{class:"dl-methods",role:"radiogroup","aria-label":"Disguise method"}),s=()=>dom.content(i,mr.map(l=>{let d=!l.needs||n[l.needs],c=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,s(),r(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},b(l.ic)),t("b",{},l.title),l.id===o?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[ur(l.stealth,"Stealth"),ur(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},d?[b(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[b("alert"),t("span",{},(a?Xi:es)[l.needs])])])}));return s(),i}function hr(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var fr=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function ts(n){let e=c=>n[c]!=null&&n[c]!=="",r=fr.filter(([c])=>e(c));if(!r.length)return null;let o=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),a=(c,p,u,x)=>{let $=fr.filter(([h])=>x.includes(h)&&e(h));return $.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[b(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},$.map(([h,m])=>o(h,m)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=r.map(([c,p])=>`${p} = ${n[c]}`).join(`
|
`),hostName:i,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(r.port),protocol_version:o.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return r.dns[0]&&(l.dns1=r.dns[0]),r.dns[1]&&(l.dns2=r.dns[1]),l}function Zi(n){let e="";for(let r=0;r<n.length;r+=32768)e+=String.fromCharCode(...n.subarray(r,r+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Qi(n){let e=globalThis;if(typeof e.CompressionStream>"u")return null;try{let r=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),o=new Uint8Array(await new e.Response(r).arrayBuffer()),a=new Uint8Array(4+o.length);return new DataView(a.buffer).setUint32(0,n.length,!1),a.set(o,4),a}catch{return null}}async function to(n,e,r=!0){let o=new TextEncoder().encode(JSON.stringify(Yi(n,e))),a=r?await Qi(o):null;return`vpn://${Zi(a??o)}`}var mr=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"balanced",title:"Balanced",ic:"shield",stealth:3,speed:4,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],jt=n=>mr.find(e=>e.id===n),mn=n=>n.v3?"max":n.v2?"balanced":"off",Ut=n=>n==="standard"?"Standard (old)":n==="strong"?"Strong (old)":null,Xi={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},es={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function ur(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(r=>t("i",{class:r<n?"on":""})))])}function hn(n,e,r,o,a=!0){let i=t("div",{class:"dl-methods",role:"radiogroup","aria-label":"Disguise method"}),s=()=>dom.content(i,mr.map(l=>{let d=!l.needs||n[l.needs],c=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,s(),r(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},b(l.ic)),t("b",{},l.title),l.id===o?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[ur(l.stealth,"Stealth"),ur(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},d?[b(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[b("alert"),t("span",{},(a?Xi:es)[l.needs])])])}));return s(),i}function hr(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var fr=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function ts(n){let e=c=>n[c]!=null&&n[c]!=="",r=fr.filter(([c])=>e(c));if(!r.length)return null;let o=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),a=(c,p,u,x)=>{let $=fr.filter(([h])=>x.includes(h)&&e(h));return $.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[b(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},$.map(([h,m])=>o(h,m)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=r.map(([c,p])=>`${p} = ${n[c]}`).join(`
|
||||||
`),d=t("div",{class:"dl-pgrid"},[a("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),a("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),a("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),a("Signatures","globe",s,["i1","i2","i3","i4","i5"]),a("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),a("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(r.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),ue(l,"Parameters copied")}},"Copy as config")]),d])}function gr(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!r)return document.createTextNode(n);let o=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},r[1])," ",o&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):r[2]])}function ns(n){let e=!1,r=t("pre",{class:"dl-conf"}),o=()=>dom.content(r,n.conf.split(`
|
`),d=t("div",{class:"dl-pgrid"},[a("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),a("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),a("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),a("Signatures","globe",s,["i1","i2","i3","i4","i5"]),a("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),a("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(r.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),ue(l,"Parameters copied")}},"Copy as config")]),d])}function gr(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!r)return document.createTextNode(n);let o=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},r[1])," ",o&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):r[2]])}function ns(n){let e=!1,r=t("pre",{class:"dl-conf"}),o=()=>dom.content(r,n.conf.split(`
|
||||||
`).flatMap((s,l)=>l?[`
|
`).flatMap((s,l)=>l?[`
|
||||||
`,gr(s,e)]:[gr(s,e)])),a=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(a,[b(e?"x":"key"),e?"Hide key":"Show key"]),o()}},[b("key"),"Show key"]);o();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),H([b("download")," Download"],()=>Te(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),a,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[b("copy"),"Copy"])]),r])])}function no(n){let e=n.amnezia.obfuscation??{},r={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([o,a])=>a==null||a===""||a===(r[o]??"0"))}async function os(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let r=await to(n,`${n.server} · ${n.person} · ${n.name}`),o={qr:()=>t("div",{class:"dl-qr-pane"},[et(Lt(n.conf),"dl-qr"),t("span",{class:"dl-sub"},no(n)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},r),H("Copy",()=>ue(r,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>ns(n)},a=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(a,o[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(e),t("div",{class:"dl-stack gap12"},[i,a])}async function rs(n,e,r,o){let a=jt(r),s=n.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await le(o?"Generate new disguise values?":`Switch to ${a.title}?`,`${s} AmneziaWG device${s===1?" stops":"s stop"} connecting until ${s===1?"it imports its":"they import their"} configuration again (from their personal link or from you).${r==="max"?" They need an app with AmneziaWG 3.1.":r==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}${n.st.servers.length===1&&s?" To keep the old disguise for some people, add a second server and move them there.":""}`,o?"Generate and apply":"Switch and apply",!0)&&await G(()=>A.serverObfuscation(e.id,r),o?"New values applied":`${a.title} applied`)&&(U("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function as(n,e){let r=n.st,o=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=jt(e.preset)?e.preset:void 0,l=s??mn(r.awg),d=H("",()=>rs(n,e,l,l===s),"neutral"),c=()=>dom.content(d,l===s?[b("reset")," Generate new values"]:[`Switch to ${jt(l).title}`]);c();let p=r.awg_state?.tools!==!1,u=[],x=he("UDP port",o,()=>It(Number(o.value),u,`Opened on the WAN firewall automatically.${Number(o.value)===4500?" 4500 is IPsec’s port: most networks let it through.":""}`));A.serverPorts(e.id).then(m=>{u=m.udp_taken??[],x.refresh()}).catch(()=>{});let $=he("MTU",a,()=>Fo(a.value,e.mtus)),h=he("Keep-alive",i,()=>qo(i.value));return Rt("",[hr("AmneziaWG",e.ifname),fe("globe","Listening","Where devices reach this core from the internet",[x]),fe("file","In every device configuration","Changing these marks devices “Update config” until they import again",[$,h]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Ut(e.preset)?pt("warn",[t("b",{},Ut(e.preset))," is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ",t("b",{},"Balanced")," or ",t("b",{},"Maximum"),": devices import their configuration again."]):"",hn(r.awg,l,m=>{l=m,c()},s,p),p&&!r.awg.v3?pt("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",ts(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ce("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ce("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet)
Line truncated
|
`,gr(s,e)]:[gr(s,e)])),a=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(a,[b(e?"x":"key"),e?"Hide key":"Show key"]),o()}},[b("key"),"Show key"]);o();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),H([b("download")," Download"],()=>Te(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),a,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[b("copy"),"Copy"])]),r])])}function no(n){let e=n.amnezia.obfuscation??{},r={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([o,a])=>a==null||a===""||a===(r[o]??"0"))}async function os(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let r=await to(n,n.server),o={qr:()=>t("div",{class:"dl-qr-pane"},[et(Lt(n.conf),"dl-qr"),t("span",{class:"dl-sub"},no(n)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},r),H("Copy",()=>ue(r,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>ns(n)},a=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(a,o[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(e),t("div",{class:"dl-stack gap12"},[i,a])}async function rs(n,e,r,o){let a=jt(r),s=n.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await le(o?"Generate new disguise values?":`Switch to ${a.title}?`,`${s} AmneziaWG device${s===1?" stops":"s stop"} connecting until ${s===1?"it imports its":"they import their"} configuration again (from their personal link or from you).${r==="max"?" They need an app with AmneziaWG 3.1.":r==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}${n.st.servers.length===1&&s?" To keep the old disguise for some people, add a second server and move them there.":""}`,o?"Generate and apply":"Switch and apply",!0)&&await G(()=>A.serverObfuscation(e.id,r),o?"New values applied":`${a.title} applied`)&&(U("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function as(n,e){let r=n.st,o=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=jt(e.preset)?e.preset:void 0,l=s??mn(r.awg),d=H("",()=>rs(n,e,l,l===s),"neutral"),c=()=>dom.content(d,l===s?[b("reset")," Generate new values"]:[`Switch to ${jt(l).title}`]);c();let p=r.awg_state?.tools!==!1,u=[],x=he("UDP port",o,()=>It(Number(o.value),u,`Opened on the WAN firewall automatically.${Number(o.value)===4500?" 4500 is IPsec’s port: most networks let it through.":""}`));A.serverPorts(e.id).then(m=>{u=m.udp_taken??[],x.refresh()}).catch(()=>{});let $=he("MTU",a,()=>Fo(a.value,e.mtus)),h=he("Keep-alive",i,()=>qo(i.value));return Rt("",[hr("AmneziaWG",e.ifname),fe("globe","Listening","Where devices reach this core from the internet",[x]),fe("file","In every device configuration","Changing these marks devices “Update config” until they import again",[$,h]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Ut(e.preset)?pt("warn",[t("b",{},Ut(e.preset))," is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ",t("b",{},"Balanced")," or ",t("b",{},"Maximum"),": devices import their configuration again."]):"",hn(r.awg,l,m=>{l=m,c()},s,p),p&&!r.awg.v3?pt("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",ts(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ce("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ce("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."
Line truncated
|
||||||
`),"Log copied"))]),p,u]),[x],"wide"),h([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},a?"Checking…":"Working…")]);let C=r??null,B=r?.id,w,v=0,y=f=>{B!==f.id&&(B=f.id,e.onJob?.(f))};if(r)e.onJob?.(r);else try{let f=await A.updatesStatus().catch(()=>null);w=f?.job?.id,v=f?.now??0;let g=await A.updatesRun(n);g.job&&g.job.state==="running"&&g.job.id!==w&&(C=g.job,y(g.job))}catch(f){return $=[be(f)],p.textContent=$[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},be(f))])),h([m(!0)]),U(be(f),"error"),null}let E=null,k=0;for(;;){if(await sa(1e3),E=await A.updatesStatus().catch(()=>null),!E){if(++k>60)break;continue}k=0;let f=E.job;if(!f||!ia(f,B,w,v)){if(Date.now()-i>15e3)break;continue}if(y(f),C=f,f.log.length){$=f.log;let g=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=$.join(`
|
`),"Log copied"))]),p,u]),[x],"wide"),h([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},a?"Checking…":"Working…")]);let C=r??null,B=r?.id,w,v=0,y=f=>{B!==f.id&&(B=f.id,e.onJob?.(f))};if(r)e.onJob?.(r);else try{let f=await A.updatesStatus().catch(()=>null);w=f?.job?.id,v=f?.now??0;let g=await A.updatesRun(n);g.job&&g.job.state==="running"&&g.job.id!==w&&(C=g.job,y(g.job))}catch(f){return $=[be(f)],p.textContent=$[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},be(f))])),h([m(!0)]),U(be(f),"error"),null}let E=null,k=0;for(;;){if(await sa(1e3),E=await A.updatesStatus().catch(()=>null),!E){if(++k>60)break;continue}k=0;let f=E.job;if(!f||!ia(f,B,w,v)){if(Date.now()-i>15e3)break;continue}if(y(f),C=f,f.log.length){$=f.log;let g=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=$.join(`
|
||||||
`),g&&(p.scrollTop=p.scrollHeight)}if(l.textContent=ra(f,e.version??""),!l.isConnected&&l.textContent&&s.after(l),c.textContent=oa((f.finished??E.now)-f.started),f.state==="running"){d.hidden=!f.phase,d.textContent=f.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!C||C.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),h([m()]),e.onDone?.(E),C;if(C.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[b("x"),t("span",{},[t("b",{},C.error??"Operation failed"),a?"":". Nothing else was changed."])])),h([H("Copy log",()=>ue($.join(`
|
`),g&&(p.scrollTop=p.scrollHeight)}if(l.textContent=ra(f,e.version??""),!l.isConnected&&l.textContent&&s.after(l),c.textContent=oa((f.finished??E.now)-f.started),f.state==="running"){d.hidden=!f.phase,d.textContent=f.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!C||C.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),h([m()]),e.onDone?.(E),C;if(C.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[b("x"),t("span",{},[t("b",{},C.error??"Operation failed"),a?"":". Nothing else was changed."])])),h([H("Copy log",()=>ue($.join(`
|
||||||
`),"Log copied")),m(!0)]),U(`${Ln[o]??"Update"}: ${C.error??"failed"}`,"error"),e.onDone?.(E),C;if(d.className="dl-pill ok",d.textContent="Finished",a&&E){let f=aa(E,o);if(dom.content(u,t("div",{class:`dl-comp-status ${f.tone}`},[b(f.tone==="ok"?"check":f.tone==="warn"?"alert":"download"),t("span",{},f.text)])),U(f.text,f.tone==="warn"?"warning":"success"),e.onDone?.(E),f.update&&e.onUpdate){let g=E;h([m(),H(`Update to ${f.update}`,()=>e.onUpdate(g),"positive")])}else h([m()]),f.tone==="ok"&&setTimeout(()=>u.isConnected&&ae(),1200);return C}if(o==="app"&&C.to){let f=C.to,g=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},[t("b",{},`Dawnline ${f} is installed. `),g])]));let S=()=>{ui.menu?.flushCache(),location.reload()};h([m(),H("Reload now",S,"positive")]),U(`Dawnline updated to ${f}`,"success",6e3);for(let T=1;T<=30;T++)if(g.textContent=`Waiting for the router to restart its services (${T} of 30)…`,await sa(1500),(await A.updatesStatus().catch(()=>null))?.version===f)return g.textContent="Services are back. Reloading…",setTimeout(S,800),C;return g.textContent="Services restarted. Reload the page to use the new version.",C}let z=o==="pkgs"?`Updated ${[...C.result?.pkgs?.updated??[],...C.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:o==="amneziawg"?`AmneziaWG${C.to?` ${C.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},z)])),h([m()]),U(z,"success"),e.onDone?.(E),C}var Ps={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function la(n,e,r,o){return!await le(`Install ${e}?`,r,"Install")||(await Jt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>o?.(),4e3),!0)}function Sn(n){return la("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Yt(n,e,r){return n==="awg"?Sn(r):e.length?la(`pkgs:${e.join(",")}`,Ps[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,r):!0}async function da(n,e){if(n==="awg")return Sn(e);let r=await G(()=>A.updatesStatus());return r?Yt(n,r.needs?.[n]??[],e):!1}var Ds=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],As={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function ca(n,e,r){let o=n.id,a=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",c=!0,p=!0,u="all",x=!1,$=ea(a,o,r),h=new Set,m="",C=()=>JSON.stringify([p,l,l?"":d,c,[...h].sort()]),B=()=>s.detected.lan||s.saved.lan||"",w=()=>(l?s.detected.wan||s.saved.wan:d)||"",v=()=>new Map(s.devices.map(R=>[R.name,R])),y=()=>{let R=v();return[...c&&B()?[B()]:[],...[...h].filter(Z=>Z!==B())].filter(Z=>Z!==w()).map(Z=>R.get(Z)??{name:Z,nets:[],missing:!0})},E=(R,K)=>{s=R,K&&(l=R.config.auto_wan,d=R.config.wan_device||R.detected.wan||R.saved.wan||"",c=R.config.auto_lan,p=R.config.lan_like,u=R.config.mesh??(R.config.device_mesh?"all":"off"),h=new Set(R.config.lan_devices),m=C()),q()},k=async R=>{let K=await A.interfaces(o).catch(Z=>(U(Z.message,"error"),null));K&&E(K,R)};function z(R){let K=c&&R.name===B(),Z=!!R.own||!!R.master||R.name===w()||K;return K||h.has(R.name)||!Z&&(R.nets.length>0||!!R.missing)}function f(R){let K=c&&R.name===B(),Z=R.name===w(),de=!K&&h.has(R.name),te=!(!!R.own||!!R.master||Z||K)&&(R.nets.length>0||de||!!R.missing),ge=(de||K)&&!R.zone&&!R.missing,O=R.missing?"Not present right now":R.own?"This server":R.master?`Port of ${R.master}`:Z?`Internet${R.zone?` · zone ${R.zone}`:""}`:R.nets.length?R.nets.join(", "):"No IPv4 network",X=t("button",{type:"button",class:`dl-if${de?" sel":""}${K?" auto":""}${!te&&!de&&!K?" off":""}${ge?" warn":""}`,"aria-pressed":de||K?"true":"false","aria-disabled":te?null:"true",click:()=>{te&&(h.has(R.name)?h.delete(R.name):h.add(R.name),q())}},[t("span",{class:"dl-if-ic"},b(As[R.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},R.name),t("span",{class:"dl-if-sub"},O)]),K?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},b("check")):""]);return me(X,()=>[t("div",{class:"dl-tip-title"},R.name),t("div",{class:"dl-muted"},[R.logical?`Interface ${R.logical}`:"No netifd interface",R.zone?` · zone ${R.zone}`:" · no firewall zone"]),R.members.length?t("div",{class:"dl-muted"},`Ports: ${R.members.join(", ")}`):"",R.nets.length?t("div",{class:"dl-mono"},R.nets.join(", ")):"",ge?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",R.master?t("div",{class:"dl-muted"},`Choose ${R.master} to include it.`):""]),X}function g(){let R=s.like_home;return!p||!s.config.lan_
Line truncated
|
`),"Log copied")),m(!0)]),U(`${Ln[o]??"Update"}: ${C.error??"failed"}`,"error"),e.onDone?.(E),C;if(d.className="dl-pill ok",d.textContent="Finished",a&&E){let f=aa(E,o);if(dom.content(u,t("div",{class:`dl-comp-status ${f.tone}`},[b(f.tone==="ok"?"check":f.tone==="warn"?"alert":"download"),t("span",{},f.text)])),U(f.text,f.tone==="warn"?"warning":"success"),e.onDone?.(E),f.update&&e.onUpdate){let g=E;h([m(),H(`Update to ${f.update}`,()=>e.onUpdate(g),"positive")])}else h([m()]),f.tone==="ok"&&setTimeout(()=>u.isConnected&&ae(),1200);return C}if(o==="app"&&C.to){let f=C.to,g=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},[t("b",{},`Dawnline ${f} is installed. `),g])]));let S=()=>{ui.menu?.flushCache(),location.reload()};h([m(),H("Reload now",S,"positive")]),U(`Dawnline updated to ${f}`,"success",6e3);for(let T=1;T<=30;T++)if(g.textContent=`Waiting for the router to restart its services (${T} of 30)…`,await sa(1500),(await A.updatesStatus().catch(()=>null))?.version===f)return g.textContent="Services are back. Reloading…",setTimeout(S,800),C;return g.textContent="Services restarted. Reload the page to use the new version.",C}let z=o==="pkgs"?`Updated ${[...C.result?.pkgs?.updated??[],...C.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:o==="amneziawg"?`AmneziaWG${C.to?` ${C.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},z)])),h([m()]),U(z,"success"),e.onDone?.(E),C}var Ps={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function la(n,e,r,o){return!await le(`Install ${e}?`,r,"Install")||(await Jt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>o?.(),4e3),!0)}function Sn(n){return la("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Yt(n,e,r){return n==="awg"?Sn(r):e.length?la(`pkgs:${e.join(",")}`,Ps[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,r):!0}async function da(n,e){if(n==="awg")return Sn(e);let r=await G(()=>A.updatesStatus());return r?Yt(n,r.needs?.[n]??[],e):!1}var Ds=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],As={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function ca(n,e,r){let o=n.id,a=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",c=!0,p=!0,u="all",x=!1,$=ea(a,o,r),h=new Set,m="",C=()=>JSON.stringify([p,l,l?"":d,c,[...h].sort()]),B=()=>s.detected.lan||s.saved.lan||"",w=()=>(l?s.detected.wan||s.saved.wan:d)||"",v=()=>new Map(s.devices.map(R=>[R.name,R])),y=()=>{let R=v();return[...c&&B()?[B()]:[],...[...h].filter(Z=>Z!==B())].filter(Z=>Z!==w()).map(Z=>R.get(Z)??{name:Z,nets:[],missing:!0})},E=(R,K)=>{s=R,K&&(l=R.config.auto_wan,d=R.config.wan_device||R.detected.wan||R.saved.wan||"",c=R.config.auto_lan,p=R.config.lan_like,u=R.config.mesh??(R.config.device_mesh?"all":"off"),h=new Set(R.config.lan_devices),m=C()),q()},k=async R=>{let K=await A.interfaces(o).catch(Z=>(U(Z.message,"error"),null));K&&E(K,R)};function z(R){let K=c&&R.name===B(),Z=!!R.own||!!R.master||R.name===w()||K;return K||h.has(R.name)||!Z&&(R.nets.length>0||!!R.missing)}function f(R){let K=c&&R.name===B(),Z=R.name===w(),de=!K&&h.has(R.name),te=!(!!R.own||!!R.master||Z||K)&&(R.nets.length>0||de||!!R.missing),ge=(de||K)&&!R.zone&&!R.missing,O=R.missing?"Not present right now":R.own?"This server":R.master?`Port of ${R.master}`:Z?`Internet${R.zone?` · zone ${R.zone}`:""}`:R.nets.length?R.nets.join(", "):"No IPv4 network",X=t("button",{type:"button",class:`dl-if${de?" sel":""}${K?" auto":""}${!te&&!de&&!K?" off":""}${ge?" warn":""}`,"aria-pressed":de||K?"true":"false","aria-disabled":te?null:"true",click:()=>{te&&(h.has(R.name)?h.delete(R.name):h.add(R.name),q())}},[t("span",{class:"dl-if-ic"},b(As[R.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},R.name),t("span",{class:"dl-if-sub"},O)]),K?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},b("check")):""]);return me(X,()=>[t("div",{class:"dl-tip-title"},R.name),t("div",{class:"dl-muted"},[R.logical?`Interface ${R.logical}`:"No netifd interface",R.zone?` · zone ${R.zone}`:" · no firewall zone"]),R.members.length?t("div",{class:"dl-muted"},`Ports: ${R.members.join(", ")}`):"",R.nets.length?t("div",{class:"dl-mono"},R.nets.join(", ")):"",ge?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",R.master?t("div",{class:"dl-muted"},`Choose ${R.master} to include it.`):""]),X}function g(){let R=s.like_home;return!p||!s.config.lan_
Line truncated
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{--ease-out: cubic-bezier(.23, 1, .32, 1);--ease-in: cubic-bezier(.55, 0, 1, .45);--ease-drawer: cubic-bezier(.32, .72, 0, 1);--spring: linear( 0, .022, .079, .158, .249, .344, .438, .527, .61, .684, .749, .805, .852, .891, .923, .949, .969, .984, .996, 1.004, 1.009, 1.013, 1.014, 1.015, 1.015, 1.014, 1.013, 1.012, 1.01, 1.009, 1.008, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1 );--spring-pop: linear( 0, .034, .122, .244, .383, .526, .662, .785, .889, .974, 1.038, 1.083, 1.111, 1.124, 1.126, 1.119, 1.106, 1.09, 1.072, 1.054, 1.038, 1.023, 1.01, 1, .993, .988, .985, .984, .984, .985, .987, .989, .992, .994, .996, .998, .999, 1, 1.001, 1.002, 1 );--dur-press: .12s;--dur-hover: .15s;--dur-pop: .18s;--dur-swap: .26s;--dur-enter: .44s;--dur-sheet: .44s;--dur-exit: .16s;--bg: #fcfcfc;--card: #ffffff;--elevated: #ffffff;--text: #0d0d0d;--muted: #5d5d5d;--faint: #8f8f8f;--line: #0000001a;--input: #00000026;--soft: #0d0d0d0d;--soft-hover: #0d0d0d1a;--primary: #0d0d0d;--primary-fg: #ffffff;--accent: #3a83f7;--info: #2c67c5;--ok: #00a240;--ok-wash: #00a24026;--warn: #e25507;--warn-wash: #e2550726;--bad: #e02e2a;--bad-wash: #e02e2a1f;--chart: #3a83f7;--track: #0d0d0d1a;--scrim: #00000040;--shadow: 0 1px 2px -1px #00000014;--shadow-xl: 0 8px 16px -4px #0000001f;--radius: 16px;--mono: "Geist Mono", ui-monospace, Menlo, monospace;color-scheme:light dark}@media(prefers-color-scheme:dark){:root{--bg: #000000;--card: #0a0a0a;--elevated: #131313;--text: #ededed;--muted: #edededa6;--faint: #ededed78;--line: #ededed13;--input: #ededed24;--soft: #ededed0d;--soft-hover: #ededed1a;--primary: #ededed;--primary-fg: #131313;--accent: #006efe;--info: #5ba2fe;--ok: #40c977;--ok-wash: #40c97726;--warn: #ff8549;--warn-wash: #ff854926;--bad: #ff6764;--bad-wash: #ff676422;--chart: #3a83f7;--track: #ededed1a;--scrim: #00000099;--shadow: none;--shadow-xl: 0 8px 16px -4px #00000080}}*{box-sizing:border-box}html,body{margin:0}html{scrollbar-gutter:stable}body{background:var(--bg);color:var(--text);font:400 15px/22px Geist,-apple-system,system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh;cursor:default}input,textarea,.keybox .mono,.linkrow .mono,.conf{cursor:text}body.locked{overflow:hidden}a{color:var(--info);text-decoration:none}a:hover{text-decoration:underline}a.btn:hover,a.badge:hover{text-decoration:none}h1,h2{margin:0;font-weight:500;letter-spacing:-.01em}h1{font-size:24px;line-height:32px}h2{font-size:16px;line-height:24px}.muted{color:var(--muted)}.faint{color:var(--faint)}.s{font-size:13px;line-height:18px}.ok{color:var(--ok)}.warn{color:var(--warn)}.strong{font-weight:500}.center{text-align:center}.mono{font-family:var(--mono);font-size:12px}.stack{display:flex;flex-direction:column;gap:2px;min-width:0}.stack.gap{gap:10px}.grow{flex:1}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row.gap{gap:8px;flex-wrap:nowrap}.row-baseline{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.offscreen{position:fixed;left:-9999px;opacity:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:saturate(180%) blur(12px);z-index:5}.brand{display:flex;align-items:center;gap:8px;font-weight:500;min-width:0}.brand .faint{font-weight:400}.logo{display:inline-flex;width:22px;height:22px;color:var(--text)}.logo svg{width:100%;height:100%}.wrap{width:100%;max-width:1048px;margin:0 auto;padding:20px 16px max(32px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:20px}.hello{display:flex;align-items:center;gap:12px}.avatar{width:44px;height:44px;border-radius:50%;background:var(--soft-hover);display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;position:relative;flex:0 0 auto}.avatar.online:after{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px var(--bg)}.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--warn-wash);font-size:14px}.notice.bad{background:var(--bad-wash)}.notice .ic{color:var(--warn)}.notice.bad .ic{color:var(--bad)}.alert{display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid vaLine truncated
|
@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{--ease-out: cubic-bezier(.23, 1, .32, 1);--ease-in: cubic-bezier(.55, 0, 1, .45);--ease-drawer: cubic-bezier(.32, .72, 0, 1);--spring: linear( 0, .022, .079, .158, .249, .344, .438, .527, .61, .684, .749, .805, .852, .891, .923, .949, .969, .984, .996, 1.004, 1.009, 1.013, 1.014, 1.015, 1.015, 1.014, 1.013, 1.012, 1.01, 1.009, 1.008, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1 );--spring-pop: linear( 0, .034, .122, .244, .383, .526, .662, .785, .889, .974, 1.038, 1.083, 1.111, 1.124, 1.126, 1.119, 1.106, 1.09, 1.072, 1.054, 1.038, 1.023, 1.01, 1, .993, .988, .985, .984, .984, .985, .987, .989, .992, .994, .996, .998, .999, 1, 1.001, 1.002, 1 );--dur-press: .12s;--dur-hover: .15s;--dur-pop: .18s;--dur-swap: .26s;--dur-enter: .44s;--dur-sheet: .44s;--dur-exit: .16s;--bg: #fcfcfc;--card: #ffffff;--elevated: #ffffff;--text: #0d0d0d;--muted: #5d5d5d;--faint: #8f8f8f;--line: #0000001a;--input: #00000026;--soft: #0d0d0d0d;--soft-hover: #0d0d0d1a;--primary: #0d0d0d;--primary-fg: #ffffff;--accent: #3a83f7;--info: #2c67c5;--ok: #00a240;--ok-wash: #00a24026;--warn: #e25507;--warn-wash: #e2550726;--bad: #e02e2a;--bad-wash: #e02e2a1f;--chart: #3a83f7;--track: #0d0d0d1a;--scrim: #00000040;--shadow: 0 1px 2px -1px #00000014;--shadow-xl: 0 8px 16px -4px #0000001f;--radius: 16px;--mono: "Geist Mono", ui-monospace, Menlo, monospace;color-scheme:light dark}@media(prefers-color-scheme:dark){:root{--bg: #000000;--card: #0a0a0a;--elevated: #131313;--text: #ededed;--muted: #edededa6;--faint: #ededed78;--line: #ededed13;--input: #ededed24;--soft: #ededed0d;--soft-hover: #ededed1a;--primary: #ededed;--primary-fg: #131313;--accent: #006efe;--info: #5ba2fe;--ok: #40c977;--ok-wash: #40c97726;--warn: #ff8549;--warn-wash: #ff854926;--bad: #ff6764;--bad-wash: #ff676422;--chart: #3a83f7;--track: #ededed1a;--scrim: #00000099;--shadow: none;--shadow-xl: 0 8px 16px -4px #00000080}}*{box-sizing:border-box}html,body{margin:0}html{scrollbar-gutter:stable}body{background:var(--bg);color:var(--text);font:400 15px/22px Geist,-apple-system,system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh;cursor:default}input,textarea,.linkrow .mono,.conf{cursor:text}body.locked{overflow:hidden}a{color:var(--info);text-decoration:none}a:hover{text-decoration:underline}a.btn:hover,a.badge:hover{text-decoration:none}h1,h2{margin:0;font-weight:500;letter-spacing:-.01em}h1{font-size:24px;line-height:32px}h2{font-size:16px;line-height:24px}.muted{color:var(--muted)}.faint{color:var(--faint)}.s{font-size:13px;line-height:18px}.ok{color:var(--ok)}.warn{color:var(--warn)}.strong{font-weight:500}.center{text-align:center}.mono{font-family:var(--mono);font-size:12px}.stack{display:flex;flex-direction:column;gap:2px;min-width:0}.stack.gap{gap:10px}.grow{flex:1}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row.gap{gap:8px;flex-wrap:nowrap}.row-baseline{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.offscreen{position:fixed;left:-9999px;opacity:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:saturate(180%) blur(12px);z-index:5}.brand{display:flex;align-items:center;gap:8px;font-weight:500;min-width:0}.brand .faint{font-weight:400}.logo{display:inline-flex;width:22px;height:22px;color:var(--text)}.logo svg{width:100%;height:100%}.wrap{width:100%;max-width:1048px;margin:0 auto;padding:20px 16px max(32px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:20px}.hello{display:flex;align-items:center;gap:12px}.avatar{width:44px;height:44px;border-radius:50%;background:var(--soft-hover);display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;position:relative;flex:0 0 auto}.avatar.online:after{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px var(--bg)}.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--warn-wash);font-size:14px}.notice.bad{background:var(--bad-wash)}.notice .ic{color:var(--warn)}.notice.bad .ic{color:var(--bad)}.alert{display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--line);bordLine truncated
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";(()=>{var Dn=Object.create;var xt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Bn=Object.getOwnPropertyNames;var Nn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var In=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var On=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Bn(t))!Rn.call(e,s)&&s!==r&&xt(e,s,{get:()=>t[s],enumerable:!(a=Hn(t,s))||a.enumerable});return e};var zn=(e,t,r)=>(r=e!=null?Dn(Nn(e)):{},On(t||!e||!e.__esModule?xt(r,"default",{value:e,enumerable:!0}):r,e));var St=In((Et,$t)=>{"use strict";var Tt=(function(){var e=function(v,f){var d=236,k=17,u=v,x=r[f],l=null,o=0,L=null,m=[],C={},B=function(p,g){o=u*4+17,l=(function(c){for(var y=new Array(c),b=0;b<c;b+=1){y[b]=new Array(c);for(var E=0;E<c;E+=1)y[b][E]=null}return y})(o),N(0,0),N(o-7,0),N(0,o-7),j(),W(),ae(p,g),u>=7&&J(p),L==null&&(L=K(u,x,m)),X(L,g)},N=function(p,g){for(var c=-1;c<=7;c+=1)if(!(p+c<=-1||o<=p+c))for(var y=-1;y<=7;y+=1)g+y<=-1||o<=g+y||(0<=c&&c<=6&&(y==0||y==6)||0<=y&&y<=6&&(c==0||c==6)||2<=c&&c<=4&&2<=y&&y<=4?l[p+c][g+y]=!0:l[p+c][g+y]=!1)},O=function(){for(var p=0,g=0,c=0;c<8;c+=1){B(!0,c);var y=s.getLostPoint(C);(c==0||p>y)&&(p=y,g=c)}return g},W=function(){for(var p=8;p<o-8;p+=1)l[p][6]==null&&(l[p][6]=p%2==0);for(var g=8;g<o-8;g+=1)l[6][g]==null&&(l[6][g]=g%2==0)},j=function(){for(var p=s.getPatternPosition(u),g=0;g<p.length;g+=1)for(var c=0;c<p.length;c+=1){var y=p[g],b=p[c];if(l[y][b]==null)for(var E=-2;E<=2;E+=1)for(var P=-2;P<=2;P+=1)E==-2||E==2||P==-2||P==2||E==0&&P==0?l[y+E][b+P]=!0:l[y+E][b+P]=!1}},J=function(p){for(var g=s.getBCHTypeNumber(u),c=0;c<18;c+=1){var y=!p&&(g>>c&1)==1;l[Math.floor(c/3)][c%3+o-8-3]=y}for(var c=0;c<18;c+=1){var y=!p&&(g>>c&1)==1;l[c%3+o-8-3][Math.floor(c/3)]=y}},ae=function(p,g){for(var c=x<<3|g,y=s.getBCHTypeInfo(c),b=0;b<15;b+=1){var E=!p&&(y>>b&1)==1;b<6?l[b][8]=E:b<8?l[b+1][8]=E:l[o-15+b][8]=E}for(var b=0;b<15;b+=1){var E=!p&&(y>>b&1)==1;b<8?l[8][o-b-1]=E:b<9?l[8][15-b-1+1]=E:l[8][15-b-1]=E}l[o-8][8]=!p},X=function(p,g){for(var c=-1,y=o-1,b=7,E=0,P=s.getMaskFunction(g),_=o-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var q=0;q<2;q+=1)if(l[y][_-q]==null){var Q=!1;E<p.length&&(Q=(p[E]>>>b&1)==1);var H=P(y,_-q);H&&(Q=!Q),l[y][_-q]=Q,b-=1,b==-1&&(E+=1,b=7)}if(y+=c,y<0||o<=y){y-=c,c=-c;break}}},$=function(p,g){for(var c=0,y=0,b=0,E=new Array(g.length),P=new Array(g.length),_=0;_<g.length;_+=1){var q=g[_].dataCount,Q=g[_].totalCount-q;y=Math.max(y,q),b=Math.max(b,Q),E[_]=new Array(q);for(var H=0;H<E[_].length;H+=1)E[_][H]=255&p.getBuffer()[H+c];c+=q;var ee=s.getErrorCorrectPolynomial(Q),te=w(E[_],ee.getLength()-1),yt=te.mod(ee);P[_]=new Array(ee.getLength()-1);for(var H=0;H<P[_].length;H+=1){var wt=H+yt.getLength()-P[_].length;P[_][H]=wt>=0?yt.getAt(wt):0}}for(var bt=0,H=0;H<g.length;H+=1)bt+=g[H].totalCount;for(var Fe=new Array(bt),Se=0,H=0;H<y;H+=1)for(var _=0;_<g.length;_+=1)H<E[_].length&&(Fe[Se]=E[_][H],Se+=1);for(var H=0;H<b;H+=1)for(var _=0;_<g.length;_+=1)H<P[_].length&&(Fe[Se]=P[_][H],Se+=1);return Fe},K=function(p,g,c){for(var y=h.getRSBlocks(p,g),b=M(),E=0;E<c.length;E+=1){var P=c[E];b.put(P.getMode(),4),b.put(P.getLength(),s.getLengthInBits(P.getMode(),p)),P.write(b)}for(var _=0,E=0;E<y.length;E+=1)_+=y[E].dataCount;if(b.getLengthInBits()>_*8)throw"code length overflow. ("+b.getLengthInBits()+">"+_*8+")";for(b.getLengthInBits()+4<=_*8&&b.put(0,4);b.getLengthInBits()%8!=0;)b.putBit(!1);for(;!(b.getLengthInBits()>=_*8||(b.put(d,8),b.getLengthInBits()>=_*8));)b.put(k,8);return $(b,y)};C.addData=function(p,g){g=g||"Byte";var c=null;switch(g){case"Numeric":c=A(p);break;case"Alphanumeric":c=D(p);break;case"Byte":c=T(p);break;case"Kanji":c=R(p);break;default:throw"mode:"+g}m.push(c),L=null},C.isDark=function(p,g){if(p<0||o<=p||g<0||o<=g)throw p+","+g;return l[p][g]},C.getModuleCount=function(){return o},C.make=function(){if(u<1){for(var p=1;p<40;p++){for(var g=h.getRSBlocks(p,x),c=M(),y=0;y<m.length;y++){var b=m[y];c.put(b.getMode(),4),c.put(b.getLength(),s.getLengthInBits(b.getMode(),p)),b.write(c)}for(var E=0,y=0;y<g.length;y++)E+=g[y].dataCount;if(c.getLengthInBits()<=E*8)break}u=p}B(!1,O())},C.createTableTag=function(p,g){p=p||2,g=typeof g=="undefined"?p*4:g;var c="";c+='<table style="',c+=" border-width: 0px; border-style: none;",c+=" border-collapse: collapse;",c+=" padding: 0px; margin: "+g+"px;",c+='">',c+="<tbody>";for(var y=0;y<C.getModuleCount();y+=1){c+="<tr>";for(var b=0;b<C.getModuleCount();b+=1)c+='<td style="',c+=" border-width: 0px; border-style: none;",c+=" border-collapse: collapse;",c+=" padding: 0px; margin: 0px;",c+=" width: "+p+"px;",c+=" height: "+p+"px;",c+=" background-color: ",c+=C.isDark(y,b)?"#000000":"#ffffff",c+=";",c+='"/>';c+="</tr>"}return c+="</tbody>",c+="</table>",c},C.createSvgTag=function(p,g,c,y){var b={};typeof arguments[0]=="object"&&(b=arguments[0],p=b.cellSize,g=b.margin,c=b.alt,y=b.title),p=p||2,g=typeof g=="undefined"?p*4:g,c=typeof c=="string"?{text:c}:c||{},c.text=c.texLine truncated
|
"use strict";(()=>{var _n=Object.create;var dt=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var Pn=Object.getOwnPropertyNames;var Dn=Object.getPrototypeOf,Hn=Object.prototype.hasOwnProperty;var Bn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Nn=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pn(t))!Hn.call(e,s)&&s!==n&&dt(e,s,{get:()=>t[s],enumerable:!(a=Sn(t,s))||a.enumerable});return e};var Rn=(e,t,n)=>(n=e!=null?_n(Dn(e)):{},Nn(t||!e||!e.__esModule?dt(n,"default",{value:e,enumerable:!0}):n,e));var xt=Bn((wt,bt)=>{"use strict";var yt=(function(){var e=function(v,y){var g=236,k=17,d=v,M=n[y],l=null,o=0,C=null,f=[],x={},B=function(u,p){o=d*4+17,l=(function(c){for(var h=new Array(c),w=0;w<c;w+=1){h[w]=new Array(c);for(var A=0;A<c;A+=1)h[w][A]=null}return h})(o),N(0,0),N(o-7,0),N(0,o-7),z(),F(),ne(u,p),d>=7&&Z(u),C==null&&(C=$e(d,M,f)),Y(C,p)},N=function(u,p){for(var c=-1;c<=7;c+=1)if(!(u+c<=-1||o<=u+c))for(var h=-1;h<=7;h+=1)p+h<=-1||o<=p+h||(0<=c&&c<=6&&(h==0||h==6)||0<=h&&h<=6&&(c==0||c==6)||2<=c&&c<=4&&2<=h&&h<=4?l[u+c][p+h]=!0:l[u+c][p+h]=!1)},I=function(){for(var u=0,p=0,c=0;c<8;c+=1){B(!0,c);var h=s.getLostPoint(x);(c==0||u>h)&&(u=h,p=c)}return p},F=function(){for(var u=8;u<o-8;u+=1)l[u][6]==null&&(l[u][6]=u%2==0);for(var p=8;p<o-8;p+=1)l[6][p]==null&&(l[6][p]=p%2==0)},z=function(){for(var u=s.getPatternPosition(d),p=0;p<u.length;p+=1)for(var c=0;c<u.length;c+=1){var h=u[p],w=u[c];if(l[h][w]==null)for(var A=-2;A<=2;A+=1)for(var D=-2;D<=2;D+=1)A==-2||A==2||D==-2||D==2||A==0&&D==0?l[h+A][w+D]=!0:l[h+A][w+D]=!1}},Z=function(u){for(var p=s.getBCHTypeNumber(d),c=0;c<18;c+=1){var h=!u&&(p>>c&1)==1;l[Math.floor(c/3)][c%3+o-8-3]=h}for(var c=0;c<18;c+=1){var h=!u&&(p>>c&1)==1;l[c%3+o-8-3][Math.floor(c/3)]=h}},ne=function(u,p){for(var c=M<<3|p,h=s.getBCHTypeInfo(c),w=0;w<15;w+=1){var A=!u&&(h>>w&1)==1;w<6?l[w][8]=A:w<8?l[w+1][8]=A:l[o-15+w][8]=A}for(var w=0;w<15;w+=1){var A=!u&&(h>>w&1)==1;w<8?l[8][o-w-1]=A:w<9?l[8][15-w-1+1]=A:l[8][15-w-1]=A}l[o-8][8]=!u},Y=function(u,p){for(var c=-1,h=o-1,w=7,A=0,D=s.getMaskFunction(p),_=o-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var G=0;G<2;G+=1)if(l[h][_-G]==null){var W=!1;A<u.length&&(W=(u[A]>>>w&1)==1);var H=D(h,_-G);H&&(W=!W),l[h][_-G]=W,w-=1,w==-1&&(A+=1,w=7)}if(h+=c,h<0||o<=h){h-=c,c=-c;break}}},de=function(u,p){for(var c=0,h=0,w=0,A=new Array(p.length),D=new Array(p.length),_=0;_<p.length;_+=1){var G=p[_].dataCount,W=p[_].totalCount-G;h=Math.max(h,G),w=Math.max(w,W),A[_]=new Array(G);for(var H=0;H<A[_].length;H+=1)A[_][H]=255&u.getBuffer()[H+c];c+=G;var X=s.getErrorCorrectPolynomial(W),ee=b(A[_],X.getLength()-1),lt=ee.mod(X);D[_]=new Array(X.getLength()-1);for(var H=0;H<D[_].length;H+=1){var ct=H+lt.getLength()-D[_].length;D[_][H]=ct>=0?lt.getAt(ct):0}}for(var ut=0,H=0;H<p.length;H+=1)ut+=p[H].totalCount;for(var Ge=new Array(ut),_e=0,H=0;H<h;H+=1)for(var _=0;_<p.length;_+=1)H<A[_].length&&(Ge[_e]=A[_][H],_e+=1);for(var H=0;H<w;H+=1)for(var _=0;_<p.length;_+=1)H<D[_].length&&(Ge[_e]=D[_][H],_e+=1);return Ge},$e=function(u,p,c){for(var h=m.getRSBlocks(u,p),w=L(),A=0;A<c.length;A+=1){var D=c[A];w.put(D.getMode(),4),w.put(D.getLength(),s.getLengthInBits(D.getMode(),u)),D.write(w)}for(var _=0,A=0;A<h.length;A+=1)_+=h[A].dataCount;if(w.getLengthInBits()>_*8)throw"code length overflow. ("+w.getLengthInBits()+">"+_*8+")";for(w.getLengthInBits()+4<=_*8&&w.put(0,4);w.getLengthInBits()%8!=0;)w.putBit(!1);for(;!(w.getLengthInBits()>=_*8||(w.put(g,8),w.getLengthInBits()>=_*8));)w.put(k,8);return de(w,h)};x.addData=function(u,p){p=p||"Byte";var c=null;switch(p){case"Numeric":c=T(u);break;case"Alphanumeric":c=E(u);break;case"Byte":c=P(u);break;case"Kanji":c=K(u);break;default:throw"mode:"+p}f.push(c),C=null},x.isDark=function(u,p){if(u<0||o<=u||p<0||o<=p)throw u+","+p;return l[u][p]},x.getModuleCount=function(){return o},x.make=function(){if(d<1){for(var u=1;u<40;u++){for(var p=m.getRSBlocks(u,M),c=L(),h=0;h<f.length;h++){var w=f[h];c.put(w.getMode(),4),c.put(w.getLength(),s.getLengthInBits(w.getMode(),u)),w.write(c)}for(var A=0,h=0;h<p.length;h++)A+=p[h].dataCount;if(c.getLengthInBits()<=A*8)break}d=u}B(!1,I())},x.createTableTag=function(u,p){u=u||2,p=typeof p=="undefined"?u*4:p;var c="";c+='<table style="',c+=" border-width: 0px; border-style: none;",c+=" border-collapse: collapse;",c+=" padding: 0px; margin: "+p+"px;",c+='">',c+="<tbody>";for(var h=0;h<x.getModuleCount();h+=1){c+="<tr>";for(var w=0;w<x.getModuleCount();w+=1)c+='<td style="',c+=" border-width: 0px; border-style: none;",c+=" border-collapse: collapse;",c+=" padding: 0px; margin: 0px;",c+=" width: "+u+"px;",c+=" height: "+u+"px;",c+=" background-color: ",c+=x.isDark(h,w)?"#000000":"#ffffff",c+=";",c+='"/>';c+="</tr>"}return c+="</tbody>",c+="</table>",c},x.createSvgTag=function(u,p,c,h){var w={};typeof arguments[0]=="object"&&(w=arguments[0],u=w.cellSize,p=w.margin,c=w.alt,h=w.title),u=u||2,p=typeof p=="undefined"?u*4:p,c=typeof c=="string"?{text:c}:c||{},c.text=c.texLine truncated
|
||||||
`}return c%2&&p>0?te.substring(0,te.length-c-1)+Array(c+1).join("▀"):te.substring(0,te.length-1)};return C.createASCII=function(p,g){if(p=p||1,p<2)return qe(g);p-=1,g=typeof g=="undefined"?p*2:g;var c=C.getModuleCount()*p+g*2,y=g,b=c-g,E,P,_,q,Q=Array(p+1).join("██"),H=Array(p+1).join(" "),ee="",te="";for(E=0;E<c;E+=1){for(_=Math.floor((E-y)/p),te="",P=0;P<c;P+=1)q=1,y<=P&&P<b&&y<=E&&E<b&&C.isDark(_,Math.floor((P-y)/p))&&(q=0),te+=q?Q:H;for(_=0;_<p;_+=1)ee+=te+`
|
`}return c%2&&u>0?ee.substring(0,ee.length-c-1)+Array(c+1).join("▀"):ee.substring(0,ee.length-1)};return x.createASCII=function(u,p){if(u=u||1,u<2)return q(p);u-=1,p=typeof p=="undefined"?u*2:p;var c=x.getModuleCount()*u+p*2,h=p,w=c-p,A,D,_,G,W=Array(u+1).join("██"),H=Array(u+1).join(" "),X="",ee="";for(A=0;A<c;A+=1){for(_=Math.floor((A-h)/u),ee="",D=0;D<c;D+=1)G=1,h<=D&&D<w&&h<=A&&A<w&&x.isDark(_,Math.floor((D-h)/u))&&(G=0),ee+=G?W:H;for(_=0;_<u;_+=1)X+=ee+`
|
||||||
`}return ee.substring(0,ee.length-1)},C.renderTo2dContext=function(p,g){g=g||2;for(var c=C.getModuleCount(),y=0;y<c;y++)for(var b=0;b<c;b++)p.fillStyle=C.isDark(y,b)?"black":"white",p.fillRect(y*g,b*g,g,g)},C};e.stringToBytesFuncs={default:function(v){for(var f=[],d=0;d<v.length;d+=1){var k=v.charCodeAt(d);f.push(k&255)}return f}},e.stringToBytes=e.stringToBytesFuncs.default,e.createStringToBytes=function(v,f){var d=(function(){for(var u=F(v),x=function(){var W=u.read();if(W==-1)throw"eof";return W},l=0,o={};;){var L=u.read();if(L==-1)break;var m=x(),C=x(),B=x(),N=String.fromCharCode(L<<8|m),O=C<<8|B;o[N]=O,l+=1}if(l!=f)throw l+" != "+f;return o})(),k=63;return function(u){for(var x=[],l=0;l<u.length;l+=1){var o=u.charCodeAt(l);if(o<128)x.push(o);else{var L=d[u.charAt(l)];typeof L=="number"?(L&255)==L?x.push(L):(x.push(L>>>8),x.push(L&255)):x.push(k)}}return x}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},s=(function(){var v=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],f=1335,d=7973,k=21522,u={},x=function(l){for(var o=0;l!=0;)o+=1,l>>>=1;return o};return u.getBCHTypeInfo=function(l){for(var o=l<<10;x(o)-x(f)>=0;)o^=f<<x(o)-x(f);return(l<<10|o)^k},u.getBCHTypeNumber=function(l){for(var o=l<<12;x(o)-x(d)>=0;)o^=d<<x(o)-x(d);return l<<12|o},u.getPatternPosition=function(l){return v[l-1]},u.getMaskFunction=function(l){switch(l){case a.PATTERN000:return function(o,L){return(o+L)%2==0};case a.PATTERN001:return function(o,L){return o%2==0};case a.PATTERN010:return function(o,L){return L%3==0};case a.PATTERN011:return function(o,L){return(o+L)%3==0};case a.PATTERN100:return function(o,L){return(Math.floor(o/2)+Math.floor(L/3))%2==0};case a.PATTERN101:return function(o,L){return o*L%2+o*L%3==0};case a.PATTERN110:return function(o,L){return(o*L%2+o*L%3)%2==0};case a.PATTERN111:return function(o,L){return(o*L%3+(o+L)%2)%2==0};default:throw"bad maskPattern:"+l}},u.getErrorCorrectPolynomial=function(l){for(var o=w([1],0),L=0;L<l;L+=1)o=o.multiply(w([1,i.gexp(L)],0));return o},u.getLengthInBits=function(l,o){if(1<=o&&o<10)switch(l){case t.MODE_NUMBER:return 10;case t.MODE_ALPHA_NUM:return 9;case t.MODE_8BIT_BYTE:return 8;case t.MODE_KANJI:return 8;default:throw"mode:"+l}else if(o<27)switch(l){case t.MODE_NUMBER:return 12;case t.MODE_ALPHA_NUM:return 11;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 10;default:throw"mode:"+l}else if(o<41)switch(l){case t.MODE_NUMBER:return 14;case t.MODE_ALPHA_NUM:return 13;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+o},u.getLostPoint=function(l){for(var o=l.getModuleCount(),L=0,m=0;m<o;m+=1)for(var C=0;C<o;C+=1){for(var B=0,N=l.isDark(m,C),O=-1;O<=1;O+=1)if(!(m+O<0||o<=m+O))for(var W=-1;W<=1;W+=1)C+W<0||o<=C+W||O==0&&W==0||N==l.isDark(m+O,C+W)&&(B+=1);B>5&&(L+=3+B-5)}for(var m=0;m<o-1;m+=1)for(var C=0;C<o-1;C+=1){var j=0;l.isDark(m,C)&&(j+=1),l.isDark(m+1,C)&&(j+=1),l.isDark(m,C+1)&&(j+=1),l.isDark(m+1,C+1)&&(j+=1),(j==0||j==4)&&(L+=3)}for(var m=0;m<o;m+=1)for(var C=0;C<o-6;C+=1)l.isDark(m,C)&&!l.isDark(m,C+1)&&l.isDark(m,C+2)&&l.isDark(m,C+3)&&l.isDark(m,C+4)&&!l.isDark(m,C+5)&&l.isDark(m,C+6)&&(L+=40);for(var C=0;C<o;C+=1)for(var m=0;m<o-6;m+=1)l.isDark(m,C)&&!l.isDark(m+1,C)&&l.isDark(m+2,C)&&l.isDark(m+3,C)&&l.isDark(m+4,C)&&!l.isDark(m+5,C)&&l.isDark(m+6,C)&&(L+=40);for(var J=0,C=0;C<o;C+=1)for(var m=0;m<o;m+=1)l.isDark(m,C)&&(J+=1);var ae=Math.abs(100*J/o/o-50)/5;return L+=ae*10,L},u})(),i=(function(){for(var v=new Array(256),f=new Array(256),d=0;d<8;d+=1)v[d]=1<<d;for(var d=8;d<256;d+=1)v[d]=v[d-4]^v[d-5]^v[d-6]^v[d-8];for(var d=0;d<255;d+=1)f[v[d]]=d;var k={};return k.glog=function(u){if(u<1)throw"glog("+u+")";return f[u]},k.gexp=function(u){for(;u<0;)u+=255;for(;u>=256;)u-=255;return v[u]},k})();function w(v,f){if(typeof v.length=="undefined")throw v.length+"/"+f;var d=(function(){for(var u=0;u<v.length&&v[u]==0;)u+=1;for(var x=new Array(v.length-u+f),l=0;l<v.length-u;l+=1)x[l]=v[l+u];return x})(),k={};return k.getAt=function(u){return d[u]},k.getLength=function(){return d.length},k.multiply=function(u){for(var x=new Array(k.getLength()+u.getLength()-1),l=0;l<k.getLength();l+=1)for(var o=0;o<u.getLength();o+=1)x[l+o]^=i.gexp(i.glog(k.getAt(l))+i.glog(u.getAt(o)));return w(x,0)},k.mod=function(u){if(k.ge
Line truncated
|
`}return X.substring(0,X.length-1)},x.renderTo2dContext=function(u,p){p=p||2;for(var c=x.getModuleCount(),h=0;h<c;h++)for(var w=0;w<c;w++)u.fillStyle=x.isDark(h,w)?"black":"white",u.fillRect(h*p,w*p,p,p)},x};e.stringToBytesFuncs={default:function(v){for(var y=[],g=0;g<v.length;g+=1){var k=v.charCodeAt(g);y.push(k&255)}return y}},e.stringToBytes=e.stringToBytesFuncs.default,e.createStringToBytes=function(v,y){var g=(function(){for(var d=V(v),M=function(){var F=d.read();if(F==-1)throw"eof";return F},l=0,o={};;){var C=d.read();if(C==-1)break;var f=M(),x=M(),B=M(),N=String.fromCharCode(C<<8|f),I=x<<8|B;o[N]=I,l+=1}if(l!=y)throw l+" != "+y;return o})(),k=63;return function(d){for(var M=[],l=0;l<d.length;l+=1){var o=d.charCodeAt(l);if(o<128)M.push(o);else{var C=g[d.charAt(l)];typeof C=="number"?(C&255)==C?M.push(C):(M.push(C>>>8),M.push(C&255)):M.push(k)}}return M}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},s=(function(){var v=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],y=1335,g=7973,k=21522,d={},M=function(l){for(var o=0;l!=0;)o+=1,l>>>=1;return o};return d.getBCHTypeInfo=function(l){for(var o=l<<10;M(o)-M(y)>=0;)o^=y<<M(o)-M(y);return(l<<10|o)^k},d.getBCHTypeNumber=function(l){for(var o=l<<12;M(o)-M(g)>=0;)o^=g<<M(o)-M(g);return l<<12|o},d.getPatternPosition=function(l){return v[l-1]},d.getMaskFunction=function(l){switch(l){case a.PATTERN000:return function(o,C){return(o+C)%2==0};case a.PATTERN001:return function(o,C){return o%2==0};case a.PATTERN010:return function(o,C){return C%3==0};case a.PATTERN011:return function(o,C){return(o+C)%3==0};case a.PATTERN100:return function(o,C){return(Math.floor(o/2)+Math.floor(C/3))%2==0};case a.PATTERN101:return function(o,C){return o*C%2+o*C%3==0};case a.PATTERN110:return function(o,C){return(o*C%2+o*C%3)%2==0};case a.PATTERN111:return function(o,C){return(o*C%3+(o+C)%2)%2==0};default:throw"bad maskPattern:"+l}},d.getErrorCorrectPolynomial=function(l){for(var o=b([1],0),C=0;C<l;C+=1)o=o.multiply(b([1,i.gexp(C)],0));return o},d.getLengthInBits=function(l,o){if(1<=o&&o<10)switch(l){case t.MODE_NUMBER:return 10;case t.MODE_ALPHA_NUM:return 9;case t.MODE_8BIT_BYTE:return 8;case t.MODE_KANJI:return 8;default:throw"mode:"+l}else if(o<27)switch(l){case t.MODE_NUMBER:return 12;case t.MODE_ALPHA_NUM:return 11;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 10;default:throw"mode:"+l}else if(o<41)switch(l){case t.MODE_NUMBER:return 14;case t.MODE_ALPHA_NUM:return 13;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+o},d.getLostPoint=function(l){for(var o=l.getModuleCount(),C=0,f=0;f<o;f+=1)for(var x=0;x<o;x+=1){for(var B=0,N=l.isDark(f,x),I=-1;I<=1;I+=1)if(!(f+I<0||o<=f+I))for(var F=-1;F<=1;F+=1)x+F<0||o<=x+F||I==0&&F==0||N==l.isDark(f+I,x+F)&&(B+=1);B>5&&(C+=3+B-5)}for(var f=0;f<o-1;f+=1)for(var x=0;x<o-1;x+=1){var z=0;l.isDark(f,x)&&(z+=1),l.isDark(f+1,x)&&(z+=1),l.isDark(f,x+1)&&(z+=1),l.isDark(f+1,x+1)&&(z+=1),(z==0||z==4)&&(C+=3)}for(var f=0;f<o;f+=1)for(var x=0;x<o-6;x+=1)l.isDark(f,x)&&!l.isDark(f,x+1)&&l.isDark(f,x+2)&&l.isDark(f,x+3)&&l.isDark(f,x+4)&&!l.isDark(f,x+5)&&l.isDark(f,x+6)&&(C+=40);for(var x=0;x<o;x+=1)for(var f=0;f<o-6;f+=1)l.isDark(f,x)&&!l.isDark(f+1,x)&&l.isDark(f+2,x)&&l.isDark(f+3,x)&&l.isDark(f+4,x)&&!l.isDark(f+5,x)&&l.isDark(f+6,x)&&(C+=40);for(var Z=0,x=0;x<o;x+=1)for(var f=0;f<o;f+=1)l.isDark(f,x)&&(Z+=1);var ne=Math.abs(100*Z/o/o-50)/5;return C+=ne*10,C},d})(),i=(function(){for(var v=new Array(256),y=new Array(256),g=0;g<8;g+=1)v[g]=1<<g;for(var g=8;g<256;g+=1)v[g]=v[g-4]^v[g-5]^v[g-6]^v[g-8];for(var g=0;g<255;g+=1)y[v[g]]=g;var k={};return k.glog=function(d){if(d<1)throw"glog("+d+")";return y[d]},k.gexp=function(d){for(;d<0;)d+=255;for(;d>=256;)d-=255;return v[d]},k})();function b(v,y){if(typeof v.length=="undefined")throw v.length+"/"+y;var g=(function(){for(var d=0;d<v.length&&v[d]==0;)d+=1;for(var M=new Array(v.length-d+y),l=0;l<v.length-d;l+=1)M[l]=v[l+d];return M})(),k={};return k.getAt=function(d){return g[d]},k.getLength=function(){return g.length},k.multiply=function(d){for(var M=new Array(k.getLength()+d.getLength()-1),l=0;l<k.getLength();l+=1)for(var o=0;o<d.getLength();o+=1)M[l+o]^=i.gexp(i.glog(k.getAt(l))+i.glog(d.getAt(o)));return b(M,0)},k.mod=function(d){if(k.getL
Line truncated
|
||||||
`),hostName:i,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},h={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(w),port:String(r.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:i};return r.dns[0]&&(h.dns1=r.dns[0]),r.dns[1]&&(h.dns2=r.dns[1]),h}function Yn(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Qn(e){let t=globalThis;if(typeof t.CompressionStream=="undefined")return null;try{let r=new t.Blob([e]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(r).arrayBuffer()),s=new Uint8Array(4+a.length);return new DataView(s.buffer).setUint32(0,e.length,!1),s.set(a,4),s}catch{return null}}async function Be(e,t,r=!0){let a=new TextEncoder().encode(JSON.stringify(Vn(e,t))),s=r?await Qn(a):null;return`vpn://${Yn(s!=null?s:a)}`}function n(e,t={},...r){let a=document.createElement(e);for(let[i,w]of Object.entries(t))w==null||w===!1||(i.startsWith("on")&&typeof w=="function"?a.addEventListener(i.slice(2),w):i==="class"?a.className=String(w):w===!0?a.setAttribute(i,""):a.setAttribute(i,String(w)));let s=i=>{i==null||i===!1||(Array.isArray(i)?i.forEach(s):a.appendChild(typeof i=="string"?document.createTextNode(i):i))};return r.forEach(s),a}function I(e){let t=n("span",{class:"ic"});return t.innerHTML=He(e,"ic-svg"),t}var ie=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,oe={out:"cubic-bezier(0.23, 1, 0.32, 1)",in:"cubic-bezier(0.55, 0, 1, 0.45)",drawer:"cubic-bezier(0.32, 0.72, 0, 1)"};function Ht(e){var r;let t=e.closest(".sheet-panel");return t?(t.dataset.hold=String(+((r=t.dataset.hold)!=null?r:0)+1),()=>{var s;let a=+((s=t.dataset.hold)!=null?s:1)-1;a>0?t.dataset.hold=String(a):delete t.dataset.hold}):()=>{}}function jn(e,t){return e<=0||t<=0?0:(1-1/(e*.55/t+1))*t}function Jn(e,t,r){return e<=0||t<-.1?!1:t>.4||e>r/3}var Bt=e=>Math.round(Math.min(380,Math.max(220,200+e*.35)));function ne(e,t){e.classList.remove(t),e.offsetWidth,e.classList.add(t)}function Nt(e,t){let r=0,a=0,s=!1,i=null,w=new ResizeObserver(()=>{if(e.dataset.hold){i==null||i.cancel(),e.classList.remove("morphing","morphing-w"),r=e.offsetHeight,a=e.offsetWidth;return}let h=getComputedStyle(e),M=i?parseFloat(h.height):r,A=i?parseFloat(h.width):a;i==null||i.cancel(),e.classList.remove("morphing","morphing-w");let D=e.offsetHeight,T=e.offsetWidth,R=e.dataset.morph==="width"||s;delete e.dataset.morph;let z=a!==0&&T!==a;if(r=D,a=T,!M||ie()||z&&!R)return;let U=Math.abs(D-M),F=R?Math.abs(T-A):0;if(U<2&&F<2)return;s=F>=2,e.classList.add("morphing"),e.classList.toggle("morphing-w",s);let V=e.animate(s?[{height:`${M}px`,width:`${A}px`},{height:`${D}px`,width:`${T}px`}]:[{height:`${M}px`},{height:`${D}px`}],{duration:Bt(Math.max(U,F)),easing:oe.out});i=V;let G=()=>{i===V&&(i=null,s=!1,e.classList.remove("morphing","morphing-w"))};V.onfinish=G,V.oncancel=G});return w.observe(t),()=>w.disconnect()}function et(e,t,r=0){let a=[...e.childNodes];if(!a.length||!e.isConnected){e.replaceChildren(...t);return}let s=getComputedStyle(e),i=document.createElement("div");i.className="ghost",i.setAttribute("aria-hidden","true"),i.inert=!0,Object.assign(i.style,{display:s.display==="flex"?"flex":"block",flexDirection:s.flexDirection,alignItems:s.alignItems,gap:s.gap,top:s.paddingTop,left:s.paddingLeft,right:s.paddingRight}),i.append(...a),e.replaceChildren(i,...t);let w=ie(),h=i.animate([{opacity:1,transform:"none"},{opacity:0,transform:w?"none":`translateX(${-r*8}px)`}],{duration:120,easing:oe.out,fill:"forwards"}),M=()=>i.remove();h.onfinish=M,h.oncancel=M;for(let A of t)A instanceof HTMLElement&&A.animate(w?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translate(${r*12}px, ${r?0:6}px)`,filter:"blur(4px)"},{opacity:1,transform:"none",filter:"blur(0)"}],{duration:w?160:280,delay:50,easing:oe.out,fill:"backwards"})}function Rt(e){return!e||!e.isConnected?Promise.resolve():e.animate(ie()?[{opacity:1},{opacity:0}]:[{opacity:1,transform:"none",filter:"blur(0)"},{opacity:0,transform:"scale(0.96)",filter:"blur(4px)"}],{duration:200,easing:oe.in,fill:"forwards"}).finished.then(()=>{},()=>{})}var It=e=>new Promise(t=>setTimeout(t,ie()?0:e)),Ce={ms:520,contentMs:300,blur:4,drift:6,scale:.98};async function Ot(e){if(!e.isConnected)return;let t=Ht(e),r=parseFloat(getComputedStyle(e.parentElement).rowGap)||0,a=e.offsetHeight;e.style.overflow="hidden",e.style.transformOrigin="50% 0",e.inert=!0;let s=()=>{};ie()?await e.animate([{opacity:1},{opacity:0}],{duration:160,easing:oe.out,fill:"forwards"}).finished.then(s,s):(e.animate([{opacity:1,filter:"blur(0px)",transform:"none"},{opacity:0,filter:`blur(${Ce.blur}px)`,transform:`translateY(${-Ce.drift}px) scale(${Ce.
Line truncated
|
`),hostName:i,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},m={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(b),port:String(n.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:i};return n.dns[0]&&(m.dns1=n.dns[0]),n.dns[1]&&(m.dns2=n.dns[1]),m}function Un(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Wn(e){let t=globalThis;if(typeof t.CompressionStream=="undefined")return null;try{let n=new t.Blob([e]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(n).arrayBuffer()),s=new Uint8Array(4+a.length);return new DataView(s.buffer).setUint32(0,e.length,!1),s.set(a,4),s}catch{return null}}async function Lt(e,t,n=!0){let a=new TextEncoder().encode(JSON.stringify(zn(e,t))),s=n?await Wn(a):null;return`vpn://${Un(s!=null?s:a)}`}var Tt=e=>e.replace(/^vpn:\/\//,"");function r(e,t={},...n){let a=document.createElement(e);for(let[i,b]of Object.entries(t))b==null||b===!1||(i.startsWith("on")&&typeof b=="function"?a.addEventListener(i.slice(2),b):i==="class"?a.className=String(b):b===!0?a.setAttribute(i,""):a.setAttribute(i,String(b)));let s=i=>{i==null||i===!1||(Array.isArray(i)?i.forEach(s):a.appendChild(typeof i=="string"?document.createTextNode(i):i))};return n.forEach(s),a}function R(e){let t=r("span",{class:"ic"});return t.innerHTML=He(e,"ic-svg"),t}var se=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,re={out:"cubic-bezier(0.23, 1, 0.32, 1)",in:"cubic-bezier(0.55, 0, 1, 0.45)",drawer:"cubic-bezier(0.32, 0.72, 0, 1)"};function At(e){var n;let t=e.closest(".sheet-panel");return t?(t.dataset.hold=String(+((n=t.dataset.hold)!=null?n:0)+1),()=>{var s;let a=+((s=t.dataset.hold)!=null?s:1)-1;a>0?t.dataset.hold=String(a):delete t.dataset.hold}):()=>{}}function Yn(e,t){return e<=0||t<=0?0:(1-1/(e*.55/t+1))*t}function Vn(e,t,n){return e<=0||t<-.1?!1:t>.4||e>n/3}var Et=e=>Math.round(Math.min(380,Math.max(220,200+e*.35)));function ae(e,t){e.classList.remove(t),e.offsetWidth,e.classList.add(t)}function $t(e,t){let n=0,a=0,s=!1,i=null,b=new ResizeObserver(()=>{if(e.dataset.hold){i==null||i.cancel(),e.classList.remove("morphing","morphing-w"),n=e.offsetHeight,a=e.offsetWidth;return}let m=getComputedStyle(e),L=i?parseFloat(m.height):n,T=i?parseFloat(m.width):a;i==null||i.cancel(),e.classList.remove("morphing","morphing-w");let E=e.offsetHeight,P=e.offsetWidth,K=e.dataset.morph==="width"||s;delete e.dataset.morph;let O=a!==0&&P!==a;if(n=E,a=P,!L||se()||O&&!K)return;let U=Math.abs(E-L),V=K?Math.abs(P-T):0;if(U<2&&V<2)return;s=V>=2,e.classList.add("morphing"),e.classList.toggle("morphing-w",s);let j=e.animate(s?[{height:`${L}px`,width:`${T}px`},{height:`${E}px`,width:`${P}px`}]:[{height:`${L}px`},{height:`${E}px`}],{duration:Et(Math.max(U,V)),easing:re.out});i=j;let Q=()=>{i===j&&(i=null,s=!1,e.classList.remove("morphing","morphing-w"))};j.onfinish=Q,j.oncancel=Q});return b.observe(t),()=>b.disconnect()}function _t(e,t,n=0){let a=[...e.childNodes];if(!a.length||!e.isConnected){e.replaceChildren(...t);return}let s=getComputedStyle(e),i=document.createElement("div");i.className="ghost",i.setAttribute("aria-hidden","true"),i.inert=!0,Object.assign(i.style,{display:s.display==="flex"?"flex":"block",flexDirection:s.flexDirection,alignItems:s.alignItems,gap:s.gap,top:s.paddingTop,left:s.paddingLeft,right:s.paddingRight}),i.append(...a),e.replaceChildren(i,...t);let b=se(),m=i.animate([{opacity:1,transform:"none"},{opacity:0,transform:b?"none":`translateX(${-n*8}px)`}],{duration:120,easing:re.out,fill:"forwards"}),L=()=>i.remove();m.onfinish=L,m.oncancel=L;for(let T of t)T instanceof HTMLElement&&T.animate(b?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translate(${n*12}px, ${n?0:6}px)`,filter:"blur(4px)"},{opacity:1,transform:"none",filter:"blur(0)"}],{duration:b?160:280,delay:50,easing:re.out,fill:"backwards"})}function St(e){return!e||!e.isConnected?Promise.resolve():e.animate(se()?[{opacity:1},{opacity:0}]:[{opacity:1,transform:"none",filter:"blur(0)"},{opacity:0,transform:"scale(0.96)",filter:"blur(4px)"}],{duration:200,easing:re.in,fill:"forwards"}).finished.then(()=>{},()=>{})}var Pt=e=>new Promise(t=>setTimeout(t,se()?0:e)),Ce={ms:520,contentMs:300,blur:4,drift:6,scale:.98};async function Dt(e){if(!e.isConnected)return;let t=At(e),n=parseFloat(getComputedStyle(e.parentElement).rowGap)||0,a=e.offsetHeight;e.style.overflow="hidden",e.style.transformOrigin="50% 0",e.inert=!0;let s=()=>{};se()?await e.animate([{opacity:1},{opacity:0}],{duration:160,easing:re.out,fill:"forwards"}).finished.then(s,s):(e.animate([{opacity:1,filter:"blur(0px)",transform:"none"},{opacity:0,filter:`blur(${Ce.blur}px)`,transform:`tr
Line truncated
|
||||||
`).flatMap((w,h)=>h?[`
|
`).flatMap((b,m)=>m?[`
|
||||||
`,ln(w,t)]:[ln(w,t)])),i&&r.querySelectorAll(".conf-v, .conf-mask").forEach(w=>w.classList.add("unmask"))},s=n("button",{class:"btn small",onclick:i=>{i.preventDefault(),t=!t,s.replaceChildren(I(t?"x":"key"),n("span",{},t?"Hide key":"Show key")),ne(s,"swap"),a(!0)}},I("key"),n("span",{},"Show key"));return a(),n("div",{class:"pane"},n("div",{class:"filecard"},n("span",{class:"filecard-ic"},".conf"),n("span",{class:"stack"},n("span",{class:"mono ellipsis"},e.filename),n("span",{class:"faint s"},Te()?"For computers and routers: import it in any WireGuard app":"For computers and routers: import it in AmneziaWG or AmneziaVPN")),ut(e)?n("button",{class:"btn primary",onclick:()=>ut(e)()},I("open"),n("span",{},"Share file")):n("button",{class:"btn primary",onclick:()=>ze(e.filename,e.conf)},I("download"),n("span",{},"Download"))),n("details",{class:"confbox"},n("summary",{},I("chevron"),n("span",{},"Configuration"),n("span",{class:"grow"}),s,n("button",{class:"btn small",onclick:i=>{i.preventDefault(),ue(e.conf,"Configuration copied",i.currentTarget)}},I("copy"),n("span",{},"Copy"))),r))}async function pt(e,t,r){let a=r!=null?r:await Ge(e);if(!a)return;let s=await Be(a,`${a.server} · ${a.name}`),i=fn(),w=e.kind==="phone"||e.kind==="tablet",h={app:()=>n("div",{class:"pane"},n("a",{class:"btn primary block big",href:s},I("amnezia"),n("span",{},"Open in AmneziaVPN")),n("ol",{class:"steps"},n("li",{},"No AmneziaVPN yet? ",n("a",{href:on().href,target:"_blank",rel:"noopener noreferrer"},on().label),"."),n("li",{},"Tap ",n("b",{},"Open in AmneziaVPN")," and confirm the import."),n("li",{},"Turn the connection on — this page shows ",n("span",{class:"ok"},"Connected")," within a minute."))),qr:()=>{let G=n("div",{class:"qr"}),v=n("p",{class:"muted s"}),f=n("div",{class:"seg"}),d=Te()?"conf":"vpn",k=()=>{},u=(x=!1)=>{let l=d==="vpn"?s:a.conf;vt(G,l),v.textContent=d==="vpn"?"Scan with the phone’s camera or inside AmneziaVPN.":Te()?"Scan inside the AmneziaWG, WireGuard or AmneziaVPN app.":"Scan inside the AmneziaWG app (or AmneziaVPN).",f.querySelectorAll(":scope > button").forEach(o=>o.classList.toggle("on",o.dataset.m===d)),k(),x&&(ne(G,"swap"),ne(v,"swap"))};for(let[x,l]of[["vpn","AmneziaVPN"],["conf",Te()?"WireGuard app":"AmneziaWG app"]])f.appendChild(n("button",{type:"button","data-m":x,onclick:()=>{d!==x&&(d=x,u(!0))}},l));return u(),k=tt(f),n("div",{class:"pane center"},f,G,v,dt())},key:()=>n("div",{class:"pane"},n("p",{class:"muted s"},"In AmneziaVPN choose “Add server → Insert key”."),n("div",{class:"keybox"},n("span",{class:"mono"},s),n("button",{class:"btn small",onclick:G=>ue(s,"Key copied",G.currentTarget)},"Copy")),n("p",{class:"faint s"},"Keep it private: anyone with the key can use your connection.")),file:()=>An(a)},M=i&&w?["app","qr","key","file"]:w?["qr","key","file"]:["file","key","qr"],A={app:"Open in app",qr:"QR code",key:"Key",file:"File"},D=n("div",{class:"tab-body"}),T=n("div",{class:"tabs",role:"tablist"}),R=-1,z=()=>{},U=G=>{let v=M.indexOf(G);T.querySelectorAll(":scope > button").forEach(f=>{f.classList.toggle("on",f.dataset.id===G),f.setAttribute("aria-selected",String(f.dataset.id===G))}),z(),R<0?D.replaceChildren(h[G]()):v!==R&&et(D,[h[G]()],Math.sign(v-R)),R=v};for(let G of M)T.appendChild(n("button",{role:"tab","data-id":G,onclick:()=>U(G)},A[G]));U(t&&M.includes(t)?t:M[0]),z=tt(T);let F=e.handshake||e.disabled?null:rt(e.kind),V=F?$n(e,()=>void Tn(F,[T,D]),F.gaveUp):()=>{};$e(e.handshake?`Connect ${e.name}`:`${e.name} is ready`,i&&w?"Add it to AmneziaVPN on this phone":w?"Scan with the phone’s camera or AmneziaVPN":"Import the file in AmneziaWG or AmneziaVPN",F==null?void 0:F.el,T,D,e.handshake?mr(e):null),ce=()=>{V(),S&&ye(S)}}function mr(e){return n("div",{class:"waiting"},e.online?n("span",{class:"ok"},"Connected"):n("span",{class:"muted"},`Last connected ${Ue(e.handshake,mt())}`))}async function Tn(e,t){var r;e.connected(),(r=e.el.closest(".sheet-panel"))==null||r.scrollTo({top:0,behavior:ie()?"auto":"smooth"}),await It(400),await Promise.all(t.map(a=>Ot(a))),await new Promise(a=>setTimeout(a,2e3)),re!=null&&re.contains(e.el)&&!e.el.closest(".ghost")&&de()}function En(e,t=4){window.setTimeout(async()=>{var r;try{let a=await he("state");S=a,!re&&!ve&&ye(a),!((r=a.person.devices.find(s=>s.id===e))!=null&&r.online)&&t>1&&En(e,t-1)}catch{}},1500)}function $n(e,t,r){let a=mt(),s=0,i=0,w=!1,h=Date.now(),M=async()=>{if(s=0,!w){if(Date.now()-h>6e5){w=!0,r();return}if(document.hidden){A();return}try{let T=await he("state");S=T;let R=T.person.devices.find(z=>z.id===e.id);if(R&&R.handshake>a){w=!0,t(),R.online||En(e.id);return}}catch(T){if(T.status===404||T.status===401){w=!0;return}}i++,A()}},A=()=>{!w&&!s&&(s=window.setTimeout(M,i<6?5e3:i<12?15e3:3e4))},D=()=>{!document.hidden&&!w&&!s&&M()};return document.addEventListener("visibilitychange",D),A(),()=>{w=!0,s&&clearTimeout(s),document.removeEventListener("visibilitychange",D)}}var Sn=e=>`dl.app.${e.id}`;function gr(e){try{let t=loc
Line truncated
|
`,sn(b,t)]:[sn(b,t)])),i&&n.querySelectorAll(".conf-v, .conf-mask").forEach(b=>b.classList.add("unmask"))},s=r("button",{class:"btn small",onclick:i=>{i.preventDefault(),t=!t,s.replaceChildren(R(t?"x":"key"),r("span",{},t?"Hide key":"Show key")),ae(s,"swap"),a(!0)}},R("key"),r("span",{},"Show key"));return a(),r("div",{class:"pane"},r("div",{class:"filecard"},r("span",{class:"filecard-ic"},".conf"),r("span",{class:"stack"},r("span",{class:"mono ellipsis"},e.filename),r("span",{class:"faint s"},xn()?"For computers and routers: import it in any WireGuard app":"For computers and routers: import it in AmneziaWG or AmneziaVPN")),Ie(e.filename,e.conf)?r("button",{class:"btn primary",onclick:()=>Ie(e.filename,e.conf)()},R("open"),r("span",{},"Share file")):r("button",{class:"btn primary",onclick:()=>st(e.filename,e.conf)},R("download"),r("span",{},"Download"))),r("details",{class:"confbox"},r("summary",{},R("chevron"),r("span",{},"Configuration"),r("span",{class:"grow"}),s,r("button",{class:"btn small",onclick:i=>{i.preventDefault(),ge(e.conf,"Configuration copied",i.currentTarget)}},R("copy"),r("span",{},"Copy"))),n))}async function hr(e,t){var n;e.connected(),(n=e.el.closest(".sheet-panel"))==null||n.scrollTo({top:0,behavior:se()?"auto":"smooth"}),await Pt(400),await Promise.all(t.map(a=>Dt(a))),await new Promise(a=>setTimeout(a,2e3)),te!=null&&te.contains(e.el)&&!e.el.closest(".ghost")&&ue()}function Tn(e,t=4){window.setTimeout(async()=>{var n;try{let a=await fe("state");S=a,!te&&!me&&Me(a),!((n=a.person.devices.find(s=>s.id===e))!=null&&n.online)&&t>1&&Tn(e,t-1)}catch{}},1500)}function gr(e,t,n){let a=pn(),s=0,i=0,b=!1,m=Date.now(),L=async()=>{if(s=0,!b){if(Date.now()-m>6e5){b=!0,n();return}if(document.hidden){T();return}try{let P=await fe("state");S=P;let K=P.person.devices.find(O=>O.id===e.id);if(K&&K.handshake>a){b=!0,t(),K.online||Tn(e.id);return}}catch(P){if(P.status===404||P.status===401){b=!0;return}}i++,T()}},T=()=>{!b&&!s&&(s=window.setTimeout(L,i<6?5e3:i<12?15e3:3e4))},E=()=>{!document.hidden&&!b&&!s&&L()};return document.addEventListener("visibilitychange",E),T(),()=>{b=!0,s&&clearTimeout(s),document.removeEventListener("visibilitychange",E)}}var An=e=>`dl.app.${e.id}`;function mr(e){try{let t=localStorage.getItem(An(e));return t==="vpn"||t==="awg"||t==="wg"?t:null}catch{return null}}function vr(e,t){try{localStorage.setItem(An(e),t)}catch{}}var on={vpn:"amnezia",awg:"amneziawg",wg:"wireguard"},yr={ios:"apple",android:"googleplay",windows:"windows",mac:"apple",linux:"linux",unknown:"other"};function le(e,t=!1,n){var i;let a=[r("span",{class:"badge-ic"},R(e.mark)),r("span",{class:"badge-txt"},r("span",{class:"badge-top"},e.top),r("span",{class:"badge-main"},e.main)),r("span",{class:"badge-chev"},R("chevron"))],s=`badge${t?" primary":""}`;return e.onclick?r("button",{type:"button",class:s,onclick:e.onclick,"data-m":n},a):r("a",{class:s,href:e.href,target:(i=e.href)!=null&&i.startsWith("vpn:")?null:"_blank",rel:"noopener noreferrer","data-m":n},a)}function ln(e,t){return r("div",{class:"pills"},t.map(n=>r("button",{type:"button",class:`pill${n.on?" on":""}`,onclick:n.pick,"data-m":`${e}:${n.id}`},n.icon?R(n.icon):null,r("span",{},n.label))))}var we=(e,t,...n)=>r("div",{class:"step"},r("div",{class:"step-head"},r("span",{class:"step-n"},e),r("span",{class:"step-title"},t)),...n);function wr(e){let t=typeof navigator.share=="function";return r("div",{class:"linkrow"},r("span",{class:"mono ellipsis"},e.replace(/^https?:\/\//,"")),r("button",{type:"button",class:"btn small",onclick:n=>ge(e,"Link copied",n.currentTarget)},"Copy"),t?r("button",{type:"button",class:"icon-btn soft","aria-label":"Share the link",onclick:()=>{var n;return navigator.share({url:e,title:(n=S==null?void 0:S.title)!=null?n:"Dawnline"}).catch(()=>{})}},R("share")):null)}async function Ke(e,t){var $e;let n=t!=null?t:await pr(e);if(!n)return;let a=await Lt(n,n.server),s=Yt(ur()),i=bn(),b=e.kind==="phone"||e.kind==="tablet",m=e.kind==="router",L=i==="ios"||i==="android",T=Wt(e.kind),E=($e=mr(e))!=null?$e:m?"awg":"vpn";s.some($=>$.id===E)||(E=m?"awg":"vpn");let P=T.length?T.includes(i)?i:"windows":i,K=Ut(e.kind,i),O=()=>T.length?P===i:K,U=()=>b||P==="ios"||P==="android",V=!1,j=!1,Q="app",v=null,y=r("div",{class:"setup"}),g=Gt(e.kind),k=en(e.kind),d=!1,M=$=>{var q;return(q=s.find(u=>u.id===$))!=null?q:s[0]},l=()=>ln("app",s.filter($=>!m||$.id!=="vpn").map($=>({id:$.id,label:$.name,icon:on[$.id],on:$.id===E,pick:()=>{E=$.id,vr(e,E),Y()}}))),o=()=>ln("os",T.map($=>({id:$,label:$===i?tn($):Xe[$],icon:yr[$],on:$===P,pick:()=>{P=$,Y()}}))),C=()=>{let $=m?Je(E):Vt(E,P);return $?[$.alt?[r("div",{class:"badges2"},le($,!1,"store"),le($.alt,!1,"store-alt")),r("span",{class:"faint s"},$.alt.why)]:le($,!1,"store"),ke(M(E))?r("span",{class:"faint s","data-m":"update"},ke(M(E))):null]:[r("span",{class:"muted s"},`Get ${oe[E]} on the ${Xe[P]} and come back here.`)]},f=()=>we("1",[r("span",{class:"grow","data-m":"get"},`Get ${oe[E]}`),s.length>1&&!V?r("b
Line truncated
|
||||||
@@ -660,3 +660,33 @@ export function mark_issued(m, id) {
|
|||||||
unlock(l);
|
unlock(l);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ---------- set up again (Reconnect) ---------- */
|
||||||
|
|
||||||
|
const RECONNECT = `${DATA_DIR}/reconnect.json`;
|
||||||
|
|
||||||
|
/** Device id → when the person asked to set it up again (router clock). */
|
||||||
|
export function reconnects() {
|
||||||
|
return read_json(RECONNECT, {});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handshake a device counts with: none from before it was set up again,
|
||||||
|
* so it shows "Not set up yet" until it connects after that.
|
||||||
|
*/
|
||||||
|
export function handshake_since(hs, since) {
|
||||||
|
return since && hs <= since ? 0 : hs;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A device is set up again: handshakes up to `at` (router clock) are its old configuration's. */
|
||||||
|
export function mark_reconnect(m, id, at) {
|
||||||
|
let l = lock('reconnect');
|
||||||
|
let all = reconnects();
|
||||||
|
all[id] = at ?? time();
|
||||||
|
for (let k in keys(all))
|
||||||
|
if (!m.devices[k])
|
||||||
|
delete all[k];
|
||||||
|
ensure_dir(DATA_DIR, 0o700);
|
||||||
|
write_json(RECONNECT, all, 0o600);
|
||||||
|
unlock(l);
|
||||||
|
};
|
||||||
|
|
||||||
@@ -104,6 +104,21 @@ export function rotate(id, opts) {
|
|||||||
return cfg;
|
return cfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a device up from scratch (a new phone, the app reinstalled, settings
|
||||||
|
* the admin changed): new keys, so the configuration it holds stops working
|
||||||
|
* with the sync, and it counts as not set up until it connects with the new
|
||||||
|
* one. The usage keeps the old keys' last handshake: awg.handshake_since hides
|
||||||
|
* it. Returns the new configuration, as rotate.
|
||||||
|
*/
|
||||||
|
export function reconnect(id, opts) {
|
||||||
|
opts ??= {};
|
||||||
|
let cfg = rotate(id, opts);
|
||||||
|
// A deferred sync (the page came through this device) lets the old keys live a few seconds more.
|
||||||
|
awg.mark_reconnect(core.load(), id, time() + (opts.defer ? 5 : 0));
|
||||||
|
return cfg;
|
||||||
|
};
|
||||||
|
|
||||||
/** Remove a device. Returns the runtime sync. */
|
/** Remove a device. Returns the runtime sync. */
|
||||||
export function remove(id, opts) {
|
export function remove(id, opts) {
|
||||||
opts ??= {};
|
opts ??= {};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
// that answers anything not shaped like a link (its not_found() twin).
|
// that answers anything not shaped like a link (its not_found() twin).
|
||||||
|
|
||||||
import { stat, readfile } from 'fs';
|
import { stat, readfile } from 'fs';
|
||||||
import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, VERSION, RUN_DIR } from 'dawnline.util';
|
import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, tunnel_name, VERSION, RUN_DIR } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as awg from 'dawnline.awg';
|
import * as awg from 'dawnline.awg';
|
||||||
import * as live from 'dawnline.live';
|
import * as live from 'dawnline.live';
|
||||||
@@ -345,11 +345,8 @@ function state(r) {
|
|||||||
let v = view.person_view(m, person, usage, live.dump(m), view.states(m, usage));
|
let v = view.person_view(m, person, usage, live.dump(m), view.states(m, usage));
|
||||||
v.state = person_state(m, person, usage);
|
v.state = person_state(m, person, usage);
|
||||||
let srv = m.servers[person.server];
|
let srv = m.servers[person.server];
|
||||||
// The device this page was opened from, when it came through the tunnel.
|
// The device this page was opened from, through the tunnel or beside it.
|
||||||
let here = null;
|
let here = view.device_here(v.devices, r.peer);
|
||||||
for (let id, d in m.devices)
|
|
||||||
if (d.person == person.id && d.address == r.peer)
|
|
||||||
here = id;
|
|
||||||
return {
|
return {
|
||||||
title: r.title,
|
title: r.title,
|
||||||
person: v,
|
person: v,
|
||||||
@@ -386,6 +383,15 @@ function api_state(r) {
|
|||||||
send_json(r, '200 OK', state(r));
|
send_json(r, '200 OK', state(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A configuration as the person gets it: the file, and so the tunnel the apps
|
||||||
|
* name after it, is the server's name. The admin's downloads keep the device
|
||||||
|
* in the name: one browser fetches many of them.
|
||||||
|
*/
|
||||||
|
function own_config(c) {
|
||||||
|
return c ? { ...c, filename: `${tunnel_name(c.server)}.conf` } : c;
|
||||||
|
}
|
||||||
|
|
||||||
function api_add(r) {
|
function api_add(r) {
|
||||||
need_open(r);
|
need_open(r);
|
||||||
need_https(r);
|
need_https(r);
|
||||||
@@ -395,7 +401,7 @@ function api_add(r) {
|
|||||||
rate_action(r);
|
rate_action(r);
|
||||||
let res = guard(r, () => devices.add(r.person.id, b.name, b.kind, { by: 'portal', public_key: b.public_key }));
|
let res = guard(r, () => devices.add(r.person.id, b.name, b.kind, { by: 'portal', public_key: b.public_key }));
|
||||||
reload(r);
|
reload(r);
|
||||||
send_json(r, '200 OK', { id: res.id, config: res.config, state: state(r) });
|
send_json(r, '200 OK', { id: res.id, config: own_config(res.config), state: state(r) });
|
||||||
}
|
}
|
||||||
|
|
||||||
function api_config(r, id) {
|
function api_config(r, id) {
|
||||||
@@ -403,7 +409,7 @@ function api_config(r, id) {
|
|||||||
need_open(r);
|
need_open(r);
|
||||||
need_https(r);
|
need_https(r);
|
||||||
awg.mark_issued(r.m, d.id);
|
awg.mark_issued(r.m, d.id);
|
||||||
send_json(r, '200 OK', awg.client_config(r.m, d));
|
send_json(r, '200 OK', own_config(awg.client_config(r.m, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** POST /devices/<id> { action }: what each action does; the answer carries the new state. */
|
/** POST /devices/<id> { action }: what each action does; the answer carries the new state. */
|
||||||
@@ -412,12 +418,13 @@ const ACTIONS = {
|
|||||||
guard(r, () => devices.update(d.id, { name: b.name }, { by: 'portal', person: r.person.id }));
|
guard(r, () => devices.update(d.id, { name: b.name }, { by: 'portal', person: r.person.id }));
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
rotate: (r, d, b) => {
|
// Set up from scratch: new keys and the new configuration, which the set-up sheet takes in.
|
||||||
|
reconnect: (r, d, b) => {
|
||||||
need_https(r);
|
need_https(r);
|
||||||
if (!devices.ready())
|
if (!devices.ready())
|
||||||
fail(r, '503 Service Unavailable', NOT_READY);
|
fail(r, '503 Service Unavailable', NOT_READY);
|
||||||
let config = guard(r, () => devices.rotate(d.id, { by: 'portal', person: r.person.id, defer: d.address == r.peer }));
|
let config = guard(r, () => devices.reconnect(d.id, { by: 'portal', person: r.person.id, defer: d.address == r.peer }));
|
||||||
return { config };
|
return { config: own_config(config) };
|
||||||
},
|
},
|
||||||
'delete': (r, d, b) => {
|
'delete': (r, d, b) => {
|
||||||
guard(r, () => devices.remove(d.id, { by: 'portal', person: r.person.id }));
|
guard(r, () => devices.remove(d.id, { by: 'portal', person: r.person.id }));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||||
|
|
||||||
export const VERSION = '0.8.1';
|
export const VERSION = '0.9.0';
|
||||||
/** GitHub repository with Dawnline releases (updates and the installer). */
|
/** GitHub repository with Dawnline releases (updates and the installer). */
|
||||||
export const REPO = 'tickcount/luci-app-dawnline';
|
export const REPO = 'tickcount/luci-app-dawnline';
|
||||||
export const RUN_DIR = '/var/run/dawnline';
|
export const RUN_DIR = '/var/run/dawnline';
|
||||||
@@ -588,6 +588,18 @@ export function host_label(s) {
|
|||||||
return l || 'device';
|
return l || 'device';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A server's name as a tunnel name ("Outline Home" → "Outline-Home"): the
|
||||||
|
* AmneziaWG and WireGuard apps name the tunnel after the file, and Android and
|
||||||
|
* wg-quick refuse anything but [a-zA-Z0-9_=+.-] up to 15 characters; Windows
|
||||||
|
* refuses its device names (CON, NUL, COM1…). "dawnline" when nothing is left.
|
||||||
|
*/
|
||||||
|
export function tunnel_name(s) {
|
||||||
|
let l = replace(translit(`${s ?? ''}`), /[^A-Za-z0-9]+/g, '-');
|
||||||
|
l = replace(substr(replace(l, /^-+|-+$/g, ''), 0, 15), /-+$/g, '');
|
||||||
|
return l && !match(l, /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i) ? l : 'dawnline';
|
||||||
|
};
|
||||||
|
|
||||||
/* ---------- time ---------- */
|
/* ---------- time ---------- */
|
||||||
|
|
||||||
/** "YYYY-MM-DD" → epoch of the end of that local day (23:59:59). */
|
/** "YYYY-MM-DD" → epoch of the end of that local day (23:59:59). */
|
||||||
|
|||||||
@@ -23,11 +23,35 @@ function config_stale(m, d) {
|
|||||||
return was != null && was != awg.config_fingerprint(m, d);
|
return was != null && was != awg.config_fingerprint(m, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The device a page request came from (`devs`: one person's device views):
|
||||||
|
* through the tunnel, by its tunnel address; outside it, the one online device
|
||||||
|
* whose tunnel comes from the request's address. The apps route the VPN's own
|
||||||
|
* address around their tunnel, and the portal shares it, so a device on the VPN
|
||||||
|
* opens the page from where its tunnel comes from. Two such devices behind one
|
||||||
|
* address (one NAT): neither.
|
||||||
|
*/
|
||||||
|
export function device_here(devs, peer) {
|
||||||
|
peer = replace(peer ?? '', /^::ffff:/, '');
|
||||||
|
if (!peer)
|
||||||
|
return null;
|
||||||
|
let near = [];
|
||||||
|
for (let d in devs) {
|
||||||
|
if (d.address == peer)
|
||||||
|
return d.id;
|
||||||
|
if (d.online && d.endpoint == peer)
|
||||||
|
push(near, d.id);
|
||||||
|
}
|
||||||
|
return length(near) == 1 ? near[0] : null;
|
||||||
|
};
|
||||||
|
|
||||||
export function device_view(m, d, usage, dmp) {
|
export function device_view(m, d, usage, dmp) {
|
||||||
let u = usage.devices?.[d.id];
|
let u = usage.devices?.[d.id];
|
||||||
let peer = dmp.peers[d.public_key];
|
let peer = dmp.peers[d.public_key];
|
||||||
let ts = time();
|
let ts = time();
|
||||||
let hs = peer?.handshake || u?.handshake || 0;
|
// Set up again (Reconnect): a handshake from before it does not count.
|
||||||
|
m._reconnect ??= awg.reconnects();
|
||||||
|
let hs = awg.handshake_since(peer?.handshake || u?.handshake || 0, m._reconnect[d.id]);
|
||||||
let p = m.people[d.person];
|
let p = m.people[d.person];
|
||||||
// The same label /tmp/hosts carries (core.device_labels), so what is shown resolves.
|
// The same label /tmp/hosts carries (core.device_labels), so what is shown resolves.
|
||||||
let label = '';
|
let label = '';
|
||||||
@@ -44,7 +68,7 @@ export function device_view(m, d, usage, dmp) {
|
|||||||
disabled: d.disabled,
|
disabled: d.disabled,
|
||||||
created: d.created,
|
created: d.created,
|
||||||
created_by: d.created_by,
|
created_by: d.created_by,
|
||||||
online: live.online(dmp, d.id, peer),
|
online: hs > 0 && live.online(dmp, d.id, peer),
|
||||||
handshake: hs,
|
handshake: hs,
|
||||||
endpoint: live.endpoint_ip(peer?.endpoint) || u?.endpoint || '',
|
endpoint: live.endpoint_ip(peer?.endpoint) || u?.endpoint || '',
|
||||||
active: !!peer,
|
active: !!peer,
|
||||||
|
|||||||
+11
-2
@@ -1,6 +1,6 @@
|
|||||||
// dawnline.awg: disguise presets against their own validation, and the parser
|
// dawnline.awg: disguise presets against their own validation, the parser
|
||||||
// of `awg show all dump` on the output formats of AmneziaWG 1.0, 2.0 and 3.1
|
// of `awg show all dump` on the output formats of AmneziaWG 1.0, 2.0 and 3.1
|
||||||
// (the stand-in awg in fixtures/bin prints the fixture put at AWG_DUMP).
|
// (the stand-in awg in fixtures/bin prints the fixture put at AWG_DUMP), and Reconnect.
|
||||||
import { readfile, writefile, unlink } from 'fs';
|
import { readfile, writefile, unlink } from 'fs';
|
||||||
import * as awg from 'dawnline.awg';
|
import * as awg from 'dawnline.awg';
|
||||||
|
|
||||||
@@ -94,3 +94,12 @@ test('dump: the tool fails', () => {
|
|||||||
let d = awg.dump();
|
let d = awg.dump();
|
||||||
eq(d, { ok: false, ifaces: {}, peers: {} }, 'nothing known');
|
eq(d, { ok: false, ifaces: {}, peers: {} }, 'nothing known');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('handshake_since: Reconnect hides older handshakes', () => {
|
||||||
|
eq(awg.handshake_since(1000, null), 1000, 'never set up again');
|
||||||
|
eq(awg.handshake_since(1000, 0), 1000, 'no time');
|
||||||
|
eq(awg.handshake_since(1000, 1500), 0, 'connected before: not set up yet');
|
||||||
|
eq(awg.handshake_since(1500, 1500), 0, 'the same second does not count');
|
||||||
|
eq(awg.handshake_since(1600, 1500), 1600, 'connected after');
|
||||||
|
eq(awg.handshake_since(0, 1500), 0, 'never connected');
|
||||||
|
});
|
||||||
@@ -117,7 +117,7 @@ test('dates', () => {
|
|||||||
eq(util.uniq([ 'a', 'b', 'a', 'c', 'b' ]), [ 'a', 'b', 'c' ], 'uniq');
|
eq(util.uniq([ 'a', 'b', 'a', 'c', 'b' ]), [ 'a', 'b', 'c' ], 'uniq');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('text: ulength, ucut, translit, host_label', () => {
|
test('text: ulength, ucut, translit, host_label, tunnel_name', () => {
|
||||||
eq(util.ulength('Мама'), 4, 'characters, not bytes');
|
eq(util.ulength('Мама'), 4, 'characters, not bytes');
|
||||||
eq(util.ulength('abc'), 3, 'ascii');
|
eq(util.ulength('abc'), 3, 'ascii');
|
||||||
eq(util.ucut('Привет', 3), 'При', 'cut by characters');
|
eq(util.ucut('Привет', 3), 'При', 'cut by characters');
|
||||||
@@ -127,6 +127,16 @@ test('text: ulength, ucut, translit, host_label', () => {
|
|||||||
eq(util.translit('Mixed Текст 1'), 'Mixed tekst 1', 'Latin and digits pass');
|
eq(util.translit('Mixed Текст 1'), 'Mixed tekst 1', 'Latin and digits pass');
|
||||||
eq(util.host_label('Galaxy S24'), 'galaxy-s24', 'label');
|
eq(util.host_label('Galaxy S24'), 'galaxy-s24', 'label');
|
||||||
eq(util.host_label('Телефон Ёжика'), 'telefon-yozhika', 'Cyrillic label');
|
eq(util.host_label('Телефон Ёжика'), 'telefon-yozhika', 'Cyrillic label');
|
||||||
|
eq(util.tunnel_name('Outline Home'), 'Outline-Home', 'tunnel name keeps the case');
|
||||||
|
eq(util.tunnel_name('Дом у моря'), 'dom-u-morya', 'Cyrillic tunnel name');
|
||||||
|
eq(util.tunnel_name(' My VPN (home)! '), 'My-VPN-home', 'tunnel name: runs of other characters are one dash');
|
||||||
|
eq(util.tunnel_name('A very long server name'), 'A-very-long-ser', 'tunnel name: 15 characters at most');
|
||||||
|
eq(util.tunnel_name('Home server 12345'), 'Home-server-123', 'tunnel name: cut');
|
||||||
|
eq(util.tunnel_name('Lakeside house x'), 'Lakeside-house', 'tunnel name: no dash left at the cut');
|
||||||
|
eq(util.tunnel_name('nul'), 'dawnline', 'tunnel name: a Windows device name');
|
||||||
|
eq(util.tunnel_name('COM1'), 'dawnline', 'tunnel name: a Windows device name, any case');
|
||||||
|
eq(util.tunnel_name('???'), 'dawnline', 'tunnel name: nothing left');
|
||||||
|
eq(util.tunnel_name(null), 'dawnline', 'tunnel name: null');
|
||||||
eq(util.host_label('!!!'), 'device', 'nothing left');
|
eq(util.host_label('!!!'), 'device', 'nothing left');
|
||||||
eq(length(util.host_label(replace(sprintf('%50s', ''), ' ', 'x'))), 40, 'cut at 40');
|
eq(length(util.host_label(replace(sprintf('%50s', ''), ' ', 'x'))), 40, 'cut at 40');
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// dawnline.view: which device a portal page was opened from.
|
||||||
|
import * as view from 'dawnline.view';
|
||||||
|
|
||||||
|
const devs = [
|
||||||
|
{ id: 'd_1', address: '10.0.0.2', online: true, endpoint: '203.0.113.7' },
|
||||||
|
{ id: 'd_2', address: '10.0.0.3', online: false, endpoint: '198.51.100.4' },
|
||||||
|
{ id: 'd_3', address: '10.0.0.4', online: true, endpoint: '192.0.2.9' },
|
||||||
|
];
|
||||||
|
|
||||||
|
test('device_here', () => {
|
||||||
|
eq(view.device_here(devs, '10.0.0.3'), 'd_2', 'through the tunnel: its address, online or not');
|
||||||
|
eq(view.device_here(devs, '203.0.113.7'), 'd_1', 'beside the tunnel: where its tunnel comes from');
|
||||||
|
eq(view.device_here(devs, '::ffff:203.0.113.7'), 'd_1', 'an IPv4 request on a dual-stack socket');
|
||||||
|
eq(view.device_here(devs, '198.51.100.4'), null, 'a device that is not online does not count');
|
||||||
|
eq(view.device_here(devs, '233.252.0.1'), null, 'from elsewhere');
|
||||||
|
eq(view.device_here([ ...devs, { id: 'd_4', address: '10.0.0.5', online: true, endpoint: '203.0.113.7' } ], '203.0.113.7'), null,
|
||||||
|
'two devices behind one address: neither');
|
||||||
|
eq(view.device_here(devs, ''), null, 'no address');
|
||||||
|
eq(view.device_here([ { id: 'd_5', address: '10.0.0.6', online: true, endpoint: '' } ], ''), null, 'no address, no endpoint');
|
||||||
|
});
|
||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.8.1",
|
"version": "0.9.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.8.1",
|
"version": "0.9.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"qrcode-generator": "1.4.4"
|
"qrcode-generator": "1.4.4"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.8.1",
|
"version": "0.9.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr
|
|||||||
{ class: 'dl-hint' },
|
{ class: 'dl-hint' },
|
||||||
'This device generated its own keys in the browser, so its full configuration only exists on that device.',
|
'This device generated its own keys in the browser, so its full configuration only exists on that device.',
|
||||||
);
|
);
|
||||||
const key = await vpnKey(cfg, `${cfg.server} · ${cfg.person} · ${cfg.name}`);
|
const key = await vpnKey(cfg, cfg.server);
|
||||||
const panes: Record<string, () => Node> = {
|
const panes: Record<string, () => Node> = {
|
||||||
qr: () =>
|
qr: () =>
|
||||||
E('div', { class: 'dl-qr-pane' }, [
|
E('div', { class: 'dl-qr-pane' }, [
|
||||||
@@ -437,6 +437,6 @@ export const awg: Core = {
|
|||||||
overviewTile,
|
overviewTile,
|
||||||
connectBlock,
|
connectBlock,
|
||||||
qrText: (cfg) => cfg.conf,
|
qrText: (cfg) => cfg.conf,
|
||||||
appKey: { label: 'Copy AmneziaVPN key', make: (cfg) => vpnKey(cfg, `${cfg.server} · ${cfg.person} · ${cfg.name}`) },
|
appKey: { label: 'Copy AmneziaVPN key', make: (cfg) => vpnKey(cfg, cfg.server) },
|
||||||
file: { label: 'Download .conf', make: (cfg) => ({ name: cfg.filename, text: cfg.conf }) },
|
file: { label: 'Download .conf', make: (cfg) => ({ name: cfg.filename, text: cfg.conf }) },
|
||||||
};
|
};
|
||||||
+109
-262
@@ -22,32 +22,18 @@ import {
|
|||||||
} from '../shared/format';
|
} from '../shared/format';
|
||||||
import { iconSvg } from '../shared/icons';
|
import { iconSvg } from '../shared/icons';
|
||||||
import { denseQr, qrSvg } from '../shared/qr';
|
import { denseQr, qrSvg } from '../shared/qr';
|
||||||
import { vpnKey } from '../shared/vpnkey';
|
import { vpnKey, vpnQrText } from '../shared/vpnkey';
|
||||||
import { h, ic, type Kid } from './dom';
|
import { h, ic, type Kid } from './dom';
|
||||||
import { waitPath, type Way } from './waitpath';
|
import { waitPath, type Way } from './waitpath';
|
||||||
import {
|
import { beat, busy, calm, copied, fold, followHeight, intro, leave, pullToClose, replay, restyle, settle, snap, swap } from './motion';
|
||||||
beat,
|
|
||||||
busy,
|
|
||||||
calm,
|
|
||||||
copied,
|
|
||||||
fold,
|
|
||||||
followHeight,
|
|
||||||
intro,
|
|
||||||
leave,
|
|
||||||
pullToClose,
|
|
||||||
replay,
|
|
||||||
restyle,
|
|
||||||
settle,
|
|
||||||
slider,
|
|
||||||
snap,
|
|
||||||
swap,
|
|
||||||
} from './motion';
|
|
||||||
import {
|
import {
|
||||||
APP_NAME,
|
APP_NAME,
|
||||||
appsFor,
|
appsFor,
|
||||||
hereLabel,
|
hereLabel,
|
||||||
deviceNoun,
|
deviceNoun,
|
||||||
importPath,
|
importSteps,
|
||||||
|
keyFileName,
|
||||||
|
opensKeyLinks,
|
||||||
setupFromHash,
|
setupFromHash,
|
||||||
setupLink,
|
setupLink,
|
||||||
inWebview,
|
inWebview,
|
||||||
@@ -172,20 +158,23 @@ async function copy(text: string, what = 'Copied', from?: EventTarget | null) {
|
|||||||
* download would land in Files. Returns the action, or null where files
|
* download would land in Files. Returns the action, or null where files
|
||||||
* cannot be shared.
|
* cannot be shared.
|
||||||
*/
|
*/
|
||||||
function shareFile(cfg: ClientConfig): (() => Promise<void>) | null {
|
function shareFile(name: string, text: string): (() => Promise<void>) | null {
|
||||||
const nav = navigator as Navigator & { canShare?: (d: unknown) => boolean };
|
const nav = navigator as Navigator & { canShare?: (d: unknown) => boolean };
|
||||||
// Desktop browsers claim they can share files and then do nothing, or open a
|
// Only iOS: there AmneziaWG, WireGuard and AmneziaVPN take a file from the
|
||||||
// sheet with nowhere useful: there a download is the right thing anyway.
|
// share sheet. On Android neither app is a share target (and Chrome does not
|
||||||
if (!/Android|iPhone|iPad/.test(navigator.userAgent)) return null;
|
// share .conf files), so a download goes into the app's own file picker;
|
||||||
|
// desktop browsers claim they can share files and then do nothing.
|
||||||
|
if (platform() !== 'ios') return null;
|
||||||
if (typeof nav.share !== 'function' || typeof File === 'undefined') return null;
|
if (typeof nav.share !== 'function' || typeof File === 'undefined') return null;
|
||||||
const file = new File([cfg.conf], cfg.filename, { type: 'application/octet-stream' });
|
const file = new File([text], name, { type: 'application/octet-stream' });
|
||||||
if (!nav.canShare?.({ files: [file] })) return null;
|
if (!nav.canShare?.({ files: [file] })) return null;
|
||||||
return async () => {
|
return async () => {
|
||||||
try {
|
try {
|
||||||
await nav.share({ files: [file], title: cfg.filename });
|
// The file alone: with a title, "Save to Files" also writes the title as a .txt.
|
||||||
|
await nav.share({ files: [file] });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Cancelled: nothing to do. Refused by the browser: the file still has to get out.
|
// Cancelled: nothing to do. Refused by the browser: the file still has to get out.
|
||||||
if ((e as Error)?.name !== 'AbortError') download(cfg.filename, cfg.conf);
|
if ((e as Error)?.name !== 'AbortError') download(name, text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -356,7 +345,7 @@ function sheet(title: string, sub: string | null, ...content: Kid[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A question before something that cannot be undone (Remove, New keys): narrow
|
* A question before something that cannot be undone (Remove, Reconnect): narrow
|
||||||
* and centred, the action's icon in its colour, one line of what happens, Cancel
|
* and centred, the action's icon in its colour, one line of what happens, Cancel
|
||||||
* and the action (no ×: Cancel says it). `run` holds the action's button busy.
|
* and the action (no ×: Cancel says it). `run` holds the action's button busy.
|
||||||
*/
|
*/
|
||||||
@@ -430,7 +419,7 @@ document.addEventListener('click', (e) => {
|
|||||||
if (menuEl && !menuEl.contains(e.target as Node)) closeMenu();
|
if (menuEl && !menuEl.contains(e.target as Node)) closeMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
function menu(anchor: HTMLElement, all: ({ label: string; icon: string; danger?: boolean; run: () => unknown } | null)[]) {
|
function menu(anchor: HTMLElement, all: ({ label: string; icon: string; danger?: boolean; warn?: boolean; run: () => unknown } | null)[]) {
|
||||||
if (menuFor === anchor) return closeMenu();
|
if (menuFor === anchor) return closeMenu();
|
||||||
closeMenu();
|
closeMenu();
|
||||||
// Separators only between items.
|
// Separators only between items.
|
||||||
@@ -445,7 +434,7 @@ function menu(anchor: HTMLElement, all: ({ label: string; icon: string; danger?:
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
role: 'menuitem',
|
role: 'menuitem',
|
||||||
class: `menu-item${it.danger ? ' danger' : ''}`,
|
class: `menu-item${it.danger ? ' danger' : it.warn ? ' warn' : ''}`,
|
||||||
onclick: () => {
|
onclick: () => {
|
||||||
closeMenu();
|
closeMenu();
|
||||||
it.run();
|
it.run();
|
||||||
@@ -748,13 +737,8 @@ function deviceCard(d: Device, st: State): HTMLElement {
|
|||||||
{ type: 'button', class: 'icon-btn soft', 'aria-label': `${d.name} options`, 'aria-haspopup': 'menu', 'aria-expanded': 'false' },
|
{ type: 'button', class: 'icon-btn soft', 'aria-label': `${d.name} options`, 'aria-haspopup': 'menu', 'aria-expanded': 'false' },
|
||||||
ic('more'),
|
ic('more'),
|
||||||
);
|
);
|
||||||
more.addEventListener('click', (ev) => {
|
// The connection itself comes from the set-up sheet (Reconnect), not from here.
|
||||||
ev.stopPropagation();
|
const items = [
|
||||||
menu(more, [
|
|
||||||
{ label: 'Show QR code', icon: 'qr', run: () => connect(d, 'qr') },
|
|
||||||
{ label: 'Copy AmneziaVPN key', icon: 'key', run: () => copyKey(d) },
|
|
||||||
{ label: 'Download .conf', icon: 'download', run: () => downloadConf(d) },
|
|
||||||
null,
|
|
||||||
// How devices at home reach it: only where the router actually lets them through.
|
// How devices at home reach it: only where the router actually lets them through.
|
||||||
...(reachableFromHome(st.person, d)
|
...(reachableFromHome(st.person, d)
|
||||||
? [
|
? [
|
||||||
@@ -763,15 +747,18 @@ function deviceCard(d: Device, st: State): HTMLElement {
|
|||||||
null,
|
null,
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
// A device the admin turned off can't be renamed, rekeyed or removed here (the router refuses).
|
// A device the admin turned off can't be renamed, set up again or removed here (the router refuses).
|
||||||
...(d.disabled
|
...(d.disabled
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
{ label: 'Rename', icon: 'edit', run: () => rename(d) },
|
{ label: 'Rename', icon: 'edit', run: () => rename(d) },
|
||||||
{ label: 'New keys', icon: 'reset', run: () => rotateKeys(d, st) },
|
{ label: 'Reconnect', icon: 'refresh', warn: true, run: () => reconnect(d, st) },
|
||||||
{ label: 'Remove', icon: 'trash', danger: true, run: () => removeDevice(d) },
|
{ label: 'Remove', icon: 'trash', danger: true, run: () => removeDevice(d) },
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
more.addEventListener('click', (ev) => {
|
||||||
|
ev.stopPropagation();
|
||||||
|
menu(more, items);
|
||||||
});
|
});
|
||||||
const week = d.spark.reduce((a, b) => a + b, 0);
|
const week = d.spark.reduce((a, b) => a + b, 0);
|
||||||
const setUp = !d.handshake && !d.disabled;
|
const setUp = !d.handshake && !d.disabled;
|
||||||
@@ -791,7 +778,7 @@ function deviceCard(d: Device, st: State): HTMLElement {
|
|||||||
{ class: 'dhead' },
|
{ class: 'dhead' },
|
||||||
h('span', { class: 'dic' }, ic(d.kind)),
|
h('span', { class: 'dic' }, ic(d.kind)),
|
||||||
h('div', { class: 'stack grow' }, h('span', { class: 'dname', 'data-v': `name:${d.id}` }, d.name), status),
|
h('div', { class: 'stack grow' }, h('span', { class: 'dname', 'data-v': `name:${d.id}` }, d.name), status),
|
||||||
locked ? null : more,
|
locked || !items.length ? null : more,
|
||||||
),
|
),
|
||||||
setUp && locked
|
setUp && locked
|
||||||
? null
|
? null
|
||||||
@@ -819,7 +806,7 @@ function deviceCard(d: Device, st: State): HTMLElement {
|
|||||||
d.config_stale && !setUp && !locked
|
d.config_stale && !setUp && !locked
|
||||||
? h(
|
? h(
|
||||||
'button',
|
'button',
|
||||||
{ type: 'button', class: 'btn block', onclick: () => connect(d) },
|
{ type: 'button', class: 'btn block', onclick: () => reconnect(d, st) },
|
||||||
ic('refresh'),
|
ic('refresh'),
|
||||||
h('span', {}, 'Update the connection'),
|
h('span', {}, 'Update the connection'),
|
||||||
)
|
)
|
||||||
@@ -913,16 +900,6 @@ function main(st: State) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Where to get the app on this platform: the store on phones, the downloads page elsewhere. */
|
|
||||||
function appLink(): { href: string; label: string } {
|
|
||||||
const pf = platform();
|
|
||||||
const st = storeFor('vpn', pf);
|
|
||||||
return {
|
|
||||||
href: st?.href ?? 'https://github.com/amnezia-vpn/amnezia-client/releases/latest',
|
|
||||||
label: `Get AmneziaVPN${pf === 'ios' ? ' for iPhone' : pf === 'android' ? ' for Android' : ''}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The platform this page is open on (iPad on Safari says Mac; touch points tell). */
|
/** The platform this page is open on (iPad on Safari says Mac; touch points tell). */
|
||||||
const platform = (): Platform => platformOf(navigator.userAgent, navigator.maxTouchPoints);
|
const platform = (): Platform => platformOf(navigator.userAgent, navigator.maxTouchPoints);
|
||||||
/** The server's disguise generation, for which apps and versions connect. */
|
/** The server's disguise generation, for which apps and versions connect. */
|
||||||
@@ -1037,17 +1014,6 @@ async function getConfig(d: Device): Promise<ClientConfig | null> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function copyKey(d: Device) {
|
|
||||||
const cfg = await getConfig(d);
|
|
||||||
if (cfg) copy(await vpnKey(cfg, `${cfg.server} · ${cfg.name}`), 'Key copied');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function downloadConf(d: Device) {
|
|
||||||
const cfg = await getConfig(d);
|
|
||||||
if (cfg) download(cfg.filename, cfg.conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Connection sheet: open-in-app / QR / key / file, plus live status. */
|
|
||||||
/** One configuration line, highlighted; private and preshared keys masked unless shown. */
|
/** One configuration line, highlighted; private and preshared keys masked unless shown. */
|
||||||
function confLine(line: string, reveal: boolean): Node {
|
function confLine(line: string, reveal: boolean): Node {
|
||||||
if (/^\s*\[.+\]\s*$/.test(line)) return h('span', { class: 'conf-sec' }, line);
|
if (/^\s*\[.+\]\s*$/.test(line)) return h('span', { class: 'conf-sec' }, line);
|
||||||
@@ -1107,8 +1073,13 @@ function filePane(cfg: ClientConfig): HTMLElement {
|
|||||||
: 'For computers and routers: import it in AmneziaWG or AmneziaVPN',
|
: 'For computers and routers: import it in AmneziaWG or AmneziaVPN',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
shareFile(cfg)
|
shareFile(cfg.filename, cfg.conf)
|
||||||
? h('button', { class: 'btn primary', onclick: () => shareFile(cfg)!() }, ic('open'), h('span', {}, 'Share file'))
|
? h(
|
||||||
|
'button',
|
||||||
|
{ class: 'btn primary', onclick: () => shareFile(cfg.filename, cfg.conf)!() },
|
||||||
|
ic('open'),
|
||||||
|
h('span', {}, 'Share file'),
|
||||||
|
)
|
||||||
: h('button', { class: 'btn primary', onclick: () => download(cfg.filename, cfg.conf) }, ic('download'), h('span', {}, 'Download')),
|
: h('button', { class: 'btn primary', onclick: () => download(cfg.filename, cfg.conf) }, ic('download'), h('span', {}, 'Download')),
|
||||||
),
|
),
|
||||||
h(
|
h(
|
||||||
@@ -1139,152 +1110,6 @@ function filePane(cfg: ClientConfig): HTMLElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function connect(d: Device, initial?: 'app' | 'qr' | 'key' | 'file', cfgIn?: ClientConfig) {
|
|
||||||
const cfg = cfgIn ?? (await getConfig(d));
|
|
||||||
if (!cfg) return;
|
|
||||||
const key = await vpnKey(cfg, `${cfg.server} · ${cfg.name}`);
|
|
||||||
const mobile = isMobile();
|
|
||||||
// What is being set up decides what comes first: a phone from a phone opens
|
|
||||||
// the app, a phone seen from a computer shows the code, a computer or
|
|
||||||
// router takes the file.
|
|
||||||
const handheld = d.kind === 'phone' || d.kind === 'tablet';
|
|
||||||
const panes: Record<string, () => HTMLElement> = {
|
|
||||||
app: () =>
|
|
||||||
h(
|
|
||||||
'div',
|
|
||||||
{ class: 'pane' },
|
|
||||||
h('a', { class: 'btn primary block big', href: key }, ic('amnezia'), h('span', {}, 'Open in AmneziaVPN')),
|
|
||||||
h(
|
|
||||||
'ol',
|
|
||||||
{ class: 'steps' },
|
|
||||||
h(
|
|
||||||
'li',
|
|
||||||
{},
|
|
||||||
'No AmneziaVPN yet? ',
|
|
||||||
h('a', { href: appLink().href, target: '_blank', rel: 'noopener noreferrer' }, appLink().label),
|
|
||||||
'.',
|
|
||||||
),
|
|
||||||
h('li', {}, 'Tap ', h('b', {}, 'Open in AmneziaVPN'), ' and confirm the import.'),
|
|
||||||
h('li', {}, 'Turn the connection on — this page shows ', h('span', { class: 'ok' }, 'Connected'), ' within a minute.'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
qr: () => {
|
|
||||||
// Two codes: AmneziaVPN reads its own key (the phone's camera opens it in
|
|
||||||
// the app); the AmneziaWG and WireGuard apps read the configuration text.
|
|
||||||
const q = h('div', { class: 'qr' });
|
|
||||||
const cap = h('p', { class: 'muted s' });
|
|
||||||
const seg = h('div', { class: 'seg' });
|
|
||||||
let mode: 'vpn' | 'conf' = plainWg() ? 'conf' : 'vpn';
|
|
||||||
let glide = () => {};
|
|
||||||
// The other code comes into focus where the last one was.
|
|
||||||
const paint = (switched = false) => {
|
|
||||||
const text = mode === 'vpn' ? key : cfg.conf;
|
|
||||||
// A dense code is drawn as large as the sheet allows: a phone camera needs the modules.
|
|
||||||
paintQr(q, text);
|
|
||||||
cap.textContent =
|
|
||||||
mode === 'vpn'
|
|
||||||
? 'Scan with the phone’s camera or inside AmneziaVPN.'
|
|
||||||
: plainWg()
|
|
||||||
? 'Scan inside the AmneziaWG, WireGuard or AmneziaVPN app.'
|
|
||||||
: 'Scan inside the AmneziaWG app (or AmneziaVPN).';
|
|
||||||
seg.querySelectorAll<HTMLElement>(':scope > button').forEach((b) => b.classList.toggle('on', b.dataset.m === mode));
|
|
||||||
glide();
|
|
||||||
if (switched) {
|
|
||||||
replay(q, 'swap');
|
|
||||||
replay(cap, 'swap');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
for (const [m, label] of [
|
|
||||||
['vpn', 'AmneziaVPN'],
|
|
||||||
['conf', plainWg() ? 'WireGuard app' : 'AmneziaWG app'],
|
|
||||||
] as const)
|
|
||||||
seg.appendChild(
|
|
||||||
h(
|
|
||||||
'button',
|
|
||||||
{
|
|
||||||
type: 'button',
|
|
||||||
'data-m': m,
|
|
||||||
onclick: () => {
|
|
||||||
if (mode === m) return;
|
|
||||||
mode = m;
|
|
||||||
paint(true);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
label,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
paint();
|
|
||||||
glide = slider(seg);
|
|
||||||
return h('div', { class: 'pane center' }, seg, q, cap, qrFlip());
|
|
||||||
},
|
|
||||||
key: () =>
|
|
||||||
h(
|
|
||||||
'div',
|
|
||||||
{ class: 'pane' },
|
|
||||||
h('p', { class: 'muted s' }, 'In AmneziaVPN choose “Add server → Insert key”.'),
|
|
||||||
h(
|
|
||||||
'div',
|
|
||||||
{ class: 'keybox' },
|
|
||||||
h('span', { class: 'mono' }, key),
|
|
||||||
h('button', { class: 'btn small', onclick: (ev: Event) => copy(key, 'Key copied', ev.currentTarget) }, 'Copy'),
|
|
||||||
),
|
|
||||||
h('p', { class: 'faint s' }, 'Keep it private: anyone with the key can use your connection.'),
|
|
||||||
),
|
|
||||||
file: () => filePane(cfg),
|
|
||||||
};
|
|
||||||
const order = mobile && handheld ? ['app', 'qr', 'key', 'file'] : handheld ? ['qr', 'key', 'file'] : ['file', 'key', 'qr'];
|
|
||||||
const labels: Record<string, string> = { app: 'Open in app', qr: 'QR code', key: 'Key', file: 'File' };
|
|
||||||
const body = h('div', { class: 'tab-body' });
|
|
||||||
const tabs = h('div', { class: 'tabs', role: 'tablist' });
|
|
||||||
// The highlight slides to the tab; its pane comes in from that side.
|
|
||||||
let current = -1;
|
|
||||||
let glide = () => {};
|
|
||||||
const show = (id: string) => {
|
|
||||||
const i = order.indexOf(id);
|
|
||||||
tabs.querySelectorAll<HTMLElement>(':scope > button').forEach((b) => {
|
|
||||||
b.classList.toggle('on', b.dataset.id === id);
|
|
||||||
b.setAttribute('aria-selected', String(b.dataset.id === id));
|
|
||||||
});
|
|
||||||
glide();
|
|
||||||
if (current < 0) body.replaceChildren(panes[id]());
|
|
||||||
else if (i !== current) swap(body, [panes[id]()], Math.sign(i - current));
|
|
||||||
current = i;
|
|
||||||
};
|
|
||||||
for (const id of order) tabs.appendChild(h('button', { role: 'tab', 'data-id': id, onclick: () => show(id) }, labels[id]));
|
|
||||||
show(initial && order.includes(initial) ? initial : order[0]);
|
|
||||||
glide = slider(tabs);
|
|
||||||
|
|
||||||
// Never connected: the way to the router waits on top, and once it fills the
|
|
||||||
// code and the file have done their job and leave. Connected before: one line.
|
|
||||||
const way = d.handshake || d.disabled ? null : waitPath(d.kind);
|
|
||||||
const stop = way ? watchFirstConnection(d, () => void arrive(way, [tabs, body]), way.gaveUp) : () => undefined;
|
|
||||||
sheet(
|
|
||||||
d.handshake ? `Connect ${d.name}` : `${d.name} is ready`,
|
|
||||||
mobile && handheld
|
|
||||||
? 'Add it to AmneziaVPN on this phone'
|
|
||||||
: handheld
|
|
||||||
? 'Scan with the phone’s camera or AmneziaVPN'
|
|
||||||
: 'Import the file in AmneziaWG or AmneziaVPN',
|
|
||||||
way?.el,
|
|
||||||
tabs,
|
|
||||||
body,
|
|
||||||
d.handshake ? liveLine(d) : null,
|
|
||||||
);
|
|
||||||
sheetClosed = () => {
|
|
||||||
stop();
|
|
||||||
if (state) main(state);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** How a device that connected before is doing: one line under the sheet. */
|
|
||||||
function liveLine(d: Device): HTMLElement {
|
|
||||||
return h(
|
|
||||||
'div',
|
|
||||||
{ class: 'waiting' },
|
|
||||||
d.online ? h('span', { class: 'ok' }, 'Connected') : h('span', { class: 'muted' }, `Last connected ${ago(d.handshake, now())}`),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The first connection arrived. The way fills green (the sheet goes back up to
|
* The first connection arrived. The way fills green (the sheet goes back up to
|
||||||
* it if it was scrolled) and says so; then everything under it, which did its
|
* it if it was scrolled) and says so; then everything under it, which did its
|
||||||
@@ -1405,6 +1230,14 @@ function rememberApp(d: Device, app: AppId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const APP_ICON: Record<AppId, string> = { vpn: 'amnezia', awg: 'amneziawg', wg: 'wireguard' };
|
const APP_ICON: Record<AppId, string> = { vpn: 'amnezia', awg: 'amneziawg', wg: 'wireguard' };
|
||||||
|
const OS_ICON: Record<Platform, string> = {
|
||||||
|
ios: 'apple',
|
||||||
|
android: 'googleplay',
|
||||||
|
windows: 'windows',
|
||||||
|
mac: 'apple',
|
||||||
|
linux: 'linux',
|
||||||
|
unknown: 'other',
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A store badge: the mark in a tile, two lines, a chevron. `primary` = the one thing to tap.
|
* A store badge: the mark in a tile, two lines, a chevron. `primary` = the one thing to tap.
|
||||||
@@ -1486,18 +1319,22 @@ function linkRow(url: string): HTMLElement {
|
|||||||
async function setup(d: Device, cfgIn?: ClientConfig) {
|
async function setup(d: Device, cfgIn?: ClientConfig) {
|
||||||
const cfg = cfgIn ?? (await getConfig(d));
|
const cfg = cfgIn ?? (await getConfig(d));
|
||||||
if (!cfg) return;
|
if (!cfg) return;
|
||||||
const key = await vpnKey(cfg, `${cfg.server} · ${cfg.name}`);
|
const key = await vpnKey(cfg, cfg.server);
|
||||||
const apps = appsFor(preset());
|
const apps = appsFor(preset());
|
||||||
const pf = platform();
|
const pf = platform();
|
||||||
const same = sameDevice(d.kind, pf);
|
|
||||||
const handheld = d.kind === 'phone' || d.kind === 'tablet';
|
const handheld = d.kind === 'phone' || d.kind === 'tablet';
|
||||||
const router = d.kind === 'router';
|
const router = d.kind === 'router';
|
||||||
const hereHandheld = pf === 'ios' || pf === 'android';
|
const hereHandheld = pf === 'ios' || pf === 'android';
|
||||||
const osChoices = osGroup(d.kind);
|
const osChoices = osGroup(d.kind);
|
||||||
let app: AppId = recallApp(d) ?? (router ? 'awg' : 'vpn');
|
let app: AppId = recallApp(d) ?? (router ? 'awg' : 'vpn');
|
||||||
if (!apps.some((a) => a.id === app)) app = router ? 'awg' : 'vpn';
|
if (!apps.some((a) => a.id === app)) app = router ? 'awg' : 'vpn';
|
||||||
// Which system a computer runs is the person's call; the browser's guess comes first.
|
// Which system a computer (or an "other" device) runs is the person's call; the browser's guess comes first.
|
||||||
let os: Platform = osChoices.length ? (osChoices.includes(pf) ? pf : 'windows') : pf;
|
let os: Platform = osChoices.length ? (osChoices.includes(pf) ? pf : 'windows') : pf;
|
||||||
|
// With a system to pick, the page is on the device being set up when the pick is this browser's own.
|
||||||
|
const sameKind = sameDevice(d.kind, pf);
|
||||||
|
const same = () => (osChoices.length ? os === pf : sameKind);
|
||||||
|
// The device being set up is a phone or a tablet: its link goes there as a code for the camera.
|
||||||
|
const mobileTarget = () => handheld || os === 'ios' || os === 'android';
|
||||||
let picker = false,
|
let picker = false,
|
||||||
away = false,
|
away = false,
|
||||||
open: 'link' | 'app' = 'app',
|
open: 'link' | 'app' = 'app',
|
||||||
@@ -1533,7 +1370,7 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
osChoices.map((o) => ({
|
osChoices.map((o) => ({
|
||||||
id: o,
|
id: o,
|
||||||
label: o === pf ? hereLabel(o) : PLATFORM_LABEL[o],
|
label: o === pf ? hereLabel(o) : PLATFORM_LABEL[o],
|
||||||
icon: o === 'windows' ? 'windows' : o === 'mac' ? 'apple' : 'linux',
|
icon: OS_ICON[o],
|
||||||
on: o === os,
|
on: o === os,
|
||||||
pick: () => {
|
pick: () => {
|
||||||
os = o;
|
os = o;
|
||||||
@@ -1591,15 +1428,25 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
// Step 2 follows the app and the device: a link for AmneziaVPN, the file for the others.
|
// Step 2 follows the app and the device: a link for AmneziaVPN, the file for the others.
|
||||||
const connectStep = () => {
|
const connectStep = () => {
|
||||||
const name = APP_NAME[app];
|
const name = APP_NAME[app];
|
||||||
if (app === 'vpn' && hereHandheld)
|
// On the phone being set up, a link opens AmneziaVPN only on Android; an
|
||||||
|
// iPhone takes the key as a .vpn file from the share sheet.
|
||||||
|
const inHand = same() && hereHandheld;
|
||||||
|
const send = app === 'vpn' && inHand && !opensKeyLinks(pf) ? shareFile(keyFileName(cfg.filename), key) : null;
|
||||||
|
if (app === 'vpn' && inHand && (opensKeyLinks(pf) || send))
|
||||||
return step(
|
return step(
|
||||||
'2',
|
'2',
|
||||||
'Add the connection',
|
'Add the connection',
|
||||||
badge({ href: key, top: 'Then come back here and tap', main: 'Open in AmneziaVPN', mark: 'amnezia' }, true, 'connect'),
|
send
|
||||||
|
? badge(
|
||||||
|
{ top: 'Then come back here and tap', main: 'Send to AmneziaVPN', mark: 'amnezia', onclick: () => void send() },
|
||||||
|
true,
|
||||||
|
'connect',
|
||||||
|
)
|
||||||
|
: badge({ href: key, top: 'Then come back here and tap', main: 'Open in AmneziaVPN', mark: 'amnezia' }, true, 'connect'),
|
||||||
h(
|
h(
|
||||||
'span',
|
'span',
|
||||||
{ class: 'faint s' },
|
{ class: 'faint s' },
|
||||||
'Nothing opened? ',
|
send ? 'Pick AmneziaVPN in the share sheet. Not there? ' : 'Nothing opened? ',
|
||||||
h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), copy(key, 'Key copied', ev.currentTarget)) }, 'Copy the key'),
|
h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), copy(key, 'Key copied', ev.currentTarget)) }, 'Copy the key'),
|
||||||
' and add it in the app.',
|
' and add it in the app.',
|
||||||
),
|
),
|
||||||
@@ -1625,14 +1472,22 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
h('li', {}, 'Add server → ', h('b', {}, 'Insert key')),
|
h('li', {}, 'Add server → ', h('b', {}, 'Insert key')),
|
||||||
h('li', {}, 'Paste the key and connect'),
|
h('li', {}, 'Paste the key and connect'),
|
||||||
),
|
),
|
||||||
h('span', { class: 'faint s' }, 'Have the app open? ', h('a', { href: key }, 'Open in AmneziaVPN')),
|
|
||||||
);
|
);
|
||||||
const share = hereHandheld ? shareFile(cfg) : null;
|
const share = hereHandheld ? shareFile(cfg.filename, cfg.conf) : null;
|
||||||
return step(
|
return step(
|
||||||
'2',
|
'2',
|
||||||
'Add the connection',
|
'Add the connection',
|
||||||
share
|
share
|
||||||
? badge({ top: `Straight into ${name}`, main: 'Share the file', mark: 'share', onclick: () => share() }, true, 'connect')
|
? badge(
|
||||||
|
{
|
||||||
|
top: same() ? `Straight into ${name}` : `Send it to the ${there}`,
|
||||||
|
main: 'Share the file',
|
||||||
|
mark: 'share',
|
||||||
|
onclick: () => share(),
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
'connect',
|
||||||
|
)
|
||||||
: badge(
|
: badge(
|
||||||
{
|
{
|
||||||
top: 'Then import it in the app',
|
top: 'Then import it in the app',
|
||||||
@@ -1646,9 +1501,8 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
h(
|
h(
|
||||||
'ol',
|
'ol',
|
||||||
{ class: 'howto', 'data-m': 'howto' },
|
{ class: 'howto', 'data-m': 'howto' },
|
||||||
h('li', {}, `Open ${name}`),
|
// In the words of the app where the file goes: the computer's system, or the phone in hand.
|
||||||
h('li', {}, importPath(app).replace(/ → .*$/, ' → '), h('b', {}, importPath(app).replace(/^.* → /, ''))),
|
importSteps(app, os, cfg.filename, !!share && same()).map(([text, bold]) => h('li', {}, text, bold ? h('b', {}, bold) : null)),
|
||||||
h('li', {}, share ? 'Confirm the import and connect' : 'Pick the file and connect'),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1698,27 +1552,28 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
// Not on the device: the link goes there (as a code for a phone's camera), the rest happens there.
|
// Not on the device: the link goes there (as a code for a phone's camera), the rest happens there.
|
||||||
// It names the device, so the page there opens straight on its set-up.
|
// It names the device, so the page there opens straight on its set-up.
|
||||||
const linkThere = setupLink(location.origin + location.pathname, d.id);
|
const linkThere = setupLink(location.origin + location.pathname, d.id);
|
||||||
const awayCard = (easiest = false, fold = false) =>
|
const awayCard = ({ easiest = false, fold = false, or = false } = {}) => {
|
||||||
h(
|
const title = `${or ? 'Or open' : 'Open'} your link on the ${there}`;
|
||||||
|
return h(
|
||||||
'div',
|
'div',
|
||||||
{ class: `step${fold && open !== 'link' ? ' folded' : ''}` },
|
{ class: `step${fold && open !== 'link' ? ' folded' : ''}` },
|
||||||
fold
|
fold
|
||||||
? foldHead(
|
? foldHead(
|
||||||
'link',
|
'link',
|
||||||
h('span', { class: 'step-title grow' }, `Open your link on the ${there}`),
|
h('span', { class: 'step-title grow' }, title),
|
||||||
easiest ? h('span', { class: 'chip', 'data-glide': 'easiest' }, 'Easiest') : null,
|
easiest ? h('span', { class: 'chip', 'data-glide': 'easiest' }, 'Easiest') : null,
|
||||||
)
|
)
|
||||||
: h(
|
: h(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'step-head' },
|
{ class: 'step-head' },
|
||||||
h('span', { class: 'step-title grow' }, `Open your link on the ${there}`),
|
h('span', { class: 'step-title grow' }, title),
|
||||||
easiest ? h('span', { class: 'chip' }, 'Easiest') : null,
|
easiest ? h('span', { class: 'chip' }, 'Easiest') : null,
|
||||||
),
|
),
|
||||||
...(fold && open !== 'link'
|
...(fold && open !== 'link'
|
||||||
? []
|
? []
|
||||||
: unfolded(entered === 'link', [
|
: unfolded(entered === 'link', [
|
||||||
h('span', { class: 'muted s step-sub' }, 'The same page there does both steps for that device.'),
|
h('span', { class: 'muted s step-sub' }, 'The same page there does both steps for that device.'),
|
||||||
handheld
|
mobileTarget()
|
||||||
? h(
|
? h(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'code-row' },
|
{ class: 'code-row' },
|
||||||
@@ -1734,6 +1589,7 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
linkRow(linkThere),
|
linkRow(linkThere),
|
||||||
])),
|
])),
|
||||||
);
|
);
|
||||||
|
};
|
||||||
const awayFold = () =>
|
const awayFold = () =>
|
||||||
away
|
away
|
||||||
? (() => {
|
? (() => {
|
||||||
@@ -1772,7 +1628,7 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
h(
|
h(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'code-row' },
|
{ class: 'code-row' },
|
||||||
qrOf('app-qr', app === 'vpn' ? key : cfg.conf),
|
qrOf('app-qr', app === 'vpn' ? vpnQrText(key) : cfg.conf),
|
||||||
h(
|
h(
|
||||||
'span',
|
'span',
|
||||||
{ class: 'stack' },
|
{ class: 'stack' },
|
||||||
@@ -1781,12 +1637,6 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
qrFlip(),
|
qrFlip(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
h(
|
|
||||||
'span',
|
|
||||||
{ class: 'faint s' },
|
|
||||||
'Prefer the file or the key? ',
|
|
||||||
h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), connect(d, 'file', cfg)) }, 'Connection details'),
|
|
||||||
),
|
|
||||||
])),
|
])),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1802,7 +1652,7 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
h('span', { class: 'grow' }, 'Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.'),
|
h('span', { class: 'grow' }, 'Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (same) parts.push(getStep(), connectStep(), awayFold());
|
if (same()) parts.push(getStep(), connectStep(), awayFold());
|
||||||
else if (router)
|
else if (router)
|
||||||
parts.push(
|
parts.push(
|
||||||
step(
|
step(
|
||||||
@@ -1813,24 +1663,14 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
),
|
),
|
||||||
step('2', 'Import the configuration', filePane(cfg)),
|
step('2', 'Import the configuration', filePane(cfg)),
|
||||||
);
|
);
|
||||||
else if (handheld) parts.push(awayCard(true, true), appCodeCard());
|
else if (handheld) parts.push(awayCard({ easiest: true, fold: true }), appCodeCard());
|
||||||
|
// A computer set up from a phone: the same two steps for the app on the computer, then the link that does both there.
|
||||||
else
|
else
|
||||||
parts.push(
|
parts.push(
|
||||||
h('span', { class: 'muted s' }, `The app goes on the ${there}. Which one is it?`),
|
h('span', { class: 'muted s' }, `The app goes on the ${there}.`),
|
||||||
osPills(),
|
getStep(),
|
||||||
awayCard(true),
|
connectStep(),
|
||||||
step(
|
awayCard({ easiest: true, or: true }),
|
||||||
'',
|
|
||||||
[h('span', { class: 'grow', 'data-m': 'get' }, `${APP_NAME[app]} for ${PLATFORM_LABEL[os]}`)],
|
|
||||||
h('span', { class: 'faint s' }, 'Or download the installer here and move it to the PC'),
|
|
||||||
...storeBlock(),
|
|
||||||
),
|
|
||||||
h(
|
|
||||||
'span',
|
|
||||||
{ class: 'faint s center' },
|
|
||||||
`Already has ${APP_NAME[app]}? `,
|
|
||||||
h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), copy(key, 'Key copied', ev.currentTarget)) }, 'Copy the key'),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
restyle(body, () => body.replaceChildren(...parts.flat().filter((x): x is Node => x instanceof Node)));
|
restyle(body, () => body.replaceChildren(...parts.flat().filter((x): x is Node => x instanceof Node)));
|
||||||
entered = null;
|
entered = null;
|
||||||
@@ -1844,7 +1684,7 @@ async function setup(d: Device, cfgIn?: ClientConfig) {
|
|||||||
},
|
},
|
||||||
way.gaveUp,
|
way.gaveUp,
|
||||||
);
|
);
|
||||||
sheet(`Set up ${d.name}`, same ? 'Two steps, about a minute' : router ? 'The packages and the file for OpenWrt' : null, way.el, body);
|
sheet(`Set up ${d.name}`, same() ? 'Two steps, about a minute' : router ? 'The packages and the file for OpenWrt' : null, way.el, body);
|
||||||
sheetClosed = () => {
|
sheetClosed = () => {
|
||||||
stop();
|
stop();
|
||||||
if (state) main(state);
|
if (state) main(state);
|
||||||
@@ -1883,24 +1723,31 @@ function rename(d: Device) {
|
|||||||
setTimeout(() => name.select(), 50);
|
setTimeout(() => name.select(), 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** New keys for a device: the old configuration stops working, the new one is shown right away. */
|
/**
|
||||||
function rotateKeys(d: Device, st: State) {
|
* Set a device up from scratch (a new phone, the app reinstalled, settings the
|
||||||
|
* admin changed): new keys, so what it holds stops working; it shows "Not set
|
||||||
|
* up yet" until it connects with the new configuration, which the set-up sheet
|
||||||
|
* opens on.
|
||||||
|
*/
|
||||||
|
function reconnect(d: Device, st: State) {
|
||||||
|
const twin = httpsTwin();
|
||||||
|
if (twin) return secureSheet(twin);
|
||||||
ask({
|
ask({
|
||||||
icon: 'key',
|
icon: 'refresh',
|
||||||
tone: 'warn',
|
tone: 'warn',
|
||||||
title: `New keys for ${d.name}?`,
|
title: `Reconnect ${d.name}?`,
|
||||||
text:
|
text:
|
||||||
st.here === d.id
|
st.here === d.id
|
||||||
? 'This device is connected through its current settings: it disconnects a few seconds after you confirm. Import the new ones that open next.'
|
? 'It gets new keys. This device is connected through its current settings: it disconnects a few seconds after you confirm. Add the new ones that open next.'
|
||||||
: 'Its current settings stop working. Set it up again with the new ones that open next.',
|
: 'It gets new keys and its current settings stop working. Set it up again with the new ones that open next.',
|
||||||
action: 'New keys',
|
action: 'Reconnect',
|
||||||
actionClass: 'primary',
|
actionClass: 'primary',
|
||||||
run: async () => {
|
run: async () => {
|
||||||
try {
|
try {
|
||||||
const r = await call<{ config: ClientConfig; state: State }>(`devices/${d.id}`, { action: 'rotate' });
|
const r = await call<{ config: ClientConfig; state: State }>(`devices/${d.id}`, { action: 'reconnect' });
|
||||||
state = r.state;
|
state = r.state;
|
||||||
main(state);
|
main(state);
|
||||||
await setup({ ...d, handshake: 0 }, r.config);
|
await setup(state.person.devices.find((x) => x.id === d.id) ?? { ...d, handshake: 0 }, r.config);
|
||||||
} catch (er) {
|
} catch (er) {
|
||||||
toast((er as Error).message, true);
|
toast((er as Error).message, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,41 +366,6 @@ export function restyle(root: ParentNode, paint: () => void) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A row of choices whose highlight slides to the one picked: a copy of the row
|
|
||||||
* drawn in the picked look on top, clipped to the picked button, so the colour
|
|
||||||
* changes exactly where the highlight is (clip-path tabs). The real buttons keep
|
|
||||||
* `.on`; call the returned function after changing it.
|
|
||||||
*/
|
|
||||||
export function slider(row: HTMLElement): () => void {
|
|
||||||
const hl = row.cloneNode(true) as HTMLElement;
|
|
||||||
hl.classList.add('slide-hl');
|
|
||||||
hl.setAttribute('aria-hidden', 'true');
|
|
||||||
hl.inert = true;
|
|
||||||
hl.removeAttribute('role');
|
|
||||||
hl.querySelectorAll('[role]').forEach((b) => b.removeAttribute('role'));
|
|
||||||
row.classList.add('slides');
|
|
||||||
row.appendChild(hl);
|
|
||||||
let placed = false;
|
|
||||||
const move = () => {
|
|
||||||
const on = row.querySelector<HTMLElement>(':scope > .on');
|
|
||||||
if (!on || !row.isConnected) return;
|
|
||||||
const w = row.clientWidth,
|
|
||||||
h = row.clientHeight;
|
|
||||||
const l = on.offsetLeft,
|
|
||||||
t = on.offsetTop;
|
|
||||||
hl.classList.toggle('placed', placed);
|
|
||||||
hl.style.clipPath = `inset(${t}px ${w - l - on.offsetWidth}px ${h - t - on.offsetHeight}px ${l}px round 999px)`;
|
|
||||||
placed = true;
|
|
||||||
};
|
|
||||||
// Fonts and the sheet's own layout settle after the first call: place it again, without a glide.
|
|
||||||
new ResizeObserver(() => {
|
|
||||||
placed = false;
|
|
||||||
move();
|
|
||||||
}).observe(row);
|
|
||||||
return move;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A copy button in its "Copied" moment: what to put back, and when. */
|
/** A copy button in its "Copied" moment: what to put back, and when. */
|
||||||
const COPIED = new WeakMap<HTMLElement, { timer: number; icon: string | null; label: string | null }>();
|
const COPIED = new WeakMap<HTMLElement, { timer: number; icon: string | null; label: string | null }>();
|
||||||
|
|
||||||
|
|||||||
+7
-139
@@ -132,7 +132,6 @@ body {
|
|||||||
}
|
}
|
||||||
input,
|
input,
|
||||||
textarea,
|
textarea,
|
||||||
.keybox .mono,
|
|
||||||
.linkrow .mono,
|
.linkrow .mono,
|
||||||
.conf {
|
.conf {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
@@ -982,6 +981,11 @@ input[type='text']:focus {
|
|||||||
.menu-item.danger .ic {
|
.menu-item.danger .ic {
|
||||||
color: var(--bad);
|
color: var(--bad);
|
||||||
}
|
}
|
||||||
|
/* Undoable but not harmless (Reconnect: new keys), as the admin's Pause. */
|
||||||
|
.menu-item.warn,
|
||||||
|
.menu-item.warn .ic {
|
||||||
|
color: var(--warn);
|
||||||
|
}
|
||||||
.menu-sep {
|
.menu-sep {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background: var(--line);
|
background: var(--line);
|
||||||
@@ -1111,38 +1115,11 @@ input[type='text']:focus {
|
|||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.tabs {
|
|
||||||
display: flex;
|
|
||||||
gap: 4px;
|
|
||||||
padding: 4px;
|
|
||||||
background: var(--soft);
|
|
||||||
border-radius: 999px;
|
|
||||||
}
|
|
||||||
.tabs button {
|
|
||||||
all: unset;
|
|
||||||
cursor: pointer;
|
|
||||||
flex: 1 1 auto;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-align: center;
|
|
||||||
padding: 7px 10px;
|
|
||||||
border-radius: 999px;
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--muted);
|
|
||||||
}
|
|
||||||
.tabs button.on {
|
|
||||||
background: var(--soft-hover);
|
|
||||||
color: var(--text);
|
|
||||||
}
|
|
||||||
.pane {
|
.pane {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
.pane.center {
|
|
||||||
align-items: center;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
/* The code, night look (shared/qr): light dots on a black card with a fine outline.
|
/* The code, night look (shared/qr): light dots on a black card with a fine outline.
|
||||||
`.light`: the plain look, for scanners that read only dark on light. */
|
`.light`: the plain look, for scanners that read only dark on light. */
|
||||||
.qr {
|
.qr {
|
||||||
@@ -1164,34 +1141,6 @@ input[type='text']:focus {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.steps {
|
|
||||||
margin: 4px 0 0;
|
|
||||||
padding: 14px 16px 14px 34px;
|
|
||||||
border-radius: 14px;
|
|
||||||
border: 1px solid var(--line);
|
|
||||||
background: var(--card);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.keybox {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
height: 44px;
|
|
||||||
padding: 0 6px 0 12px;
|
|
||||||
border: 1px solid var(--input);
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
.keybox .mono {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
color: var(--muted);
|
|
||||||
}
|
|
||||||
.filecard {
|
.filecard {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -1290,15 +1239,6 @@ details > summary {
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
.waiting {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
padding: 12px 14px;
|
|
||||||
border-radius: 12px;
|
|
||||||
background: var(--soft);
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tooltip & toast */
|
/* tooltip & toast */
|
||||||
.tip {
|
.tip {
|
||||||
@@ -1351,33 +1291,6 @@ details > summary {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
}
|
}
|
||||||
.firststeps .steps {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Which app the code is for. */
|
|
||||||
.pane .seg {
|
|
||||||
display: inline-flex;
|
|
||||||
gap: 2px;
|
|
||||||
padding: 3px;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: var(--soft, rgba(127, 127, 127, 0.12));
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.pane .seg button {
|
|
||||||
border: 0;
|
|
||||||
background: none;
|
|
||||||
color: inherit;
|
|
||||||
font: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
padding: 5px 12px;
|
|
||||||
border-radius: 999px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.pane .seg button.on {
|
|
||||||
background: var(--card, #fff);
|
|
||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------- setting up a device: two numbered steps ---------- */
|
/* ---------- setting up a device: two numbered steps ---------- */
|
||||||
.setup {
|
.setup {
|
||||||
@@ -1385,11 +1298,6 @@ details > summary {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
.setup .center {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.step {
|
.step {
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
@@ -1763,8 +1671,6 @@ details > summary {
|
|||||||
.name-chip,
|
.name-chip,
|
||||||
.fold-link,
|
.fold-link,
|
||||||
.pill-link,
|
.pill-link,
|
||||||
.tabs > button,
|
|
||||||
.seg > button,
|
|
||||||
.menu-item {
|
.menu-item {
|
||||||
transition:
|
transition:
|
||||||
transform var(--dur-press) var(--ease-out),
|
transform var(--dur-press) var(--ease-out),
|
||||||
@@ -1779,9 +1685,7 @@ details > summary {
|
|||||||
.kind:active,
|
.kind:active,
|
||||||
.icon-btn:active,
|
.icon-btn:active,
|
||||||
.fold-link:active,
|
.fold-link:active,
|
||||||
.pill-link:active,
|
.pill-link:active {
|
||||||
.tabs > button:active,
|
|
||||||
.seg > button:active {
|
|
||||||
transform: scale(0.97);
|
transform: scale(0.97);
|
||||||
}
|
}
|
||||||
/* Wide surfaces give less: the same press reads larger on them. */
|
/* Wide surfaces give less: the same press reads larger on them. */
|
||||||
@@ -2018,7 +1922,6 @@ textarea {
|
|||||||
}
|
}
|
||||||
/* What a swap lifts out of the flow while it fades (motion.ts swap): under the new content, not over it. */
|
/* What a swap lifts out of the flow while it fades (motion.ts swap): under the new content, not over it. */
|
||||||
.sheet-inner,
|
.sheet-inner,
|
||||||
.tab-body,
|
|
||||||
.setup {
|
.setup {
|
||||||
position: relative;
|
position: relative;
|
||||||
isolation: isolate;
|
isolation: isolate;
|
||||||
@@ -2029,38 +1932,6 @@ textarea {
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tabs and segments: a copy of the row in the picked look, clipped to the pick, slides (motion.ts slider). */
|
|
||||||
.slides {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.slide-hl {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
margin: 0 !important;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
.slide-hl.placed {
|
|
||||||
transition: clip-path 300ms var(--ease-out);
|
|
||||||
}
|
|
||||||
.tabs.slide-hl {
|
|
||||||
background: var(--soft-hover);
|
|
||||||
}
|
|
||||||
.pane .seg.slide-hl {
|
|
||||||
background: var(--card);
|
|
||||||
}
|
|
||||||
.slide-hl > button,
|
|
||||||
.slide-hl > button.on {
|
|
||||||
background: none;
|
|
||||||
box-shadow: none;
|
|
||||||
color: var(--text);
|
|
||||||
transition: none;
|
|
||||||
}
|
|
||||||
.tabs.slides > button.on,
|
|
||||||
.pane .seg.slides > button.on {
|
|
||||||
background: none;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup repaints (motion.ts restyle): what flipped starts from its other look; a card that
|
/* Setup repaints (motion.ts restyle): what flipped starts from its other look; a card that
|
||||||
just folded shows its chevron with a little spring. */
|
just folded shows its chevron with a little spring. */
|
||||||
.fold.to-off .fold-chev {
|
.fold.to-off .fold-chev {
|
||||||
@@ -2313,7 +2184,6 @@ textarea {
|
|||||||
.sheet.open .sheet-panel {
|
.sheet.open .sheet-panel {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
.slide-hl.placed,
|
|
||||||
.confbox > summary > .ic:first-child {
|
.confbox > summary > .ic:first-child {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
@@ -2325,9 +2195,7 @@ textarea {
|
|||||||
.slot.add:active,
|
.slot.add:active,
|
||||||
.name-chip:active,
|
.name-chip:active,
|
||||||
.fold-link:active,
|
.fold-link:active,
|
||||||
.pill-link:active,
|
.pill-link:active {
|
||||||
.tabs > button:active,
|
|
||||||
.seg > button:active {
|
|
||||||
transform: none;
|
transform: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+60
-6
@@ -33,8 +33,13 @@ export function sameDevice(kind: Kind, platform: Platform): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The systems a kind may run: a computer's is the person's call, the rest are read from the browser. */
|
/**
|
||||||
export const osGroup = (kind: Kind): Platform[] => (kind === 'computer' || kind === 'other' ? ['windows', 'mac', 'linux'] : []);
|
* The systems a kind may run, when that is the person's call: a computer's
|
||||||
|
* desktop systems, any system for an "other" device (a TV box runs Android, a
|
||||||
|
* NAS Linux). A phone's or a tablet's is read from the browser.
|
||||||
|
*/
|
||||||
|
export const osGroup = (kind: Kind): Platform[] =>
|
||||||
|
kind === 'computer' ? ['windows', 'mac', 'linux'] : kind === 'other' ? ['ios', 'android', 'windows', 'mac', 'linux'] : [];
|
||||||
|
|
||||||
export interface AppChoice {
|
export interface AppChoice {
|
||||||
id: AppId;
|
id: AppId;
|
||||||
@@ -154,10 +159,59 @@ export const routerStore = (app: AppId): Store =>
|
|||||||
}
|
}
|
||||||
: { href: 'https://openwrt.org/packages/start', top: 'OpenWrt packages', main: 'amneziawg-tools + kmod', mark: 'openwrt' };
|
: { href: 'https://openwrt.org/packages/start', top: 'OpenWrt packages', main: 'amneziawg-tools + kmod', mark: 'openwrt' };
|
||||||
|
|
||||||
/** Inside the app: where the scanner and the importer are. */
|
/**
|
||||||
export const scanPath = (app: AppId): string =>
|
* Does AmneziaVPN here open a `vpn://` link? Only the Android app registers the
|
||||||
app === 'vpn' ? 'Add server → Scan QR' : app === 'awg' ? 'Add tunnel → Scan QR code' : 'Add tunnel → Create from QR code';
|
* scheme: on iOS, macOS and Windows the link opens nothing ("the address is
|
||||||
export const importPath = (app: AppId): string => (app === 'vpn' ? 'Add server → Insert key' : 'Add tunnel → Import from file');
|
* invalid"), or another app that claims vpn:// gets the key.
|
||||||
|
*/
|
||||||
|
export const opensKeyLinks = (platform: Platform): boolean => platform === 'android';
|
||||||
|
|
||||||
|
/** The key as a file for the share sheet: AmneziaVPN on iOS imports `.vpn` files (the key as text). */
|
||||||
|
export const keyFileName = (confName: string): string => `${confName.replace(/\.conf$/i, '')}.vpn`;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inside the app: where the scanner and the importer are, as each platform's
|
||||||
|
* app words it. The WireGuard apps are the same apps as AmneziaWG (it is
|
||||||
|
* their fork), menus included.
|
||||||
|
*/
|
||||||
|
const TUNNEL_MENU: Partial<Record<Platform, { file: string; qr?: string }>> = {
|
||||||
|
ios: { file: '+ → Create from file or archive', qr: '+ → Create from QR code' },
|
||||||
|
android: { file: '+ → Import from file or archive', qr: '+ → Scan from QR code' },
|
||||||
|
mac: { file: '+ → Import tunnel(s) from file' },
|
||||||
|
windows: { file: 'Add Tunnel → Import tunnel(s) from file' },
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Where the app scans a code; a phone of either kind gets both wordings. */
|
||||||
|
export function scanPath(app: AppId, platform: Platform = 'unknown'): string {
|
||||||
|
if (app === 'vpn') return 'Add server → Scan QR';
|
||||||
|
const qr = TUNNEL_MENU[platform]?.qr;
|
||||||
|
return qr ?? `${TUNNEL_MENU.ios!.qr} (Android: ${TUNNEL_MENU.android!.qr!.replace(/^.* → /, '')})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Where the app takes a file (AmneziaVPN: the key). */
|
||||||
|
export function importPath(app: AppId, platform: Platform = 'unknown'): string {
|
||||||
|
if (app === 'vpn') return 'Add server → Insert key';
|
||||||
|
return TUNNEL_MENU[platform]?.file ?? 'Add tunnel → Import from file';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The file into the app, step by step: [text, the part in bold]. Linux has no
|
||||||
|
* app, only the tools: the file goes up straight from where it was saved
|
||||||
|
* (its name is a valid interface name, see tunnel_name on the router).
|
||||||
|
*/
|
||||||
|
export function importSteps(app: AppId, platform: Platform, file: string, shared: boolean): [string, string][] {
|
||||||
|
if (platform === 'linux')
|
||||||
|
return [
|
||||||
|
['Open a terminal in the folder with the file', ''],
|
||||||
|
['Run ', `sudo ${app === 'wg' ? 'wg-quick' : 'awg-quick'} up ./${file}`],
|
||||||
|
];
|
||||||
|
const path = importPath(app, platform);
|
||||||
|
return [
|
||||||
|
[`Open ${APP_NAME[app]}`, ''],
|
||||||
|
[path.replace(/ → [^→]*$/, ' → '), path.replace(/^.* → /, '')],
|
||||||
|
[shared ? 'Confirm the import and connect' : 'Pick the file and connect', ''],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export const PLATFORM_LABEL: Record<Platform, string> = {
|
export const PLATFORM_LABEL: Record<Platform, string> = {
|
||||||
ios: 'iPhone / iPad',
|
ios: 'iPhone / iPad',
|
||||||
|
|||||||
@@ -135,6 +135,14 @@ export async function vpnKey(cfg: ClientConfig, description: string, compress =
|
|||||||
return `vpn://${base64Url(packed ?? json)}`;
|
return `vpn://${base64Url(packed ?? json)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key as AmneziaVPN's scanner reads it: the payload without "vpn://". Its
|
||||||
|
* QR import decodes the scanned text as base64 as it is (only the paste and
|
||||||
|
* file imports drop the prefix), and v, p and n are base64 too: with the
|
||||||
|
* prefix the payload shifts and the import fails.
|
||||||
|
*/
|
||||||
|
export const vpnQrText = (key: string): string => key.replace(/^vpn:\/\//, '');
|
||||||
|
|
||||||
/** The .conf with a browser-held private key substituted in. */
|
/** The .conf with a browser-held private key substituted in. */
|
||||||
export function withPrivateKey(cfg: ClientConfig, priv: string): ClientConfig {
|
export function withPrivateKey(cfg: ClientConfig, priv: string): ClientConfig {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -2,9 +2,15 @@ import { describe, expect, it } from 'vitest';
|
|||||||
import {
|
import {
|
||||||
appsFor,
|
appsFor,
|
||||||
deviceNoun,
|
deviceNoun,
|
||||||
|
importPath,
|
||||||
|
importSteps,
|
||||||
inWebview,
|
inWebview,
|
||||||
|
keyFileName,
|
||||||
|
opensKeyLinks,
|
||||||
|
osGroup,
|
||||||
platformOf,
|
platformOf,
|
||||||
sameDevice,
|
sameDevice,
|
||||||
|
scanPath,
|
||||||
setupFromHash,
|
setupFromHash,
|
||||||
setupLink,
|
setupLink,
|
||||||
storeFor,
|
storeFor,
|
||||||
@@ -54,6 +60,13 @@ describe('setup', () => {
|
|||||||
expect(sameDevice('phone', 'unknown')).toBe(false);
|
expect(sameDevice('phone', 'unknown')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('lets the person pick the system of a computer or an "other" device', () => {
|
||||||
|
expect(osGroup('computer')).toEqual(['windows', 'mac', 'linux']);
|
||||||
|
expect(osGroup('other')).toEqual(['ios', 'android', 'windows', 'mac', 'linux']);
|
||||||
|
expect(osGroup('phone')).toEqual([]);
|
||||||
|
expect(osGroup('router')).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
it('lists the apps a disguise allows, AmneziaVPN first', () => {
|
it('lists the apps a disguise allows, AmneziaVPN first', () => {
|
||||||
expect(appsFor('max').map((a) => a.id)).toEqual(['vpn', 'awg']);
|
expect(appsFor('max').map((a) => a.id)).toEqual(['vpn', 'awg']);
|
||||||
expect(appsFor('off').map((a) => a.id)).toEqual(['vpn', 'awg', 'wg']);
|
expect(appsFor('off').map((a) => a.id)).toEqual(['vpn', 'awg', 'wg']);
|
||||||
@@ -72,6 +85,31 @@ describe('setup', () => {
|
|||||||
expect(storeFor('vpn', 'unknown')).toBeNull();
|
expect(storeFor('vpn', 'unknown')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('opens vpn:// links only where AmneziaVPN registers them, and names the key file for the rest', () => {
|
||||||
|
expect(opensKeyLinks('android')).toBe(true);
|
||||||
|
expect(opensKeyLinks('ios')).toBe(false);
|
||||||
|
expect(opensKeyLinks('windows')).toBe(false);
|
||||||
|
expect(opensKeyLinks('mac')).toBe(false);
|
||||||
|
expect(keyFileName('outline-iphone.conf')).toBe('outline-iphone.vpn');
|
||||||
|
expect(keyFileName('home')).toBe('home.vpn');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('words the import as each platform’s app does', () => {
|
||||||
|
expect(importPath('awg', 'ios')).toBe('+ → Create from file or archive');
|
||||||
|
expect(importPath('awg', 'android')).toBe('+ → Import from file or archive');
|
||||||
|
expect(importPath('wg', 'windows')).toBe('Add Tunnel → Import tunnel(s) from file');
|
||||||
|
expect(importPath('vpn', 'ios')).toBe('Add server → Insert key');
|
||||||
|
expect(scanPath('awg', 'android')).toBe('+ → Scan from QR code');
|
||||||
|
expect(scanPath('awg')).toBe('+ → Create from QR code (Android: Scan from QR code)');
|
||||||
|
expect(importSteps('awg', 'mac', 'Outline-Home.conf', false)).toEqual([
|
||||||
|
['Open AmneziaWG', ''],
|
||||||
|
['+ → ', 'Import tunnel(s) from file'],
|
||||||
|
['Pick the file and connect', ''],
|
||||||
|
]);
|
||||||
|
expect(importSteps('awg', 'linux', 'Outline-Home.conf', false)[1]).toEqual(['Run ', 'sudo awg-quick up ./Outline-Home.conf']);
|
||||||
|
expect(importSteps('wg', 'linux', 'Outline-Home.conf', false)[1][1]).toContain('wg-quick up');
|
||||||
|
});
|
||||||
|
|
||||||
it('spots in-app browsers', () => {
|
it('spots in-app browsers', () => {
|
||||||
expect(inWebview(`${ANDROID} Telegram-Android/10.0`)).toBe(true);
|
expect(inWebview(`${ANDROID} Telegram-Android/10.0`)).toBe(true);
|
||||||
expect(inWebview(IPHONE)).toBe(false);
|
expect(inWebview(IPHONE)).toBe(false);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { inflateSync } from 'node:zlib';
|
import { inflateSync } from 'node:zlib';
|
||||||
import { byDeviceState, bytes, daysLeft, initials, quotaText, slugify } from '../src/shared/format';
|
import { byDeviceState, bytes, daysLeft, initials, quotaText, slugify } from '../src/shared/format';
|
||||||
import { amneziaJson, base64Url, fromBase64Url, vpnKey, withPrivateKey } from '../src/shared/vpnkey';
|
import { amneziaJson, base64Url, fromBase64Url, vpnKey, vpnQrText, withPrivateKey } from '../src/shared/vpnkey';
|
||||||
import type { ClientConfig } from '../src/shared/types';
|
import type { ClientConfig } from '../src/shared/types';
|
||||||
|
|
||||||
const cfg: ClientConfig = {
|
const cfg: ClientConfig = {
|
||||||
@@ -80,6 +80,14 @@ describe('vpn:// keys', () => {
|
|||||||
expect(JSON.parse(json).hostName).toBe('vpn.example.com');
|
expect(JSON.parse(json).hostName).toBe('vpn.example.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('puts the bare payload in the QR code: AmneziaVPN’s scanner does not drop vpn://', async () => {
|
||||||
|
const key = await vpnKey(cfg, 'x');
|
||||||
|
const qr = vpnQrText(key);
|
||||||
|
expect(qr).toBe(key.slice(6));
|
||||||
|
expect(qr).toMatch(/^[A-Za-z0-9_-]+$/);
|
||||||
|
expect(vpnQrText(qr)).toBe(qr);
|
||||||
|
});
|
||||||
|
|
||||||
it('substitutes a browser-held private key', () => {
|
it('substitutes a browser-held private key', () => {
|
||||||
const c = withPrivateKey(
|
const c = withPrivateKey(
|
||||||
{ ...cfg, has_private_key: false, conf: cfg.conf.replace('AAA=', '<private key stays on your device>') },
|
{ ...cfg, has_private_key: false, conf: cfg.conf.replace('AAA=', '<private key stays on your device>') },
|
||||||
|
|||||||
Reference in new issue
Block a user