mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-03 01:38:14 -04:00

Since the challenge is done off of the main thread, there is no simple way to report the progress done towards completing it. This change adds a callback parameter, `progressCallback`, which is called with the most recently attempted nonce every ~1024 iterations (should this be configurable?). For the single-threaded "slow" algorithm, this is exactly every 1024 iterations. For the multi-threaded "fast" algorithm, threads take turns reporting in a round-robin as then notice they have passed a multiple of 1024. This complexity is to avoid individual threads falling behind their siblings due to the overhead of messaging the main thread. To minimize this overhead as much as possible, a regular number is sent instead of an object. With the new information provided by the callback, a hash rate display is added to the challenge page. This display is updated at most once per second and set with tabular numbers to avoid the constantly changing value being too visually distracting. * web: show a progress bar based on completion probability To provide more feedback to the user, the spinner is replaced with a progress bar of the probability the challenge is complete. Since it looks a little weird that a progress bar would fill up a quarter of the way and then jump to the end (even though the probability would make that happen 1 in 4 times), the bar is mapped with a quadratic easing function to move faster at the beginning and then slow down as the probability of redirection increases. If the probability exceeds 90%, a message appears letting the user know things are taking longer than expected and to continue being patient. Signed-off-by: Xe Iaso <me@xeiaso.net>
124 lines
4.2 KiB
Plaintext
124 lines
4.2 KiB
Plaintext
package web
|
|
|
|
import (
|
|
"github.com/TecharoHQ/anubis"
|
|
"github.com/TecharoHQ/anubis/xess"
|
|
)
|
|
|
|
templ base(title string, body templ.Component) {
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>{ title }</title>
|
|
<link rel="stylesheet" href={ xess.URL }/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<style>
|
|
body,
|
|
html {
|
|
height: 100%;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
|
|
.centered-div {
|
|
text-align: center;
|
|
}
|
|
|
|
#status {
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
#progress {
|
|
display: none;
|
|
width: min(20rem, 90%);
|
|
height: 2rem;
|
|
border-radius: 1rem;
|
|
overflow: hidden;
|
|
margin: 1rem 0 2rem;
|
|
outline-color: #b16286;
|
|
outline-offset: 2px;
|
|
outline-style: solid;
|
|
outline-width: 4px;
|
|
}
|
|
|
|
.bar-inner {
|
|
background-color: #b16286;
|
|
height: 100%;
|
|
width: 0;
|
|
transition: width 0.25s ease-in;
|
|
}
|
|
</style>
|
|
@templ.JSONScript("anubis_version", anubis.Version)
|
|
</head>
|
|
<body id="top">
|
|
<main>
|
|
<center>
|
|
<h1 id="title" class=".centered-div">{ title }</h1>
|
|
</center>
|
|
@body
|
|
<footer>
|
|
<center>
|
|
<p>
|
|
Protected by <a href="https://github.com/TecharoHQ/anubis">Anubis</a> from <a
|
|
href="https://techaro.lol"
|
|
>Techaro</a>. Made with ❤️ in 🇨🇦.
|
|
</p>
|
|
</center>
|
|
</footer>
|
|
</main>
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
templ index() {
|
|
<div class="centered-div">
|
|
<img
|
|
id="image"
|
|
style="width:100%;max-width:256px;"
|
|
src={ "/.within.website/x/cmd/anubis/static/img/pensive.webp?cacheBuster=" +
|
|
anubis.Version }
|
|
/>
|
|
<img
|
|
style="display:none;"
|
|
style="width:100%;max-width:256px;"
|
|
src={ "/.within.website/x/cmd/anubis/static/img/happy.webp?cacheBuster=" +
|
|
anubis.Version }
|
|
/>
|
|
<p id="status">Loading...</p>
|
|
<script async type="module" src={ "/.within.website/x/cmd/anubis/static/js/main.mjs?cacheBuster=" + anubis.Version }></script>
|
|
<div id="progress" role="progressbar" aria-labelledby="status">
|
|
<div class="bar-inner"></div>
|
|
</div>
|
|
<details>
|
|
<summary>Why am I seeing this?</summary>
|
|
<p>You are seeing this because the administrator of this website has set up <a href="https://github.com/TecharoHQ/anubis">Anubis</a> to protect the server against the scourge of <a href="https://thelibre.news/foss-infrastructure-is-under-attack-by-ai-companies/">AI companies aggressively scraping websites</a>. This can and does cause downtime for the websites, which makes their resources inaccessible for everyone.</p>
|
|
<p>Anubis is a compromise. Anubis uses a <a href="https://anubis.techaro.lol/docs/design/why-proof-of-work">Proof-of-Work</a> scheme in the vein of <a href="https://en.wikipedia.org/wiki/Hashcash">Hashcash</a>, a proposed proof-of-work scheme for reducing email spam. The idea is that at individual scales the additional load is ignorable, but at mass scraper levels it adds up and makes scraping much more expensive.</p>
|
|
<p>Ultimately, this is a hack whose real purpose is to give a "good enough" placeholder solution so that more time can be spent on fingerprinting and identifying headless browsers (EG: via how they do font rendering) so that the challenge proof of work page doesn't need to be presented to users that are much more likely to be legitimate.</p>
|
|
<p>Please note that Anubis requires the use of modern JavaScript features that plugins like <a href="https://jshelter.org/">JShelter</a> will disable. Please disable JShelter or other such plugins for this domain.</p>
|
|
</details>
|
|
<noscript>
|
|
<p>
|
|
Sadly, you must enable JavaScript to get past this challenge. This is required because AI companies have changed
|
|
the social contract around how website hosting works. A no-JS solution is a work-in-progress.
|
|
</p>
|
|
</noscript>
|
|
<div id="testarea"></div>
|
|
</div>
|
|
}
|
|
|
|
templ errorPage(message string) {
|
|
<div class="centered-div">
|
|
<img
|
|
id="image"
|
|
style="width:100%;max-width:256px;"
|
|
src={ "/.within.website/x/cmd/anubis/static/img/sad.webp?cacheBuster=" + anubis.Version }
|
|
/>
|
|
<p>{ message }.</p>
|
|
<button onClick="window.location.reload();">Try again</button>
|
|
<p><a href="/">Go home</a></p>
|
|
</div>
|
|
}
|