From 218105d4ec38e311a4d187543ac47428eeb85c3e Mon Sep 17 00:00:00 2001 From: Alberto Sottile Date: Fri, 25 Jan 2019 10:13:18 +0100 Subject: [PATCH] IPv6: use HostnameEndpoint in client for both IPv4 and IPv6 This change was originally introduced and then deleted. Now is reintroduced after tests on both protocols. HostnameEndpoint is needed in some configurations to resolve IPv6-only hostnames, so it is required. The connection now works with both protocols on clients and servers. NOTE: now a wrong server/address/port DOES NOT trigger a Connection with Server Failed error immediately, the error stays in Deferred. This must be fixed before putting this code in production. --- syncplay/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syncplay/client.py b/syncplay/client.py index c4bc20a..318efc4 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -11,6 +11,7 @@ import time from copy import deepcopy from functools import wraps +from twisted.internet.endpoints import HostnameEndpoint from twisted.internet.protocol import ClientFactory from twisted.internet import reactor, task, defer, threads @@ -728,7 +729,8 @@ class SyncplayClient(object): if '[' in host: host = host.strip('[]') port = int(port) - reactor.connectTCP(host, port, self.protocolFactory) + self._endpoint = HostnameEndpoint(reactor, host, port) + self._endpoint.connect(self.protocolFactory) reactor.run() def stop(self, promptForAction=False):