Start multiple classes

Like this example I want to start multiple classes.
I want to implement every functionality in different class and return them in main start event based on options read. Is it possible?

def start():
    return [FunctionClass1(), FunctionClass2()]

Thanks

1 Like

Hi,

You can partially do that with 3.0. Take a look at the same example from master: add_header_class.py.
While the set of classes is fixed, each class can register their own options and only be active if those are set. Does that help? :slight_smile:

It is exactly what I was looking for!
Currently I am using v2.0.2: what I have to change in my scripts for v3.0? when will it be released in non beta version?
I installed v2.0.2 by pip3, what I have to do to try new version?

what I have to change in my scripts for v3.0?

I think the main changes are 1) script arguments -> options, and 2) addon loading (as in the example). We’ll have new docs in place for the final release

when will it be released in non beta version?

3.0 is feature complete and stable, we just need to finish documentation. So hopefully very soon™.

I installed v2.0.2 by pip3, what I have to do to try new version?

You can find prereleases at https://github.com/mitmproxy/mitmproxy/releases, e.g. you can just download the wheel and pip-install it. :slight_smile:

I installed stable 3.0.0 RC2 by the wheel but now I have some problems with script arguments: I read arguments from external
mitmproxy -s "my_script.py arg1"
and I have an error
No such script: my_script.py arg1
You proposed me custom option but I want to declare arguments in the command and not to modify the main script. It is possible?

Hi, does this help?

Thank you for your immediate reply!
It is the step I miss.
Sorry, it is almost obvious…

Glad it helps and no worries - this is very useful feedback that leads to immediate improvements to the documentation. :slight_smile: