Merge ~ines-almeida/txpkgupload:allow-setting-passive-port-range into txpkgupload:master

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: 30041281095334e3a15803b9963309e78f90dd16
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/txpkgupload:allow-setting-passive-port-range
Merge into: txpkgupload:master
Diff against target: 68 lines (+29/-4)
2 files modified
src/txpkgupload/plugin.py (+4/-1)
src/txpkgupload/twistedftp.py (+25/-3)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+452960@code.launchpad.net

Commit message

Update twisted and txpkgupload to allow a passive port range config

The port range is used to get a DTP port within the range. This would allow one to restrict which ports it can connect to.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/txpkgupload/plugin.py b/src/txpkgupload/plugin.py
index b78923c..32ede15 100644
--- a/src/txpkgupload/plugin.py
+++ b/src/txpkgupload/plugin.py
@@ -244,7 +244,10 @@ class PkgUploadServiceMaker:
244 port=ftp_config["port"],244 port=ftp_config["port"],
245 root=root,245 root=root,
246 temp_dir=temp_dir,246 temp_dir=temp_dir,
247 idle_timeout=config["idle_timeout"])247 idle_timeout=config["idle_timeout"],
248 min_passive_port=config.get("min_passive_port"),
249 max_passive_port=config.get("max_passive_port"),
250 )
248 ftp_service.name = "ftp"251 ftp_service.name = "ftp"
249 ftp_service.setServiceParent(services)252 ftp_service.setServiceParent(services)
250253
diff --git a/src/txpkgupload/twistedftp.py b/src/txpkgupload/twistedftp.py
index 995fa08..4c019b6 100644
--- a/src/txpkgupload/twistedftp.py
+++ b/src/txpkgupload/twistedftp.py
@@ -360,7 +360,15 @@ class FTPWithEPSV(ftp.FTP):
360class FTPServiceFactory(service.Service):360class FTPServiceFactory(service.Service):
361 """A factory that makes an `FTPService`"""361 """A factory that makes an `FTPService`"""
362362
363 def __init__(self, port, root, temp_dir, idle_timeout):363 def __init__(
364 self,
365 port,
366 root,
367 temp_dir,
368 idle_timeout,
369 min_passive_port,
370 max_passive_port,
371 ):
364 realm = FTPRealm(root, temp_dir)372 realm = FTPRealm(root, temp_dir)
365 portal = Portal(realm)373 portal = Portal(realm)
366 portal.registerChecker(AccessCheck())374 portal.registerChecker(AccessCheck())
@@ -371,14 +379,28 @@ class FTPServiceFactory(service.Service):
371 factory.welcomeMessage = "Launchpad upload server"379 factory.welcomeMessage = "Launchpad upload server"
372 factory.timeOut = idle_timeout380 factory.timeOut = idle_timeout
373381
382 if min_passive_port and max_passive_port:
383 factory.passivePortRange = range(
384 min_passive_port, max_passive_port
385 )
386
374 self.ftpfactory = factory387 self.ftpfactory = factory
375 self.portno = port388 self.portno = port
376389
377 @staticmethod390 @staticmethod
378 def makeFTPService(port, root, temp_dir, idle_timeout):391 def makeFTPService(
392 port, root, temp_dir, idle_timeout, min_passive_port, max_passive_port
393 ):
379 if port.isdigit():394 if port.isdigit():
380 strport = "tcp6:%s" % port395 strport = "tcp6:%s" % port
381 else:396 else:
382 strport = port397 strport = port
383 factory = FTPServiceFactory(port, root, temp_dir, idle_timeout)398 factory = FTPServiceFactory(
399 port,
400 root,
401 temp_dir,
402 idle_timeout,
403 min_passive_port,
404 max_passive_port,
405 )
384 return strports.service(strport, factory.ftpfactory)406 return strports.service(strport, factory.ftpfactory)

Subscribers

People subscribed via source and target branches

to all changes: