-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/anubis: disable video test for now
Signed-off-by: Xe Iaso <[email protected]>
- Loading branch information
Showing
5 changed files
with
12 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(()=>{function w(e,i=5){return new Promise((n,t)=>{let o=URL.createObjectURL(new Blob(["(",y(),")()"],{type:"application/javascript"})),s=new Worker(o);s.onmessage=r=>{s.terminate(),n(r.data)},s.onerror=r=>{s.terminate(),t()},s.postMessage({data:e,difficulty:i}),URL.revokeObjectURL(o)})}function y(){return function(){let e=i=>{let n=new TextEncoder().encode(i);return crypto.subtle.digest("SHA-256",n.buffer).then(t=>Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join(""))};addEventListener("message",async i=>{let n=i.data.data,t=i.data.difficulty,o,s=0;do o=await e(n+s++);while(o.substring(0,t)!==Array(t+1).join("0"));s-=1,postMessage({hash:o,data:n,difficulty:t,nonce:s})})}.toString()}var g='<video id="videotest" width="0" height="0" src="/.within.website/x/cmd/anubis/static/testdata/black.mp4"></video>',h=async e=>(e.innerHTML=g,await new Promise(i=>{let n=document.getElementById("videotest");n.oncanplay=()=>{e.style.display="none",i(!0)},n.onerror=t=>{e.style.display="none",i(!1)}}));var f=(e="",i={})=>{let n=new URL(e,window.location.href);return Object.entries(i).forEach(t=>{let[o,s]=t;n.searchParams.set(o,s)}),n.toString()},d=e=>`/.within.website/x/cmd/anubis/static/img/${e}.webp`;(async()=>{let e=document.getElementById("status"),i=document.getElementById("image"),n=document.getElementById("title"),t=document.getElementById("spinner"),o=document.getElementById("testarea");if(!await h(o)){n.innerHTML="Oh no!",e.innerHTML="Checks failed. Please check your browser's settings and try again.",i.src=d("sad"),t.innerHTML="",t.style.display="none";return}e.innerHTML="Calculating...";let{challenge:r,difficulty:c}=await fetch("/.within.website/x/cmd/anubis/api/make-challenge",{method:"POST"}).then(a=>{if(!a.ok)throw new Error("Failed to fetch config");return a.json()}).catch(a=>{throw n.innerHTML="Oh no!",e.innerHTML=`Failed to fetch config: ${a.message}`,i.src=d("sad"),t.innerHTML="",t.style.display="none",a});e.innerHTML=`Calculating...<br/>Difficulty: ${c}`;let l=Date.now(),{hash:p,nonce:m}=await w(r,c),u=Date.now();n.innerHTML="Success!",e.innerHTML=`Done! Took ${u-l}ms, ${m} iterations`,i.src=d("happy"),t.innerHTML="",t.style.display="none",setTimeout(()=>{let a=window.location.href;window.location.href=f("/.within.website/x/cmd/anubis/api/pass-challenge",{response:p,nonce:m,redir:a,elapsedTime:u-l,difficulty:c})},2e3)})();})(); | ||
(()=>{function l(n,s=5){return new Promise((i,t)=>{let o=URL.createObjectURL(new Blob(["(",w(),")()"],{type:"application/javascript"})),e=new Worker(o);e.onmessage=r=>{e.terminate(),i(r.data)},e.onerror=r=>{e.terminate(),t()},e.postMessage({data:n,difficulty:s}),URL.revokeObjectURL(o)})}function w(){return function(){let n=s=>{let i=new TextEncoder().encode(s);return crypto.subtle.digest("SHA-256",i.buffer).then(t=>Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join(""))};addEventListener("message",async s=>{let i=s.data.data,t=s.data.difficulty,o,e=0;do o=await n(i+e++);while(o.substring(0,t)!==Array(t+1).join("0"));e-=1,postMessage({hash:o,data:i,difficulty:t,nonce:e})})}.toString()}var h=(n="",s={})=>{let i=new URL(n,window.location.href);return Object.entries(s).forEach(t=>{let[o,e]=t;i.searchParams.set(o,e)}),i.toString()},m=n=>`/.within.website/x/cmd/anubis/static/img/${n}.webp`;(async()=>{let n=document.getElementById("status"),s=document.getElementById("image"),i=document.getElementById("title"),t=document.getElementById("spinner");n.innerHTML="Calculating...";let{challenge:o,difficulty:e}=await fetch("/.within.website/x/cmd/anubis/api/make-challenge",{method:"POST"}).then(a=>{if(!a.ok)throw new Error("Failed to fetch config");return a.json()}).catch(a=>{throw i.innerHTML="Oh no!",n.innerHTML=`Failed to fetch config: ${a.message}`,s.src=m("sad"),t.innerHTML="",t.style.display="none",a});n.innerHTML=`Calculating...<br/>Difficulty: ${e}`;let r=Date.now(),{hash:u,nonce:c}=await l(o,e),d=Date.now();i.innerHTML="Success!",n.innerHTML=`Done! Took ${d-r}ms, ${c} iterations`,s.src=m("happy"),t.innerHTML="",t.style.display="none",setTimeout(()=>{let a=window.location.href;window.location.href=h("/.within.website/x/cmd/anubis/api/pass-challenge",{response:u,nonce:c,redir:a,elapsedTime:d-r,difficulty:e})},2e3)})();})(); |
Binary file not shown.
Binary file not shown.
Binary file not shown.