Skip to content

Commit

Permalink
Relax endpont check (fixes #56)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jul 31, 2015
1 parent 18708ab commit ee77ae0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ CHANGES

* Do deeper lookup for inhereted classes #54

* Relax endpont check #56

0.6.1 (2015-05-19)
^^^^^^^^^^^^^^^^^^

Expand Down
6 changes: 0 additions & 6 deletions aiozmq/core.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import asyncio
import asyncio.events
import errno
import re
import struct
import sys
import threading
import weakref
import zmq

from collections import deque, Iterable, namedtuple
from ipaddress import ip_address

from .interface import ZmqTransport, ZmqProtocol
from .log import logger
Expand Down Expand Up @@ -235,7 +233,6 @@ def event_received(self, evt):

class _BaseTransport(ZmqTransport):

_TCP_RE = re.compile('^tcp://(.+):(\d+)|\*$')
LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5
ZMQ_TYPES = {getattr(zmq, name): name
for name in ('PUB', 'SUB', 'REP', 'REQ',
Expand Down Expand Up @@ -478,9 +475,6 @@ def connect(self, endpoint):
if not isinstance(endpoint, str):
raise TypeError('endpoint should be str, got {!r}'
.format(endpoint))
match = self._TCP_RE.match(endpoint)
if match:
ip_address(match.group(1)) # check for correct IPv4 or IPv6
try:
self._zmq_sock.connect(endpoint)
except zmq.ZMQError as exc:
Expand Down
17 changes: 11 additions & 6 deletions tests/zmq_events_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,20 @@ def connect():
self.loop.run_until_complete(connect())

def test_create_zmq_connection_dns_in_connect(self):
port = find_unused_port()

@asyncio.coroutine
def connect():
with self.assertRaises(ValueError):
yield from aiozmq.create_zmq_connection(
lambda: Protocol(self.loop),
zmq.SUB,
connect='tcp://example.com:5555',
loop=self.loop)
addr = 'tcp://localhost:{}'.format(port)
tr, pr = yield from aiozmq.create_zmq_connection(
lambda: Protocol(self.loop),
zmq.SUB,
connect=addr,
loop=self.loop)
yield from pr.connected

self.assertEqual({addr}, tr.connections())
tr.close()

self.loop.run_until_complete(connect())

Expand Down

0 comments on commit ee77ae0

Please sign in to comment.