From a708830309a2b61587fcadd4a552b49a0ecc2e86 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Wed, 20 May 2026 19:31:44 +0200 Subject: [PATCH] give the set_path et set_url fonction to plugins Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- internal/plugins/lua.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/plugins/lua.go b/internal/plugins/lua.go index ec3f3dc..3795ec0 100644 --- a/internal/plugins/lua.go +++ b/internal/plugins/lua.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "log" + "net/url" "os/exec" "strings" "time" @@ -292,6 +293,21 @@ func pushRequest(L *lua.LState, f *goproxy.Flow) *lua.LTable { return 0 })) + L.SetField(t, "set_path", L.NewFunction(func(L *lua.LState) int { + r.URL.Path = L.CheckString(2) + return 0 + })) + + L.SetField(t, "set_url", L.NewFunction(func(L *lua.LState) int { + parsed, err := url.Parse(L.CheckString(2)) + if err != nil { + log.Printf("[plugin] set_url: %v", err) + return 0 + } + r.URL = parsed + return 0 + })) + return t }