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 }