Merge pull request #61 from everywall/proxy_v2/cleanup-main

cleanup main
This commit is contained in:
Kevin Pham
2023-12-05 14:03:40 -06:00
committed by GitHub
18 changed files with 299 additions and 257 deletions

View File

@@ -1,12 +1,11 @@
package main package main
import ( import (
"embed" _ "embed"
"fmt" "fmt"
"html/template" "html/template"
"log" "log"
"os" "os"
"strings"
"ladder/handlers" "ladder/handlers"
"ladder/internal/cli" "ladder/internal/cli"
@@ -14,20 +13,9 @@ import (
"github.com/akamensky/argparse" "github.com/akamensky/argparse"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/basicauth"
"github.com/gofiber/fiber/v2/middleware/favicon"
"github.com/gofiber/template/html/v2" "github.com/gofiber/template/html/v2"
) )
//go:embed favicon.ico
var faviconData string
//go:embed styles.css
var cssData embed.FS
//go:embed script.js
var scriptData embed.FS
//go:embed VERSION //go:embed VERSION
var version string var version string
@@ -151,23 +139,8 @@ func main() {
}, },
) )
// TODO: move to cmd/auth.go app.Use(handlers.Auth())
userpass := os.Getenv("USERPASS") app.Use(handlers.Favicon())
if userpass != "" {
userpass := strings.Split(userpass, ":")
app.Use(basicauth.New(basicauth.Config{
Users: map[string]string{
userpass[0]: userpass[1],
},
}))
}
// TODO: move to handlers/favicon.go
app.Use(favicon.New(favicon.Config{
Data: []byte(faviconData),
URL: "/favicon.ico",
}))
if os.Getenv("NOLOGS") != "true" { if os.Getenv("NOLOGS") != "true" {
app.Use(func(c *fiber.Ctx) error { app.Use(func(c *fiber.Ctx) error {
@@ -179,29 +152,8 @@ func main() {
app.Get("/", handlers.Form) app.Get("/", handlers.Form)
app.Get("/styles.css", func(c *fiber.Ctx) error { app.Get("styles.css", handlers.Styles)
cssData, err := cssData.ReadFile("styles.css") app.Get("script.js", handlers.Script)
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
}
c.Set("Content-Type", "text/css")
return c.Send(cssData)
})
// TODO: move to handlers/script.go
app.Get("/script.js", func(c *fiber.Ctx) error {
scriptData, err := scriptData.ReadFile("script.js")
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
}
c.Set("Content-Type", "text/javascript")
return c.Send(scriptData)
})
app.Get("ruleset", handlers.Ruleset) app.Get("ruleset", handlers.Ruleset)
app.Get("raw/*", handlers.Raw) app.Get("raw/*", handlers.Raw)

25
handlers/auth.go Normal file
View File

@@ -0,0 +1,25 @@
package handlers
import (
"os"
"strings"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/basicauth"
)
func Auth() fiber.Handler {
userpass := os.Getenv("USERPASS")
if userpass != "" {
userpass := strings.Split(userpass, ":")
return basicauth.New(basicauth.Config{
Users: map[string]string{
userpass[0]: userpass[1],
},
})
}
return func(c *fiber.Ctx) error {
return c.Next()
}
}

18
handlers/favicon.go Normal file
View File

@@ -0,0 +1,18 @@
package handlers
import (
_ "embed"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/favicon"
)
//go:embed favicon.ico
var faviconData string
func Favicon() fiber.Handler {
return favicon.New(favicon.Config{
Data: []byte(faviconData),
URL: "/favicon.ico",
})
}

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -33,13 +33,13 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler {
SetRequestModifications( SetRequestModifications(
// rx.SpoofJA3fingerprint(ja3, "Googlebot"), // rx.SpoofJA3fingerprint(ja3, "Googlebot"),
// rx.MasqueradeAsFacebookBot(), // rx.MasqueradeAsFacebookBot(),
//rx.MasqueradeAsGoogleBot(), // rx.MasqueradeAsGoogleBot(),
rx.DeleteOutgoingCookies(), rx.DeleteOutgoingCookies(),
rx.ForwardRequestHeaders(), rx.ForwardRequestHeaders(),
//rx.SpoofReferrerFromGoogleSearch(), // rx.SpoofReferrerFromGoogleSearch(),
rx.SpoofReferrerFromLinkedInPost(), rx.SpoofReferrerFromLinkedInPost(),
//rx.RequestWaybackMachine(), // rx.RequestWaybackMachine(),
//rx.RequestArchiveIs(), // rx.RequestArchiveIs(),
). ).
AddResponseModifications( AddResponseModifications(
tx.ForwardResponseHeaders(), tx.ForwardResponseHeaders(),

23
handlers/script.go Normal file
View File

@@ -0,0 +1,23 @@
package handlers
import (
"embed"
"github.com/gofiber/fiber/v2"
)
//go:embed script.js
var scriptData embed.FS
func Script(c *fiber.Ctx) error {
scriptData, err := scriptData.ReadFile("script.js")
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
}
c.Set("Content-Type", "text/javascript")
return c.Send(scriptData)
}

23
handlers/styles.go Normal file
View File

@@ -0,0 +1,23 @@
package handlers
import (
"embed"
"github.com/gofiber/fiber/v2"
)
//go:embed styles.css
var cssData embed.FS
func Styles(c *fiber.Ctx) error {
cssData, err := cssData.ReadFile("styles.css")
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
}
c.Set("Content-Type", "text/css")
return c.Send(cssData)
}

View File

@@ -1,6 +1,6 @@
{ {
"scripts": { "scripts": {
"build": "pnpx tailwindcss -i ./styles/input.css -o ./styles/output.css --build && pnpx minify ./styles/output.css > ./cmd/styles.css" "build": "pnpx tailwindcss -i ./styles/input.css -o ./styles/output.css --build && pnpx minify ./styles/output.css > ./handlers/styles.css"
}, },
"devDependencies": { "devDependencies": {
"minify": "^10.5.2", "minify": "^10.5.2",

View File

@@ -83,7 +83,7 @@ func init() {
%s %s
}`, strings.Join(factoryMaps, "\n")) }`, strings.Join(factoryMaps, "\n"))
//fmt.Println(code) // fmt.Println(code)
return code, nil return code, nil
} }
@@ -155,7 +155,7 @@ func init() {
%s %s
}`, strings.Join(factoryMaps, "\n")) }`, strings.Join(factoryMaps, "\n"))
//fmt.Println(code) // fmt.Println(code)
return code, nil return code, nil
} }
@@ -177,7 +177,7 @@ func main() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
//fmt.Println(rqmCode) // fmt.Println(rqmCode)
fq, err := os.Create("../ruleset/rule_reqmod_types.gen.go") fq, err := os.Create("../ruleset/rule_reqmod_types.gen.go")
if err != nil { if err != nil {
@@ -192,7 +192,7 @@ func main() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
//fmt.Println(rsmCode) // fmt.Println(rsmCode)
fs, err := os.Create("../ruleset/rule_resmod_types.gen.go") fs, err := os.Create("../ruleset/rule_resmod_types.gen.go")
if err != nil { if err != nil {

View File

@@ -2,8 +2,9 @@ package requestmodifiers
import ( import (
"fmt" "fmt"
"ladder/proxychain"
"regexp" "regexp"
"ladder/proxychain"
) )
func ModifyPathWithRegex(matchRegex string, replacement string) proxychain.RequestModification { func ModifyPathWithRegex(matchRegex string, replacement string) proxychain.RequestModification {

View File

@@ -3,8 +3,9 @@ package responsemodifiers
import ( import (
_ "embed" _ "embed"
"io" "io"
"ladder/proxychain"
"strings" "strings"
"ladder/proxychain"
) )
//go:embed patch_google_analytics.js //go:embed patch_google_analytics.js

View File

@@ -4,9 +4,10 @@ import (
"embed" "embed"
"encoding/json" "encoding/json"
"io" "io"
"ladder/proxychain"
"log" "log"
"regexp" "regexp"
"ladder/proxychain"
) )
//go:embed vendor/ddg-tracker-surrogates/mapping.json //go:embed vendor/ddg-tracker-surrogates/mapping.json

View File

@@ -3,6 +3,7 @@ package ruleset_v2
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"ladder/proxychain" "ladder/proxychain"
) )
@@ -84,7 +85,6 @@ func (rule *Rule) MarshalJSON() ([]byte, error) {
// implement type yaml marshaller // implement type yaml marshaller
func (rule *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error { func (rule *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error {
type Aux struct { type Aux struct {
Domains []string `yaml:"domains"` Domains []string `yaml:"domains"`
RequestModifications []_rqm `yaml:"requestmodifications"` RequestModifications []_rqm `yaml:"requestmodifications"`
@@ -122,7 +122,6 @@ func (rule *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error {
} }
func (rule *Rule) MarshalYAML() (interface{}, error) { func (rule *Rule) MarshalYAML() (interface{}, error) {
type Aux struct { type Aux struct {
Domains []string `yaml:"domains"` Domains []string `yaml:"domains"`
RequestModifications []_rqm `yaml:"requestmodifications"` RequestModifications []_rqm `yaml:"requestmodifications"`

View File

@@ -1,5 +1,5 @@
package ruleset_v2 package ruleset_v2
// DO NOT EDIT THIS FILE. It is automatically generated by ladder/proxychain/codegen/codegen.go // DO NOT EDIT THIS FILE. It is automatically generated by ladder/proxychain/codegen/codegen.go
// The purpose of this is serialization of rulesets from JSON or YAML into functional options suitable // The purpose of this is serialization of rulesets from JSON or YAML into functional options suitable
// for use in proxychains. // for use in proxychains.
@@ -16,168 +16,167 @@ var rqmModMap map[string]RequestModifierFactory
func init() { func init() {
rqmModMap = make(map[string]RequestModifierFactory) rqmModMap = make(map[string]RequestModifierFactory)
rqmModMap["ForwardRequestHeaders"] = func(_ ...string) proxychain.RequestModification { rqmModMap["ForwardRequestHeaders"] = func(_ ...string) proxychain.RequestModification {
return rx.ForwardRequestHeaders() return rx.ForwardRequestHeaders()
} }
rqmModMap["MasqueradeAsGoogleBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsGoogleBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsGoogleBot() return rx.MasqueradeAsGoogleBot()
} }
rqmModMap["MasqueradeAsBingBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsBingBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsBingBot() return rx.MasqueradeAsBingBot()
} }
rqmModMap["MasqueradeAsWaybackMachineBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsWaybackMachineBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsWaybackMachineBot() return rx.MasqueradeAsWaybackMachineBot()
} }
rqmModMap["MasqueradeAsFacebookBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsFacebookBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsFacebookBot() return rx.MasqueradeAsFacebookBot()
} }
rqmModMap["MasqueradeAsYandexBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsYandexBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsYandexBot() return rx.MasqueradeAsYandexBot()
} }
rqmModMap["MasqueradeAsBaiduBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsBaiduBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsBaiduBot() return rx.MasqueradeAsBaiduBot()
} }
rqmModMap["MasqueradeAsDuckDuckBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsDuckDuckBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsDuckDuckBot() return rx.MasqueradeAsDuckDuckBot()
} }
rqmModMap["MasqueradeAsYahooBot"] = func(_ ...string) proxychain.RequestModification { rqmModMap["MasqueradeAsYahooBot"] = func(_ ...string) proxychain.RequestModification {
return rx.MasqueradeAsYahooBot() return rx.MasqueradeAsYahooBot()
} }
rqmModMap["ModifyDomainWithRegex"] = func(params ...string) proxychain.RequestModification { rqmModMap["ModifyDomainWithRegex"] = func(params ...string) proxychain.RequestModification {
return rx.ModifyDomainWithRegex(params[0], params[1]) return rx.ModifyDomainWithRegex(params[0], params[1])
} }
rqmModMap["SetOutgoingCookie"] = func(params ...string) proxychain.RequestModification { rqmModMap["SetOutgoingCookie"] = func(params ...string) proxychain.RequestModification {
return rx.SetOutgoingCookie(params[0], params[1]) return rx.SetOutgoingCookie(params[0], params[1])
} }
rqmModMap["SetOutgoingCookies"] = func(params ...string) proxychain.RequestModification { rqmModMap["SetOutgoingCookies"] = func(params ...string) proxychain.RequestModification {
return rx.SetOutgoingCookies(params[0]) return rx.SetOutgoingCookies(params[0])
} }
rqmModMap["DeleteOutgoingCookie"] = func(params ...string) proxychain.RequestModification { rqmModMap["DeleteOutgoingCookie"] = func(params ...string) proxychain.RequestModification {
return rx.DeleteOutgoingCookie(params[0]) return rx.DeleteOutgoingCookie(params[0])
} }
rqmModMap["DeleteOutgoingCookies"] = func(_ ...string) proxychain.RequestModification { rqmModMap["DeleteOutgoingCookies"] = func(_ ...string) proxychain.RequestModification {
return rx.DeleteOutgoingCookies() return rx.DeleteOutgoingCookies()
} }
rqmModMap["DeleteOutgoingCookiesExcept"] = func(params ...string) proxychain.RequestModification { rqmModMap["DeleteOutgoingCookiesExcept"] = func(params ...string) proxychain.RequestModification {
return rx.DeleteOutgoingCookiesExcept(params[0]) return rx.DeleteOutgoingCookiesExcept(params[0])
} }
rqmModMap["ModifyPathWithRegex"] = func(params ...string) proxychain.RequestModification { rqmModMap["ModifyPathWithRegex"] = func(params ...string) proxychain.RequestModification {
return rx.ModifyPathWithRegex(params[0], params[1]) return rx.ModifyPathWithRegex(params[0], params[1])
} }
rqmModMap["ModifyQueryParams"] = func(params ...string) proxychain.RequestModification { rqmModMap["ModifyQueryParams"] = func(params ...string) proxychain.RequestModification {
return rx.ModifyQueryParams(params[0], params[1]) return rx.ModifyQueryParams(params[0], params[1])
} }
rqmModMap["SetRequestHeader"] = func(params ...string) proxychain.RequestModification { rqmModMap["SetRequestHeader"] = func(params ...string) proxychain.RequestModification {
return rx.SetRequestHeader(params[0], params[1]) return rx.SetRequestHeader(params[0], params[1])
} }
rqmModMap["DeleteRequestHeader"] = func(params ...string) proxychain.RequestModification { rqmModMap["DeleteRequestHeader"] = func(params ...string) proxychain.RequestModification {
return rx.DeleteRequestHeader(params[0]) return rx.DeleteRequestHeader(params[0])
} }
rqmModMap["RequestArchiveIs"] = func(_ ...string) proxychain.RequestModification { rqmModMap["RequestArchiveIs"] = func(_ ...string) proxychain.RequestModification {
return rx.RequestArchiveIs() return rx.RequestArchiveIs()
} }
rqmModMap["RequestGoogleCache"] = func(_ ...string) proxychain.RequestModification { rqmModMap["RequestGoogleCache"] = func(_ ...string) proxychain.RequestModification {
return rx.RequestGoogleCache() return rx.RequestGoogleCache()
} }
rqmModMap["RequestWaybackMachine"] = func(_ ...string) proxychain.RequestModification { rqmModMap["RequestWaybackMachine"] = func(_ ...string) proxychain.RequestModification {
return rx.RequestWaybackMachine() return rx.RequestWaybackMachine()
} }
rqmModMap["ResolveWithGoogleDoH"] = func(_ ...string) proxychain.RequestModification { rqmModMap["ResolveWithGoogleDoH"] = func(_ ...string) proxychain.RequestModification {
return rx.ResolveWithGoogleDoH() return rx.ResolveWithGoogleDoH()
} }
rqmModMap["SpoofOrigin"] = func(params ...string) proxychain.RequestModification { rqmModMap["SpoofOrigin"] = func(params ...string) proxychain.RequestModification {
return rx.SpoofOrigin(params[0]) return rx.SpoofOrigin(params[0])
} }
rqmModMap["HideOrigin"] = func(_ ...string) proxychain.RequestModification { rqmModMap["HideOrigin"] = func(_ ...string) proxychain.RequestModification {
return rx.HideOrigin() return rx.HideOrigin()
} }
rqmModMap["SpoofReferrer"] = func(params ...string) proxychain.RequestModification { rqmModMap["SpoofReferrer"] = func(params ...string) proxychain.RequestModification {
return rx.SpoofReferrer(params[0]) return rx.SpoofReferrer(params[0])
} }
rqmModMap["HideReferrer"] = func(_ ...string) proxychain.RequestModification { rqmModMap["HideReferrer"] = func(_ ...string) proxychain.RequestModification {
return rx.HideReferrer() return rx.HideReferrer()
} }
rqmModMap["SpoofReferrerFromBaiduSearch"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromBaiduSearch"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromBaiduSearch() return rx.SpoofReferrerFromBaiduSearch()
} }
rqmModMap["SpoofReferrerFromBingSearch"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromBingSearch"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromBingSearch() return rx.SpoofReferrerFromBingSearch()
} }
rqmModMap["SpoofReferrerFromGoogleSearch"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromGoogleSearch"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromGoogleSearch() return rx.SpoofReferrerFromGoogleSearch()
} }
rqmModMap["SpoofReferrerFromLinkedInPost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromLinkedInPost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromLinkedInPost() return rx.SpoofReferrerFromLinkedInPost()
} }
rqmModMap["SpoofReferrerFromNaverSearch"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromNaverSearch"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromNaverSearch() return rx.SpoofReferrerFromNaverSearch()
} }
rqmModMap["SpoofReferrerFromPinterestPost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromPinterestPost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromPinterestPost() return rx.SpoofReferrerFromPinterestPost()
} }
rqmModMap["SpoofReferrerFromQQPost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromQQPost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromQQPost() return rx.SpoofReferrerFromQQPost()
} }
rqmModMap["SpoofReferrerFromRedditPost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromRedditPost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromRedditPost() return rx.SpoofReferrerFromRedditPost()
} }
rqmModMap["SpoofReferrerFromTumblrPost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromTumblrPost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromTumblrPost() return rx.SpoofReferrerFromTumblrPost()
} }
rqmModMap["SpoofReferrerFromTwitterPost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromTwitterPost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromTwitterPost() return rx.SpoofReferrerFromTwitterPost()
} }
rqmModMap["SpoofReferrerFromVkontaktePost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromVkontaktePost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromVkontaktePost() return rx.SpoofReferrerFromVkontaktePost()
} }
rqmModMap["SpoofReferrerFromWeiboPost"] = func(_ ...string) proxychain.RequestModification { rqmModMap["SpoofReferrerFromWeiboPost"] = func(_ ...string) proxychain.RequestModification {
return rx.SpoofReferrerFromWeiboPost() return rx.SpoofReferrerFromWeiboPost()
} }
rqmModMap["SpoofUserAgent"] = func(params ...string) proxychain.RequestModification { rqmModMap["SpoofUserAgent"] = func(params ...string) proxychain.RequestModification {
return rx.SpoofUserAgent(params[0]) return rx.SpoofUserAgent(params[0])
} }
rqmModMap["SpoofXForwardedFor"] = func(params ...string) proxychain.RequestModification { rqmModMap["SpoofXForwardedFor"] = func(params ...string) proxychain.RequestModification {
return rx.SpoofXForwardedFor(params[0]) return rx.SpoofXForwardedFor(params[0])
} }
}
}

