def _makeDataConnection(self): # Establish a passive data connection (i.e. client connecting to # server). responseLines = wait(self.client.queueStringCommand("PASV")) host, port = ftp.decodeHostPort(responseLines[-1][4:]) downloader = wait(protocol.ClientCreator(reactor, _BufferingProtocol).connectTCP("127.0.0.1", port)) return downloader
def _makeDataConnection(self): responseLines = wait(self.client.queueStringCommand('PASV')) host, port = ftp.decodeHostPort(responseLines[-1][4:]) downloader = wait( protocol.ClientCreator(reactor, _BufferingProtocol).connectTCP('127.0.0.1', port) ) return downloader
def _makeDataConnection(self): # Establish a passive data connection (i.e. client connecting to # server). responseLines = wait(self.client.queueStringCommand('PASV')) host, port = ftp.decodeHostPort(responseLines[-1][4:]) downloader = wait( protocol.ClientCreator(reactor, _BufferingProtocol).connectTCP( '127.0.0.1', port)) return downloader
def testDecodeHostPort(self): self.assertEquals(ftp.decodeHostPort('25,234,129,22,100,23'), ('25.234.129.22', 25623)) nums = range(6) for i in range(6): badValue = list(nums) badValue[i] = 256 s = ','.join(map(str, badValue)) self.assertRaises(ValueError, ftp.decodeHostPort, s)
def testPASV(self): # Login self._anonymousLogin() # Issue a PASV command, and extract the host and port from the response responseLines = wait(self.client.queueStringCommand('PASV')) host, port = ftp.decodeHostPort(responseLines[-1][4:]) # Make sure the server is listening on the port it claims to be self.assertEqual(port, self.serverProtocol.dtpPort.getHost().port) # Semi-reasonable way to force cleanup self.serverProtocol.connectionLost(error.ConnectionDone())
def testPASV(self): # Login self._anonymousLogin() # Issue a PASV command, and extract the host and port from the response responseLines = wait(self.client.queueStringCommand('PASV')) host, port = ftp.decodeHostPort(responseLines[-1][4:]) # Make sure the server is listening on the port it claims to be self.assertEqual(port, self.serverProtocol.dtpPort.getHost().port) # Hack: clean up the DTP port directly d = self.serverProtocol.dtpPort.stopListening() if d is not None: wait(d) self.serverProtocol.dtpFactory = None
def testPASV(self): self._anonymousLogin() responseLines = wait(self.client.queueStringCommand('PASV')) host, port = ftp.decodeHostPort(responseLines[-1][4:]) self.assertEqual(port, self.serverProtocol.dtpPort.getHost().port) self.serverProtocol.connectionLost(error.ConnectionDone())
def testDecodeHostPort(self): self.assertEquals(ftp.decodeHostPort('25,234,129,22,100,23'), ('25.234.129.22', 25623))
def testDecodeHostPort(self): data = "999 The magic address is (123,234,56,78,11,22)" host, port = ftp.decodeHostPort(data) self.failUnlessEqual(host, '123.234.56.78') self.failUnlessEqual(port, (11*256) + 22)
def gotPASV(responseLines): host, port = ftp.decodeHostPort(responseLines[-1][4:]) cc = protocol.ClientCreator(reactor, _BufferingProtocol) return cc.connectTCP('127.0.0.1', port)