abhinavsingh / proxy.py

💫 Ngrok FRP Alternative • ⚡ Fast • 🪶 Lightweight • 0️⃣ Dependency • 🔌 Pluggable • 😈 TLS interception • 🔒 DNS-over-HTTPS • 🔥 Poor Man's VPN • ⏪ Reverse & ⏩ Forward • 👮🏿 "Proxy Server" framework • 🌐 "Web Server" framework • ➵ ➶ ➷ ➠ "PubSub" framework • 👷 "Work" acceptor & executor framework
https://abhinavsingh.com/proxy-py-a-lightweight-single-file-http-proxy-server-in-python/
BSD 3-Clause "New" or "Revised" License
2.99k stars 573 forks source link

[Plugin] Custom flags in external plugins not discovered when enabled using kwargs #871

Open abhinavsingh opened 2 years ago

abhinavsingh commented 2 years ago

Describe the bug

DOES NOT WORK

proxy.Proxy(plugins=["...", "...",]) will not result in discovering custom flags defined in the external plugins.

FOLLOWING 2 SCENARIO WORKS

proxy.Plugin(*("--plugin", "...", "--plugin", "..."))

or

proxy --plugin ....

FIX

args.plugins must be resolved prior to calling Flags.parse for custom flag discovery.

klmunday commented 1 year ago

Hi,

Is there any update to this or more details regarding implementing the workaround for the skeleton app example? https://github.com/abhinavsingh/proxy.py/tree/develop/skeleton

klmunday commented 1 year ago

Hi,

Is there any update to this or more details regarding implementing the workaround for the skeleton app example? https://github.com/abhinavsingh/proxy.py/tree/develop/skeleton

Figured it out.

def run_proxy() -> None:
    with proxy.Proxy(
            enable_web_server=True,
            port=9000,
            input_args=["--plugin", "<plugin name>"]
    ) as _:
        proxy.sleep_loop()

This then correctly loads the plugin and resolves the plugins flags and their default values. I would imagine for any utilisation of the flags (outside of default) you'd probably need to add those to the input_args as well