Skip to content

Commit

Permalink
cmd/anubis: don't include Accept-Encoding in challenge
Browse files Browse the repository at this point in the history
Browsers are known to change the Accept-Encoding header based on
what media type is being accepted. I kinda hate this too, but such
is life.

Signed-off-by: Xe Iaso <[email protected]>
  • Loading branch information
Xe committed Jan 24, 2025
1 parent 1cab723 commit 2eae2a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cmd/anubis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ func (s *Server) challengeFor(r *http.Request) string {
fp := sha256.Sum256(s.priv.Seed())

data := fmt.Sprintf(
"Accept-Encoding=%s,Accept-Language=%s,X-Real-IP=%s,User-Agent=%s,WeekTime=%s,Fingerprint=%x",
r.Header.Get("Accept-Encoding"),
"Accept-Language=%s,X-Real-IP=%s,User-Agent=%s,WeekTime=%s,Fingerprint=%x",
r.Header.Get("Accept-Language"),
r.Header.Get("X-Real-Ip"),
r.UserAgent(),
Expand Down
7 changes: 6 additions & 1 deletion cmd/httpdebug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package main

import (
"flag"
"fmt"
"io"
"log"
"log/slog"
"net/http"
"os"

"within.website/x/internal"
)
Expand All @@ -19,7 +22,9 @@ func main() {
slog.Info("listening", "url", "http://localhost"+*bind)
log.Fatal(http.ListenAndServe(*bind, http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
r.Write(w)
fmt.Println("---")
r.Write(io.MultiWriter(w, os.Stdout))
fmt.Println("---")
},
)))
}

0 comments on commit 2eae2a4

Please sign in to comment.