diff --git a/copyparty/__main__.py b/copyparty/__main__.py index c2daf91c..97a2b178 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1521,6 +1521,7 @@ def add_ftp(ap): ap2.add_argument("--ftp-wt", metavar="SEC", type=int, default=7, help="grace period for resuming interrupted uploads (any client can write to any file last-modified more recently than \033[33mSEC\033[0m seconds ago)") ap2.add_argument("--ftp-nat", metavar="ADDR", type=u, default="", help="the NAT address to use for passive connections") ap2.add_argument("--ftp-pr", metavar="P-P", type=u, default="", help="the range of TCP ports to use for passive connections, for example \033[32m12000-13000") + ap2.add_argument("--ftp-banner", metavar="T", type=u, default="welcome to the party", help="bannertext to send when someone connects; \\n is newline, can be @filepath (loaded into memory on startup); if it has a newline then banner must be longer than 75 chars") def add_webdav(ap): diff --git a/copyparty/ftpd.py b/copyparty/ftpd.py index ccbd423c..0cdc2c33 100644 --- a/copyparty/ftpd.py +++ b/copyparty/ftpd.py @@ -28,6 +28,7 @@ from .util import ( fsenc, ipnorm, pybin, + read_utf8, relchk, runhook, sanitize_fn, @@ -624,11 +625,17 @@ class Ftpd(object): hs.append([h1, self.args.ftps]) + zs = self.args.ftp_banner.replace("\\n", "\n") + if zs.startswith("@"): + zs = read_utf8(None, zs[1:], False) + banner = zs.replace("\r", "").replace("\n", "\r\n").strip() + for h_lp in hs: h2, lp = h_lp FtpHandler.hub = h2.hub = hub FtpHandler.args = h2.args = hub.args FtpHandler.authorizer = h2.authorizer = FtpAuth(hub) + FtpHandler.banner = banner if self.args.ftp_pr: p1, p2 = [int(x) for x in self.args.ftp_pr.split("-")]