aruba / pyaoscx

Python modules for AOS-CX
Apache License 2.0
35 stars 24 forks source link

Connection via IPv6 using IP-Address fails #17

Open flycam opened 2 years ago

flycam commented 2 years ago

Trying to connect to a device using and IPv6 Address fails with the error: raise LoginError("Cookies were not set correctly. Login failed") I did encase the IP Address in square brackets like [2001:db8:1::25], as it is customary for URLs. Without the brackets, I got even more parsing errors.

In the file session.py:159 in method open(...): )

        self.connected = (
            hasattr(cookies, "_cookies") and self.ip in cookies._cookies
        )

the check for connected fails, as for some reason unknown to me the switch returns the cookie with the address [2001:db8:1::25].local. This extra .local at the end of the ip fails the test condition.

I tried to mitigate by also checking for .local, and that is a workaround for my development machine at the moment.

        self.connected = hasattr(cookies, '_cookies') and (self.ip in cookies._cookies or "%s.local"% self.ip in cookies._cookies)

I would really appreciate a fix for this in the official pypi version (or in aos-cx, whatever is preferred), as plan to run this on ipv6-only networks, and newly deployed switches do not have dns entries yet. If I need to push this via my SE or a support case, please tell me as that would be possible.

tchiapuziowong commented 2 years ago

Looking into this and how it escaped testing! Thank you for bringing this to our attention 👍

liske commented 1 month ago

This cookie check in pyaoscx looks almost broken.

I have a setup were an alternative https port is used, this breaks this module. I wonder