synchronizing/mitm

TypeError: ClassTask.__init__() got an unexpected keyword argument 'run_forever'

Closed this issue ยท 6 comments

Hello, here I am again!

EDIT: If I knew how to fix this I'd make a PR, sorry in advance!

Code (from examples):

from mitm import MITM, protocol, middleware, crypto

mitm = MITM(
    host="127.0.0.1",
    port=8888,
    protocols=[protocol.HTTP],
    middlewares=[middleware.Log],
    buffer_size=8192,
    timeout=5,
    ssl_context=crypto.mitm_ssl_default_context(),
    start=False,
)
mitm.start()

Output error:

Traceback (most recent call last):
  File "c:\Users\Slimakoi\Desktop\Coding\test\falling_new.py", line 3, in <module>
    mitm = MITM(
  File "C:\Program Files\Python310\lib\site-packages\mitm\mitm.py", line 65, in __init__
    super().__init__(
TypeError: ClassTask.__init__() got an unexpected keyword argument 'run_forever'

@synchronizing ClassTask class of toolbox package need to support run_forever keyword argument ๐Ÿ™

Oh no, sorry guys. I'll get to this later today and submit a fix. My apologies!

Just released v1.2.0 that fixes these issues. You guys should be able to do:

pip install mitm --upgrade

To upgrade mitm to the latest version, and use:

from mitm import MITM, protocol, middleware, crypto

mitm = MITM(
    host="127.0.0.1",
    port=8888,
    protocols=[protocol.HTTP],
    middlewares=[middleware.Log],
    buffer_size=8192,
    timeout=5,
    ssl_context=crypto.mitm_ssl_default_context(),
)
mitm.run()

Do note that I changed mitm.start() to mitm.run(). The project is very much still in development, and I'm still figuring out args/func names/etc. as I go along, and so I apologize for the random little bugs and changes.

Thank you for reporting the issues. I'll start locking in Toolbox versioning to prevent this headache.

No worries! Thank you so much for maintaining this project.

Although I for another error, maybe because I'm running python 3.10.0

Traceback (most recent call last):
  File "C:\Users\Slimakoi\Desktop\Coding\test\falling_new.py", line 1, in <module>
    from mitm import MITM, protocol, middleware, crypto
  File "C:\Program Files\Python310\lib\site-packages\mitm\__init__.py", line 22, in <module>
    from .mitm import *
  File "C:\Program Files\Python310\lib\site-packages\mitm\mitm.py", line 10, in <module>
    from toolbox.asyncio.pattern import CoroutineClass
ImportError: cannot import name 'CoroutineClass' from 'toolbox.asyncio.pattern' (C:\Program Files\Python310\lib\site-packages\toolbox\asyncio\pattern.py)

ImportError: cannot import name 'CoroutineClass' from 'toolbox.asyncio.pattern' (C:\Program Files\Python310\lib\site-packages\toolbox\asyncio\pattern.py)

Try doing:

pip install toolbox --upgrade

Edit: I locked toolbox and httpq versioning via the requirements.txt. If you do

pip install mitm --upgrade

One more time it should work without a hitch now.

Works like a charm now, thanks!