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.
This commit is contained in:
Alberto Sottile 2019-01-25 10:13:18 +01:00
parent a78c646556
commit 218105d4ec

View File

@ -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):