From cc73737ea5a074e04f828a1fd4811101c6494792 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 13 May 2015 22:58:04 +0200 Subject: [PATCH] Add IPv6 support To support ipv6 the session sockets need to listen on the local interface the main connection arrived. This way the session sockets get the correct address family. --- tftp/protocol.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tftp/protocol.py b/tftp/protocol.py index c74bbbb..218c3ee 100644 --- a/tftp/protocol.py +++ b/tftp/protocol.py @@ -53,9 +53,11 @@ def _startSession(self, datagram, addr, mode): # information to interested backends without adding extra call # arguments, or switching to using a request object, for example. context = {} + interface = '' if self.transport is not None: # Add the local and remote addresses to the call context. local = self.transport.getHost() + interface = local.host context["local"] = local.host, local.port context["remote"] = addr try: @@ -82,12 +84,12 @@ def _startSession(self, datagram, addr, mode): fs_interface = NetasciiReceiverProxy(fs_interface) session = RemoteOriginWriteSession(addr, fs_interface, datagram.options, _clock=self._clock) - reactor.listenUDP(0, session) + reactor.listenUDP(0, session, interface=interface) returnValue(session) elif datagram.opcode == OP_RRQ: if mode == 'netascii': fs_interface = NetasciiSenderProxy(fs_interface) session = RemoteOriginReadSession(addr, fs_interface, datagram.options, _clock=self._clock) - reactor.listenUDP(0, session) + reactor.listenUDP(0, session, interface=interface) returnValue(session)