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
1diff --git a/src/txpkgupload/plugin.py b/src/txpkgupload/plugin.py
2index b78923c..32ede15 100644
3--- a/src/txpkgupload/plugin.py
4+++ b/src/txpkgupload/plugin.py
5@@ -244,7 +244,10 @@ class PkgUploadServiceMaker:
6 port=ftp_config["port"],
7 root=root,
8 temp_dir=temp_dir,
9- idle_timeout=config["idle_timeout"])
10+ idle_timeout=config["idle_timeout"],
11+ min_passive_port=config.get("min_passive_port"),
12+ max_passive_port=config.get("max_passive_port"),
13+ )
14 ftp_service.name = "ftp"
15 ftp_service.setServiceParent(services)
16
17diff --git a/src/txpkgupload/twistedftp.py b/src/txpkgupload/twistedftp.py
18index 995fa08..4c019b6 100644
19--- a/src/txpkgupload/twistedftp.py
20+++ b/src/txpkgupload/twistedftp.py
21@@ -360,7 +360,15 @@ class FTPWithEPSV(ftp.FTP):
22 class FTPServiceFactory(service.Service):
23 """A factory that makes an `FTPService`"""
24
25- def __init__(self, port, root, temp_dir, idle_timeout):
26+ def __init__(
27+ self,
28+ port,
29+ root,
30+ temp_dir,
31+ idle_timeout,
32+ min_passive_port,
33+ max_passive_port,
34+ ):
35 realm = FTPRealm(root, temp_dir)
36 portal = Portal(realm)
37 portal.registerChecker(AccessCheck())
38@@ -371,14 +379,28 @@ class FTPServiceFactory(service.Service):
39 factory.welcomeMessage = "Launchpad upload server"
40 factory.timeOut = idle_timeout
41
42+ if min_passive_port and max_passive_port:
43+ factory.passivePortRange = range(
44+ min_passive_port, max_passive_port
45+ )
46+
47 self.ftpfactory = factory
48 self.portno = port
49
50 @staticmethod
51- def makeFTPService(port, root, temp_dir, idle_timeout):
52+ def makeFTPService(
53+ port, root, temp_dir, idle_timeout, min_passive_port, max_passive_port
54+ ):
55 if port.isdigit():
56 strport = "tcp6:%s" % port
57 else:
58 strport = port
59- factory = FTPServiceFactory(port, root, temp_dir, idle_timeout)
60+ factory = FTPServiceFactory(
61+ port,
62+ root,
63+ temp_dir,
64+ idle_timeout,
65+ min_passive_port,
66+ max_passive_port,
67+ )
68 return strports.service(strport, factory.ftpfactory)

Subscribers

People subscribed via source and target branches

to all changes: