From 78bbfa42fa1159bce12c2c1d29eeb0bb9a8a2f75 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 25 Aug 2023 21:04:59 +0200 Subject: Remove mailinglist and proof-of-work functionality --- src/http/pow.go | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 src/http/pow.go (limited to 'src/http/pow.go') diff --git a/src/http/pow.go b/src/http/pow.go deleted file mode 100644 index 1bd5cb5..0000000 --- a/src/http/pow.go +++ /dev/null @@ -1,53 +0,0 @@ -package http - -import ( - "encoding/hex" - "errors" - "fmt" - "net/http" - - "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil" -) - -func (a *api) newPowChallengeHandler() http.Handler { - return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { - - challenge := a.params.PowManager.NewChallenge() - - apiutil.JSONResult(rw, r, struct { - Seed string `json:"seed"` - Target uint32 `json:"target"` - }{ - Seed: hex.EncodeToString(challenge.Seed), - Target: challenge.Target, - }) - }) -} - -func (a *api) requirePowMiddleware(h http.Handler) http.Handler { - return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { - - seedHex := r.FormValue("powSeed") - seed, err := hex.DecodeString(seedHex) - if err != nil || len(seed) == 0 { - apiutil.BadRequest(rw, r, errors.New("invalid powSeed")) - return - } - - solutionHex := r.FormValue("powSolution") - solution, err := hex.DecodeString(solutionHex) - if err != nil || len(seed) == 0 { - apiutil.BadRequest(rw, r, errors.New("invalid powSolution")) - return - } - - err = a.params.PowManager.CheckSolution(seed, solution) - - if err != nil { - apiutil.BadRequest(rw, r, fmt.Errorf("checking proof-of-work solution: %w", err)) - return - } - - h.ServeHTTP(rw, r) - }) -} -- cgit v1.2.3