add /api/outline path

This commit is contained in:
Kevin Pham
2023-11-29 11:38:28 -06:00
parent 909d29230f
commit 53ce3ff297
4 changed files with 66 additions and 14 deletions

44
handlers/api_outline.go Normal file
View File

@@ -0,0 +1,44 @@
package handlers
import (
"ladder/proxychain"
rx "ladder/proxychain/requestmodifers"
tx "ladder/proxychain/responsemodifers"
"github.com/gofiber/fiber/v2"
)
func NewAPIOutlineHandler(path string, opts *ProxyOptions) fiber.Handler {
// TODO: implement ruleset logic
/*
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().
WithAPIPath(path).
SetDebugLogging(opts.Verbose).
SetRequestModifications(
rx.MasqueradeAsGoogleBot(),
rx.ForwardRequestHeaders(),
rx.SpoofReferrerFromGoogleSearch(),
).
AddResponseModifications(
tx.DeleteIncomingCookies(),
tx.RewriteHTMLResourceURLs(),
tx.APIOutline(),
).
SetFiberCtx(c).
Execute()
return proxychain
}
}