diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 0ca8387b..df491c67 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1049,7 +1049,7 @@ def add_network(ap): ap2.add_argument("--rp-loc", metavar="PATH", type=u, default="", help="if reverse-proxying on a location instead of a dedicated domain/subdomain, provide the base location here; example: [\033[32m/foo/bar\033[0m]") if ANYWIN: ap2.add_argument("--reuseaddr", action="store_true", help="set reuseaddr on listening sockets on windows; allows rapid restart of copyparty at the expense of being able to accidentally start multiple instances") - else: + elif not MACOS: ap2.add_argument("--freebind", action="store_true", help="allow listening on IPs which do not yet exist, for example if the network interfaces haven't finished going up. Only makes sense for IPs other than '0.0.0.0', '127.0.0.1', '::', and '::1'. May require running as root (unless net.ipv6.ip_nonlocal_bind)") ap2.add_argument("--wr-h-eps", metavar="PATH", type=u, default="", help="write list of listening-on ip:port to textfile at \033[33mPATH\033[0m when http-servers have started") ap2.add_argument("--wr-h-aon", metavar="PATH", type=u, default="", help="write list of accessible-on ip:port to textfile at \033[33mPATH\033[0m when http-servers have started") diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index f47c8fe8..d2378413 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -45,6 +45,7 @@ from .util import ( APPLESAN_RE, BITNESS, DAV_ALLPROPS, + E_SCK_WR, FN_EMB, HAVE_SQLITE3, HTTPCODE, @@ -4365,7 +4366,7 @@ class HttpCli(object): self.log("file deleted; disconnecting") break except IOError as ex: - if ex.errno not in (errno.EPIPE, errno.ESHUTDOWN, errno.EBADFD): + if ex.errno not in E_SCK_WR: raise finally: if f: diff --git a/copyparty/tcpsrv.py b/copyparty/tcpsrv.py index d344dfb9..65f343d0 100644 --- a/copyparty/tcpsrv.py +++ b/copyparty/tcpsrv.py @@ -282,7 +282,7 @@ class TcpSrv(object): except: pass # will create another ipv4 socket instead - if not ANYWIN and self.args.freebind: + if getattr(self.args, "freebind", False): srv.setsockopt(socket.SOL_IP, socket.IP_FREEBIND, 1) try: diff --git a/copyparty/util.py b/copyparty/util.py index f877ea9d..64be2d13 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -105,6 +105,7 @@ def _ens(want: str) -> tuple[int, ...]: # WSAENOTSOCK - no longer a socket # EUNATCH - can't assign requested address (wifi down) E_SCK = _ens("ENOTCONN EUNATCH EBADF WSAENOTSOCK WSAECONNRESET") +E_SCK_WR = _ens("EPIPE ESHUTDOWN EBADFD") E_ADDR_NOT_AVAIL = _ens("EADDRNOTAVAIL WSAEADDRNOTAVAIL") E_ADDR_IN_USE = _ens("EADDRINUSE WSAEADDRINUSE") E_ACCESS = _ens("EACCES WSAEACCES")