Skip to content

Commit

Permalink
set remote_addr
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Dec 2, 2022
1 parent b99fbc9 commit 7bc13b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion asyncsnmplib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ def __init__(self, host, port=161, community='public', max_rows=10000):
self.community = community
self.max_rows = max_rows

# On some systems it seems to be required to set the remote_addr argument
# https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_datagram_endpoint
async def connect(self, timeout=10):
try:
infos = await self._loop.getaddrinfo(self.host, self.port)
family, *_, addr = infos[0]
transport, protocol = await asyncio.wait_for(
self._loop.create_datagram_endpoint(
lambda: SnmpProtocol(addr),
# remote_addr=(self.host, self.port),
remote_addr=(self.host, self.port),
family=family),
timeout=timeout)
except Exception:
Expand Down Expand Up @@ -188,13 +190,16 @@ def __init__(
raise Exception('Supply priv_passwd')
self._priv_hash = self._auth_proto.hash_passphrase(priv_passwd)

# On some systems it seems to be required to set the remote_addr argument
# https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_datagram_endpoint
async def connect(self, timeout=10):
try:
infos = await self._loop.getaddrinfo(self.host, self.port)
family, *_, addr = infos[0]
transport, protocol = await asyncio.wait_for(
self._loop.create_datagram_endpoint(
lambda: SnmpV3Protocol(addr),
remote_addr=(self.host, self.port),
family=family),
timeout=timeout)
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion asyncsnmplib/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.2'
__version__ = '0.1.3'

0 comments on commit 7bc13b2

Please sign in to comment.