Skip to content

Commit

Permalink
adding docs and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
fionera committed Nov 14, 2023
1 parent e84b2bb commit 5851760
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ browsers that really know how to dance!
- Simple Captcha (Including Sound)
- [hCaptcha](https://www.hcaptcha.com/)
- [reCatpcha](https://developers.google.com/recaptcha?hl=de)
- [Turnstile](https://developers.cloudflare.com/turnstile/)
- [Turnstile](https://developers.cloudflare.com/turnstile/)

## Example setup with HAProxy
To start berghain locally you can follow these easy steps:

1. Run `npm run build` inside `web/`
2. Run `haproxy -f examples/haproxy/haproxy.cfg`
3. Run `go run ./cmd/spop/. -config cmd/spop/config.yaml`
8 changes: 6 additions & 2 deletions berghain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/hmac"
"crypto/sha256"
"hash"
"log"
"sync"
"time"
)
Expand Down Expand Up @@ -43,13 +44,16 @@ func (b *Berghain) releaseHMAC(h hash.Hash) {
}

func (b *Berghain) LevelConfig(level uint8) *LevelConfig {

if level == 0 {
panic("level cannot be zero")
log.Println("level cannot be zero. correcting to 1")
}

if level > uint8(len(b.Levels)) {
panic("level overflows")
log.Printf("level too high. correcting to %d", len(b.Levels))
}

level = min(uint8(len(b.Levels)), max(1, level))

return b.Levels[level-1]
}
4 changes: 1 addition & 3 deletions cmd/spop/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ secret: JMal0XJRROOMsMdPqggG2tR56CTkpgN3r47GgUN/WSQ=
default:
- duration: 24h
type: none
- duration: 1h
type: pow
- duration: 60s
- duration: 30m
type: pow

frontend:
Expand Down
1 change: 0 additions & 1 deletion examples/haproxy/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ frontend test

http-request set-var(req.berghain.level) int(1) if { sc1_http_req_rate gt 5 }
http-request set-var(req.berghain.level) int(2) if { sc1_http_req_rate gt 10 }
http-request set-var(req.berghain.level) int(3) if { sc1_http_req_rate gt 15 }

acl berghain_active var(req.berghain.level) -m found

Expand Down
4 changes: 3 additions & 1 deletion web/src/challange/challanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export async function challengeFingerprinting() {
* @return {Promise<void>}
*/
export async function challengeNone() {
return;
return new Promise((resolve) => {
setTimeout(resolve, 3000);
});
}

/**
Expand Down
4 changes: 4 additions & 0 deletions web/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ import * as loader from "./challange/loader.js";
loader.start();
const result = await doChallenge()
loader.stop(!!result);

if (!result) {
setTimeout(() => {window.location.reload();}, 1000);
}
});
})();

0 comments on commit 5851760

Please sign in to comment.