Added confirmation of incoming traffic to known remote host.

git-svn-id: https://tftpy.svn.sourceforge.net/svnroot/tftpy/trunk@11 63283fd4-ec1e-0410-9879-cb7f675518da
master
msoulier 2006-10-04 22:16:26 +00:00
parent c11ac3a321
commit c24bba272f
1 changed files with 20 additions and 1 deletions

View File

@ -427,6 +427,18 @@ class TftpClient(TftpSession):
self.host = host
self.port = port
self.options = options
def gethost(self):
"Simple getter method."
return self.__host
def sethost(self, host):
"""Setter method that also sets the address property as a result
of the host that is set."""
self.__host = host
self.address = socket.gethostbyname(host)
host = property(gethost, sethost)
def download(self, filename, output, packethook=None):
"""This method initiates a tftp download from the configured remote
@ -456,7 +468,14 @@ class TftpClient(TftpSession):
logger.debug("Received %d bytes from %s:%s"
% (len(buffer), raddress, rport))
# FIXME - check sender port and ip address
if rport != self.port or raddress != self.address:
logger.warn("Received traffic from %s:%s but we're "
"connected to %s:%s. Discarding."
% (raddress, rport,
self.host, self.port))
continue
if isinstance(recvpkt, TftpPacketDAT):
logger.debug("recvpkt.blocknumber = %d" % recvpkt.blocknumber)
logger.debug("curblock = %d" % curblock)