Skip to content

Commit

Permalink
make compatible with ipv6 (#123)
Browse files Browse the repository at this point in the history
* make compatible with ipv6

* improve debug logging
  • Loading branch information
starkillerOG committed May 19, 2022
1 parent 215710a commit aadc483
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pynetgear/router.py
Expand Up @@ -7,6 +7,7 @@
from time import sleep

import requests
from ipaddress import IPv6Address
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning

Expand Down Expand Up @@ -61,6 +62,13 @@ def __init__(
if not user:
user = c.DEFAULT_USER

try:
IPv6Address(host)
except ValueError:
pass
else:
host = "[%s]" % (host)

self.username = user
self.password = password
self.url = url
Expand Down Expand Up @@ -222,12 +230,12 @@ def _make_request(

return success, response

except requests.exceptions.RequestException:
except requests.exceptions.RequestException as err:
if not self._logging_in:
_LOGGER.exception("Error talking to API")
else:
_LOGGER.debug("RequestException while logging in "
"port %s ssl %s", self.port, self.ssl)
"port %s ssl %s: %s", self.port, self.ssl, err)
self.cookie = None

# Maybe one day we will distinguish between
Expand Down

0 comments on commit aadc483

Please sign in to comment.