Skip to content

Commit 79f51e7

Browse files
authored
Add an example of loading external plugins
1 parent 09c9b63 commit 79f51e7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,37 @@ OR, simply pass fully-qualified path as parameter, e.g.
17221722

17231723
`proxy --plugins /path/to/my/app/my_app.proxyPlugin`
17241724

1725+
Here is a quick working example:
1726+
1727+
- Contents of `/tmp/plug` folder
1728+
1729+
```console
1730+
╰─ ls -1 /tmp/plug ─╯
1731+
my_plugin.py
1732+
```
1733+
1734+
- Custom `MyPlugin` class
1735+
1736+
```console
1737+
╰─ cat /tmp/plug/my_plugin.py ─╯
1738+
from proxy.http.proxy import HttpProxyBasePlugin
1739+
1740+
1741+
class MyPlugin(HttpProxyBasePlugin):
1742+
pass
1743+
```
1744+
1745+
This is an empty plugin for demonstrating external plugin usage. You must implement necessary methods to make your plugins work for real traffic
1746+
1747+
- Start `proxy.py` with `MyPlugin`
1748+
1749+
```console
1750+
╰─ PYTHONPATH=/tmp/plug proxy --plugin my_plugin.MyPlugin ─╯
1751+
...[redacted]... - Loaded plugin proxy.http.proxy.HttpProxyPlugin
1752+
...[redacted]... - Loaded plugin my_plugin.MyPlugin
1753+
...[redacted]... - Listening on ::1:8899
1754+
```
1755+
17251756
## Unable to connect with proxy.py from remote host
17261757

17271758
Make sure `proxy.py` is listening on correct network interface.

0 commit comments

Comments
 (0)