Skip to content

Commit

Permalink
Support rlbypass for handle resolution (#297)
Browse files Browse the repository at this point in the history
Use the `rlbypass` header for handle resolution when resolving against
`.bsky.social` handles.
  • Loading branch information
ericvolp12 authored Sep 6, 2023
2 parents 7ede4c3 + b10d28e commit 2fcb59a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/bigsky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"

Expand All @@ -24,6 +25,7 @@ import (
"github.com/bluesky-social/indigo/xrpc"
_ "go.uber.org/automaxprocs"

"net/http"
_ "net/http/pprof"

_ "github.com/joho/godotenv/autoload"
Expand Down Expand Up @@ -295,7 +297,17 @@ func Bigsky(cctx *cli.Context) error {
blobstore = &blobs.DiskBlobStore{bsdir}
}

var hr api.HandleResolver = &api.ProdHandleResolver{}
prodHR := api.ProdHandleResolver{}
if rlskip != "" {
prodHR.ReqMod = func(req *http.Request, host string) error {
if strings.HasSuffix(host, ".bsky.social") {
req.Header.Set("x-ratelimit-bypass", rlskip)
}
return nil
}
}

var hr api.HandleResolver = &prodHR
if cctx.StringSlice("handle-resolver-hosts") != nil {
hr = &api.TestHandleResolver{
TrialHosts: cctx.StringSlice("handle-resolver-hosts"),
Expand Down

0 comments on commit 2fcb59a

Please sign in to comment.