package handlers import ( rx "github.com/everywall/ladder/proxychain/requestmodifiers" tx "github.com/everywall/ladder/proxychain/responsemodifiers" "github.com/everywall/ladder/proxychain" ruleset_v2 "github.com/everywall/ladder/proxychain/ruleset" "github.com/gofiber/fiber/v2" ) type ProxyOptions struct { Ruleset ruleset_v2.IRuleset Verbose bool } func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler { /* var rs ruleset.RuleSet if opts.RulesetPath != "" { r, err := ruleset.NewRuleset(opts.RulesetPath) if err != nil { panic(err) } rs = r } */ return func(c *fiber.Ctx) error { proxychain := proxychain. NewProxyChain(). SetFiberCtx(c). SetDebugLogging(opts.Verbose). SetRequestModifications( //rx.SpoofJA3fingerprint(ja3, "Googlebot"), rx.AddCacheBusterQuery(), rx.MasqueradeAsGoogleBot(), rx.ForwardRequestHeaders(), rx.DeleteOutgoingCookies(), rx.SpoofReferrerFromRedditPost(), //rx.SpoofReferrerFromLinkedInPost(), //rx.RequestWaybackMachine(), //rx.RequestArchiveIs(), ). AddResponseModifications( tx.ForwardResponseHeaders(), //tx.BlockThirdPartyScripts(), tx.DeleteIncomingCookies(), tx.DeleteLocalStorageData(), tx.DeleteSessionStorageData(), tx.BypassCORS(), tx.BypassContentSecurityPolicy(), tx.RewriteHTMLResourceURLs(), tx.PatchDynamicResourceURLs(), tx.PatchTrackerScripts(), tx.BlockElementRemoval(".article-content"), // techcrunch //tx.BlockElementRemoval(".available-content"), // substack // tx.SetContentSecurityPolicy("default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"), ) // no options passed in, return early if opts == nil { return proxychain.Execute() } // load ruleset rule, exists := opts.Ruleset.GetRule(proxychain.Request.URL) if exists { proxychain.AddOnceRequestModifications(rule.RequestModifications...) proxychain.AddOnceResponseModifications(rule.ResponseModifications...) } return proxychain.Execute() } }