Skip to content

Commit f08aee7

Browse files
committed
coverage
1 parent 69d95bd commit f08aee7

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

synapse/models/inet.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ def _normPyStr(self, valu):
461461
portstr = f':{port}'
462462

463463
elif self.defport:
464-
subs['port'] = self.port
465-
virts['port'] = (self.port, self.porttype.stortype)
466-
portstr = f':{self.port}'
464+
subs['port'] = self.defport
465+
virts['port'] = (self.defport, self.porttype.stortype)
466+
portstr = f':{self.defport}'
467467

468468
return f'{proto}://[{host}]{portstr}', {'subs': subs, 'virts': virts}
469469

@@ -475,6 +475,12 @@ def _normPyStr(self, valu):
475475
host = self.iptype.repr(ipv6)
476476
subs['ip'] = ipv6
477477
virts['ip'] = (ipv6, self.iptype.stortype)
478+
479+
if self.defport:
480+
subs['port'] = self.defport
481+
virts['port'] = (self.defport, self.porttype.stortype)
482+
return f'{proto}://[{host}]:{self.defport}', {'subs': subs, 'virts': virts}
483+
478484
return f'{proto}://{host}', {'subs': subs, 'virts': virts}
479485

480486
# Otherwise treat as IPv4

synapse/tests/test_model_inet.py

+6
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,12 @@ async def test_server(self):
13581358
nodes = await core.nodes('[ it:network=* :dns:resolvers=(([6, 1]),)]')
13591359
self.eq(nodes[0].get('dns:resolvers'), ('udp://[::1]:53',))
13601360

1361+
nodes = await core.nodes('[ it:network=* :dns:resolvers=("::1",)]')
1362+
self.eq(nodes[0].get('dns:resolvers'), ('udp://[::1]:53',))
1363+
1364+
nodes = await core.nodes('[ it:network=* :dns:resolvers=("[::1]",)]')
1365+
self.eq(nodes[0].get('dns:resolvers'), ('udp://[::1]:53',))
1366+
13611367
async def test_servfile(self):
13621368
async with self.getTestCore() as core:
13631369
valu = ('tcp://127.0.0.1:4040', 64 * 'f')

0 commit comments

Comments
 (0)