def secure_fxp_to(self, file, target, target_file=None, type='I'): """FXP (server-to-server-copy) a file between 2 servers. This uses CPSV instead of PASV to fxp file with SSL encryption""" if not target_file: target_file = file if not self.prot_p: self.prot_p() if not target.prot_p: target.prot_p() type = 'TYPE ' + type self.voidcmd(type) target.voidcmd(type) if self.use_pret: self.voidcmd('PRET RETR ' + file) host, host_port = ftplib.parse227(self.sendcmd('CPSV')) if target.use_pret: target.voidcmd('PRET STOR' + target_file) target.sendport(host, host_port) t_reply = target.sendcmd('STOR ' + target_file) if t_reply[:3] not in {'125', '150'}: raise ftplib.error_proto # RFC 959 reply = self.sendcmd('RETR ' + file) if reply[:3] not in {'125', '150'}: raise ftplib.error_proto # RFC 959 self.voidresp() target.voidresp()
def makepasv(self): if self.af == socket.AF_INET: host, port = parse227(self.sendcmd('PASV')) else: host, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername()) return self.host, port
def makepasv(self): if self.af == socket.AF_INET: host, port = parse227(self.sendcmd('PASV')) else: host, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername()) # We tweak this so we don't use the internal ip returned by the remote server. # old: `return host, port` return self.host, port
def makepasv(self): if self.af == socket.AF_INET: host, port = parse227(self.sendcmd('PASV')) else: host, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername()) if self.fix_host is not None: host = self.fix_host return host, port
def makepasv(self, family): '''Create a new connection and send a PASV/EPSV command for it.''' if family == socket.AF_INET: resp = self._request('PASV') host, port = ftplib.parse227(str(resp.raw)) else: resp = self._request('EPSV') host, port = ftplib.parse229(str(resp.raw), self.sock.getpeername()) conn = socket.create_connection((host, port), self.timeout) connMetadata = {"response": resp, "host": host, "port": port} return conn, connMetadata
def makepasv(self): if self.af == socket.AF_INET: host, port = ftplib.parse227(self.sendcmd('PASV')) else: host, port = ftplib.parse229(self.sendcmd('EPSV'), self.sock.getpeername()) if '0.0.0.0' == host: """ this ip will be unroutable, we copy Filezilla and return the host instead """ host = self.host return host, port
def fxp_to(self, file, target, target_file=None, type='I'): """FXP (server-to-server-copy) a file between 2 servers.""" if not target_file: target_file = file type = 'TYPE ' + type self.voidcmd(type) target.voidcmd(type) if self.use_pret: self.voidcmd('PRET RETR ' + file) host, host_port = ftplib.parse227(self.sendcmd('PASV')) if target.use_pret: target.voidcmd('PRET STOR' + target_file) target.sendport(host, host_port) t_reply = target.sendcmd('STOR ' + target_file) if t_reply[:3] not in {'125', '150'}: raise ftplib.error_proto # RFC 959 reply = self.sendcmd('RETR ' + file) if reply[:3] not in {'125', '150'}: raise ftplib.error_proto # RFC 959 self.voidresp() target.voidresp()
def ftpcp(source, sourcename, target, targetname='', type='I'): """Copy file from one FTP-instance to another.""" if not targetname: targetname = sourcename type = 'TYPE ' + type source.voidcmd(type) target.voidcmd(type) sourcehost, sourceport = ftplib.parse227(source.sendcmd('PASV')) target.sendport(sourcehost, sourceport) # RFC 959: the user must "listen" [...] BEFORE sending the # transfer request. # So: STOR before RETR, because here the target is a "user". treply = target.sendcmd('STOR ' + targetname) if treply[:3] not in {'125', '150'}: raise ftplib.error_proto # RFC 959 sreply = source.sendcmd('RETR ' + sourcename) if sreply[:3] not in {'125', '150'}: raise ftplib.error_proto # RFC 959 source.voidresp() target.voidresp()
def update_event(self, inp=-1): self.set_output_val(0, ftplib.parse227(self.input(0)))