mirror of
https://github.com/django/daphne.git
synced 2024-11-21 23:46:33 +03:00
IPV6 interface binding (#80)
This commit is contained in:
parent
4d23655b5c
commit
630609fce7
|
@ -185,6 +185,7 @@ def build_endpoint_description_strings(
|
|||
"""
|
||||
socket_descriptions = []
|
||||
if host and port:
|
||||
host = host.strip('[]').replace(':', '\:')
|
||||
socket_descriptions.append('tcp:port=%d:interface=%s' % (int(port), host))
|
||||
elif any([host, port]):
|
||||
raise ValueError('TCP binding requires both port and host kwargs.')
|
||||
|
|
|
@ -28,6 +28,16 @@ class TestEndpointDescriptions(TestCase):
|
|||
['tcp:port=8000:interface=127.0.0.1']
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
build(port=8000, host='[200a::1]'),
|
||||
['tcp:port=8000:interface=200a\:\:1']
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
build(port=8000, host='200a::1'),
|
||||
['tcp:port=8000:interface=200a\:\:1']
|
||||
)
|
||||
|
||||
# incomplete port/host kwargs raise errors
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
|
@ -123,6 +133,14 @@ class TestCLIInterface(TestCase):
|
|||
'-b 10.0.0.1',
|
||||
['tcp:port=8000:interface=10.0.0.1']
|
||||
)
|
||||
self.checkCLI(
|
||||
'-b 200a::1',
|
||||
['tcp:port=8000:interface=200a\:\:1']
|
||||
)
|
||||
self.checkCLI(
|
||||
'-b [200a::1]',
|
||||
['tcp:port=8000:interface=200a\:\:1']
|
||||
)
|
||||
self.checkCLI(
|
||||
'-p 8080 -b example.com',
|
||||
['tcp:port=8080:interface=example.com']
|
||||
|
|
Loading…
Reference in New Issue
Block a user