Skip to content

Add environment variable to configure max connection by ip #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## -*- docker-image-name: "mauler/simple-ftp-server" -*-

FROM python:slim
MAINTAINER Paulo <[email protected]>
MAINTAINER EURANOVA <[email protected]>

ENV FTP_ROOT /ftp-home
ENV FTP_USER ftp
Expand Down
7 changes: 5 additions & 2 deletions image/root/bin/simple-ftp-server
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

import logging

def main():
# Instantiate a dummy authorizer for managing 'virtual' users
authorizer = DummyAuthorizer()
LOGLEVEL = environ.get('LOGLEVEL', 'WARNING').upper()
logging.basicConfig(level=LOGLEVEL)

# Define a new user having full r/w permissions and a read-only
# anonymous user
Expand All @@ -26,7 +29,7 @@ def main():

# Specify a masquerade address and the range of ports to use for
# passive connections. Decomment in case you're behind a NAT.
# handler.masquerade_address = '151.25.42.11'
# handler.masquerade_address = environ.get('FTP_MASQUERADE_ADDRESS', None)
# handler.passive_ports = range(60000, 65535)

# Instantiate FTP server class and listen on 0.0.0.0:2121
Expand All @@ -35,7 +38,7 @@ def main():

# set a limit for connections
server.max_cons = 256
server.max_cons_per_ip = 5
server.max_cons_per_ip = int(environ.get('FTP_MAX_CONS_PER_IP', '50'))

# start ftp server
server.serve_forever()
Expand Down