mirror of
https://github.com/django/daphne.git
synced 2025-07-14 18:02:17 +03:00
IPV6 interface binding
This commit is contained in:
parent
60952b34bf
commit
4ce0d43223
|
@ -185,6 +185,7 @@ def build_endpoint_description_strings(
|
||||||
"""
|
"""
|
||||||
socket_descriptions = []
|
socket_descriptions = []
|
||||||
if host and port:
|
if host and port:
|
||||||
|
host = host.strip('[]').replace(':', '\:')
|
||||||
socket_descriptions.append('tcp:port=%d:interface=%s' % (int(port), host))
|
socket_descriptions.append('tcp:port=%d:interface=%s' % (int(port), host))
|
||||||
elif any([host, port]):
|
elif any([host, port]):
|
||||||
raise ValueError('TCP binding requires both port and host kwargs.')
|
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']
|
['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
|
# incomplete port/host kwargs raise errors
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
ValueError,
|
ValueError,
|
||||||
|
@ -123,6 +133,14 @@ class TestCLIInterface(TestCase):
|
||||||
'-b 10.0.0.1',
|
'-b 10.0.0.1',
|
||||||
['tcp:port=8000:interface=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(
|
self.checkCLI(
|
||||||
'-p 8080 -b example.com',
|
'-p 8080 -b example.com',
|
||||||
['tcp:port=8080:interface=example.com']
|
['tcp:port=8080:interface=example.com']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user