View File

@@ -1,5 +1,5 @@
package ruleset_v2 package ruleset_v2
// DO NOT EDIT THIS FILE. It is automatically generated by ladder/proxychain/codegen/codegen.go // DO NOT EDIT THIS FILE. It is automatically generated by ladder/proxychain/codegen/codegen.go
// The purpose of this is serialization of rulesets from JSON or YAML into functional options suitable // The purpose of this is serialization of rulesets from JSON or YAML into functional options suitable
// for use in proxychains. // for use in proxychains.
@@ -16,84 +16,83 @@ var rsmModMap map[string]ResponseModifierFactory
func init() { func init() {
rsmModMap = make(map[string]ResponseModifierFactory) rsmModMap = make(map[string]ResponseModifierFactory)
rsmModMap["APIContent"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["APIContent"] = func(_ ...string) proxychain.ResponseModification {
return tx.APIContent() return tx.APIContent()
} }
rsmModMap["BlockElementRemoval"] = func(params ...string) proxychain.ResponseModification { rsmModMap["BlockElementRemoval"] = func(params ...string) proxychain.ResponseModification {
return tx.BlockElementRemoval(params[0]) return tx.BlockElementRemoval(params[0])
} }
rsmModMap["BypassCORS"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["BypassCORS"] = func(_ ...string) proxychain.ResponseModification {
return tx.BypassCORS() return tx.BypassCORS()
} }
rsmModMap["BypassContentSecurityPolicy"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["BypassContentSecurityPolicy"] = func(_ ...string) proxychain.ResponseModification {
return tx.BypassContentSecurityPolicy() return tx.BypassContentSecurityPolicy()
} }
rsmModMap["SetContentSecurityPolicy"] = func(params ...string) proxychain.ResponseModification { rsmModMap["SetContentSecurityPolicy"] = func(params ...string) proxychain.ResponseModification {
return tx.SetContentSecurityPolicy(params[0]) return tx.SetContentSecurityPolicy(params[0])
} }
rsmModMap["ForwardResponseHeaders"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["ForwardResponseHeaders"] = func(_ ...string) proxychain.ResponseModification {
return tx.ForwardResponseHeaders() return tx.ForwardResponseHeaders()
} }
rsmModMap["GenerateReadableOutline"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["GenerateReadableOutline"] = func(_ ...string) proxychain.ResponseModification {
return tx.GenerateReadableOutline() return tx.GenerateReadableOutline()
} }
rsmModMap["InjectScriptBeforeDOMContentLoaded"] = func(params ...string) proxychain.ResponseModification { rsmModMap["InjectScriptBeforeDOMContentLoaded"] = func(params ...string) proxychain.ResponseModification {
return tx.InjectScriptBeforeDOMContentLoaded(params[0]) return tx.InjectScriptBeforeDOMContentLoaded(params[0])
} }
rsmModMap["InjectScriptAfterDOMContentLoaded"] = func(params ...string) proxychain.ResponseModification { rsmModMap["InjectScriptAfterDOMContentLoaded"] = func(params ...string) proxychain.ResponseModification {
return tx.InjectScriptAfterDOMContentLoaded(params[0]) return tx.InjectScriptAfterDOMContentLoaded(params[0])
} }
rsmModMap["InjectScriptAfterDOMIdle"] = func(params ...string) proxychain.ResponseModification { rsmModMap["InjectScriptAfterDOMIdle"] = func(params ...string) proxychain.ResponseModification {
return tx.InjectScriptAfterDOMIdle(params[0]) return tx.InjectScriptAfterDOMIdle(params[0])
} }
rsmModMap["DeleteIncomingCookies"] = func(params ...string) proxychain.ResponseModification { rsmModMap["DeleteIncomingCookies"] = func(params ...string) proxychain.ResponseModification {
return tx.DeleteIncomingCookies(params[0]) return tx.DeleteIncomingCookies(params[0])
} }
rsmModMap["DeleteIncomingCookiesExcept"] = func(params ...string) proxychain.ResponseModification { rsmModMap["DeleteIncomingCookiesExcept"] = func(params ...string) proxychain.ResponseModification {
return tx.DeleteIncomingCookiesExcept(params[0]) return tx.DeleteIncomingCookiesExcept(params[0])
} }
rsmModMap["SetIncomingCookies"] = func(params ...string) proxychain.ResponseModification { rsmModMap["SetIncomingCookies"] = func(params ...string) proxychain.ResponseModification {
return tx.SetIncomingCookies(params[0]) return tx.SetIncomingCookies(params[0])
} }
rsmModMap["SetIncomingCookie"] = func(params ...string) proxychain.ResponseModification { rsmModMap["SetIncomingCookie"] = func(params ...string) proxychain.ResponseModification {
return tx.SetIncomingCookie(params[0], params[1]) return tx.SetIncomingCookie(params[0], params[1])
} }
rsmModMap["SetResponseHeader"] = func(params ...string) proxychain.ResponseModification { rsmModMap["SetResponseHeader"] = func(params ...string) proxychain.ResponseModification {
return tx.SetResponseHeader(params[0], params[1]) return tx.SetResponseHeader(params[0], params[1])
} }
rsmModMap["DeleteResponseHeader"] = func(params ...string) proxychain.ResponseModification { rsmModMap["DeleteResponseHeader"] = func(params ...string) proxychain.ResponseModification {
return tx.DeleteResponseHeader(params[0]) return tx.DeleteResponseHeader(params[0])
} }
rsmModMap["PatchDynamicResourceURLs"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["PatchDynamicResourceURLs"] = func(_ ...string) proxychain.ResponseModification {
return tx.PatchDynamicResourceURLs() return tx.PatchDynamicResourceURLs()
} }
rsmModMap["PatchGoogleAnalytics"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["PatchGoogleAnalytics"] = func(_ ...string) proxychain.ResponseModification {
return tx.PatchGoogleAnalytics() return tx.PatchGoogleAnalytics()
} }
rsmModMap["PatchTrackerScripts"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["PatchTrackerScripts"] = func(_ ...string) proxychain.ResponseModification {
return tx.PatchTrackerScripts() return tx.PatchTrackerScripts()
} }
rsmModMap["RewriteHTMLResourceURLs"] = func(_ ...string) proxychain.ResponseModification { rsmModMap["RewriteHTMLResourceURLs"] = func(_ ...string) proxychain.ResponseModification {
return tx.RewriteHTMLResourceURLs() return tx.RewriteHTMLResourceURLs()
} }
}
}

View File

@@ -3,8 +3,9 @@ package ruleset_v2
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"gopkg.in/yaml.v3"
"testing" "testing"
"gopkg.in/yaml.v3"
) )
// unmarshalRule is a helper function to unmarshal a Rule from a JSON string. // unmarshalRule is a helper function to unmarshal a Rule from a JSON string.