add raw handler support
This commit is contained in:
@@ -34,7 +34,7 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler {
|
||||
SetRequestModifications(
|
||||
//rx.SpoofJA3fingerprint(ja3, "Googlebot"),
|
||||
rx.AddCacheBusterQuery(),
|
||||
//rx.MasqueradeAsGoogleBot(),
|
||||
rx.MasqueradeAsGoogleBot(),
|
||||
rx.ForwardRequestHeaders(),
|
||||
rx.DeleteOutgoingCookies(),
|
||||
rx.SpoofReferrerFromRedditPost(),
|
||||
|
||||
@@ -1,9 +1,51 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"ladder/proxychain"
|
||||
rx "ladder/proxychain/requestmodifiers"
|
||||
tx "ladder/proxychain/responsemodifiers"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func Raw(c *fiber.Ctx) error {
|
||||
return nil
|
||||
func NewRawProxySiteHandler(opts *ProxyOptions) fiber.Handler {
|
||||
|
||||
return func(c *fiber.Ctx) error {
|
||||
proxychain := proxychain.
|
||||
NewProxyChain().
|
||||
SetFiberCtx(c).
|
||||
SetRequestModifications(
|
||||
rx.AddCacheBusterQuery(),
|
||||
rx.MasqueradeAsGoogleBot(),
|
||||
rx.ForwardRequestHeaders(),
|
||||
rx.HideOrigin(),
|
||||
rx.DeleteOutgoingCookies(),
|
||||
rx.SpoofReferrerFromRedditPost(),
|
||||
)
|
||||
|
||||
// no options passed in, return early
|
||||
if opts == nil {
|
||||
// return as plaintext, overriding any rules
|
||||
proxychain.AddOnceResponseModifications(
|
||||
tx.SetResponseHeader("content-type", "text/plain; charset=UTF-8"),
|
||||
)
|
||||
|
||||
return proxychain.Execute()
|
||||
}
|
||||
|
||||
// load ruleset
|
||||
rule, exists := opts.Ruleset.GetRule(proxychain.Request.URL)
|
||||
if exists {
|
||||
proxychain.AddOnceRequestModifications(rule.RequestModifications...)
|
||||
proxychain.AddOnceResponseModifications(rule.ResponseModifications...)
|
||||
}
|
||||
|
||||
// return as plaintext, overriding any rules
|
||||
proxychain.AddOnceResponseModifications(
|
||||
tx.SetResponseHeader("content-type", "text/plain; charset=UTF-8"),
|
||||
)
|
||||
|
||||
return proxychain.Execute()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func TestRaw(t *testing.T) {
|
||||
app := fiber.New()
|
||||
app.Get("/raw/*", Raw)
|
||||
app.Get("/raw/*", NewRawProxySiteHandler(nil))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user