update cli flags to load ruleset

This commit is contained in:
Kevin Pham
2023-12-05 21:28:53 -06:00
parent 5a7fe8a70a
commit 6192373587
4 changed files with 28 additions and 18 deletions

View File

@@ -10,6 +10,7 @@ import (
"ladder/handlers"
"ladder/internal/cli"
"ladder/proxychain/requestmodifiers/bot"
"ladder/proxychain/ruleset"
"github.com/akamensky/argparse"
"github.com/gofiber/fiber/v2"
@@ -116,6 +117,18 @@ func main() {
*prefork = true
}
var rs ruleset_v2.IRuleset
switch {
case *ruleset != "":
rs, err = ruleset_v2.NewRuleset(*ruleset)
if err != nil {
fmt.Printf("ERROR: failed to load ruleset from %s\n", *ruleset)
}
case os.Getenv("RULESET") != "":
rs = ruleset_v2.NewRulesetFromEnv()
}
engine := html.New("./handlers", ".html")
engine.AddFunc(
// add unescape function
@@ -145,6 +158,11 @@ func main() {
})
}
proxyOpts := &handlers.ProxyOptions{
Verbose: *verbose,
Ruleset: rs,
}
app.Get("/", handlers.Form)
app.Get("styles.css", handlers.Styles)
@@ -152,11 +170,6 @@ func main() {
app.Get("ruleset", handlers.Ruleset)
app.Get("raw/*", handlers.Raw)
proxyOpts := &handlers.ProxyOptions{
Verbose: *verbose,
RulesetPath: *ruleset,
}
app.Get("api/content/*", handlers.NewAPIContentHandler("api/outline/*", proxyOpts))
app.Get("outline/*", handlers.NewOutlineHandler("outline/*", proxyOpts))