From 10caafa34c2c3b6c719c4ead6ff4f96c4ca2aea6 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 11 Jun 2023 08:14:45 +0000 Subject: [PATCH] v1.7.6 --- copyparty/__version__.py | 2 +- copyparty/cert.py | 15 +++++++-------- copyparty/svchub.py | 26 +++++++++++++++++++++++++- copyparty/tcpsrv.py | 3 ++- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/copyparty/__version__.py b/copyparty/__version__.py index c506c727..d3087999 100644 --- a/copyparty/__version__.py +++ b/copyparty/__version__.py @@ -1,6 +1,6 @@ # coding: utf-8 -VERSION = (1, 7, 5) +VERSION = (1, 7, 6) CODENAME = "unlinked" BUILD_DT = (2023, 6, 11) diff --git a/copyparty/cert.py b/copyparty/cert.py index 6232734a..a6c28132 100644 --- a/copyparty/cert.py +++ b/copyparty/cert.py @@ -1,13 +1,12 @@ -import os -import errno -import time -import json -import shutil -import filecmp import calendar +import errno +import filecmp +import json +import os +import shutil +import time -from .util import runcmd, Netdev - +from .util import Netdev, runcmd HAVE_CFSSL = True diff --git a/copyparty/svchub.py b/copyparty/svchub.py index c5f70372..e2d7b9bf 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -30,6 +30,7 @@ if True: # pylint: disable=using-constant-test from .__init__ import ANYWIN, EXE, MACOS, TYPE_CHECKING, EnvParams, unicode from .authsrv import AuthSrv +from .cert import ensure_cert from .mtag import HAVE_FFMPEG, HAVE_FFPROBE from .tcpsrv import TcpSrv from .th_srv import HAVE_PIL, HAVE_VIPS, HAVE_WEBP, ThumbSrv @@ -239,7 +240,8 @@ class SvcHub(object): if args.ftp or args.ftps: from .ftpd import Ftpd - self.ftpd = Ftpd(self) + self.ftpd: Optional[Ftpd] = None + Daemon(self.start_ftpd, "start_ftpd") zms += "f" if args.ftp else "F" if args.smb: @@ -269,6 +271,28 @@ class SvcHub(object): self.broker = Broker(self) + def start_ftpd(self) -> None: + time.sleep(30) + if self.ftpd: + return + + self.restart_ftpd() + + def restart_ftpd(self) -> None: + if not hasattr(self, "ftpd"): + return + + from .ftpd import Ftpd + + if self.ftpd: + return # todo + + if not os.path.exists(self.args.cert): + ensure_cert(self.log, self.args) + + self.ftpd = Ftpd(self) + self.log("root", "started FTPd") + def thr_httpsrv_up(self) -> None: time.sleep(1 if self.args.ign_ebind_all else 5) expected = self.broker.num_workers * self.tcpsrv.nsrv diff --git a/copyparty/tcpsrv.py b/copyparty/tcpsrv.py index 2077d116..e2f50c02 100644 --- a/copyparty/tcpsrv.py +++ b/copyparty/tcpsrv.py @@ -8,8 +8,8 @@ import sys import time from .__init__ import ANYWIN, PY2, TYPE_CHECKING, unicode -from .stolen.qrcodegen import QrCode from .cert import gencert +from .stolen.qrcodegen import QrCode from .util import ( E_ACCESS, E_ADDR_IN_USE, @@ -297,6 +297,7 @@ class TcpSrv(object): self.hub.broker.say("set_netdevs", self.netdevs) self.hub.start_zeroconf() gencert(self.log, self.args, self.netdevs) + self.hub.restart_ftpd() def shutdown(self) -> None: self.stopping = True