diff options
-rw-r--r-- | tftpy/TftpServer.py | 14 | ||||
-rw-r--r-- | tftpy/TftpShared.py | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/tftpy/TftpServer.py b/tftpy/TftpServer.py index cb5d613..5b5d705 100644 --- a/tftpy/TftpServer.py +++ b/tftpy/TftpServer.py @@ -271,6 +271,18 @@ class TftpServerHandler(TftpSession): rport) raise TftpException, "Unsupported mode: %s" % recvpkt.mode + # test host/port of client end + if self.host != raddress or self.port != rport: + self.senderror(self.sock, + TftpErrors.UnknownTID, + raddress, + rport) + logger.error("Expected traffic from %s:%s but received it " + "from %s:%s instead." + % (self.host, self.port, raddress, rport)) + self.errors += 1 + return + if self.state.state == 'rrq': logger.debug("Received RRQ. Composing response.") self.filename = self.root + os.sep + recvpkt.filename @@ -310,7 +322,6 @@ class TftpServerHandler(TftpSession): % (self.key, blksize)) self.options['blksize'] = DEF_BLKSIZE - logger.debug("Composing and sending OACK packet") self.send_oack() elif len(recvpkt.options.keys()) > 0: @@ -415,6 +426,7 @@ class TftpServerHandler(TftpSession): self.sock.sendto(dat.encode().buffer, (self.host, self.port)) self.timesent = time.time() + # FIXME - should these be factored-out into the session class? def send_oack(self): """This method sends an OACK packet based on current params.""" logger.debug("Composing and sending OACK packet") diff --git a/tftpy/TftpShared.py b/tftpy/TftpShared.py index c4d4a1c..2871151 100644 --- a/tftpy/TftpShared.py +++ b/tftpy/TftpShared.py @@ -1,4 +1,5 @@ import logging +from tftpy import TftpPacketERR LOG_LEVEL = logging.NOTSET MIN_BLKSIZE = 8 |