From 54caf63f6aab9198d0e2038da38b2d7b0622bffc Mon Sep 17 00:00:00 2001
From: ed
Date: Thu, 7 Aug 2025 15:18:59 +0000
Subject: [PATCH] optimize
---
copyparty/__main__.py | 4 ++--
copyparty/httpcli.py | 13 +++++--------
copyparty/multicast.py | 6 +-----
copyparty/svchub.py | 2 +-
4 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/copyparty/__main__.py b/copyparty/__main__.py
index 86b6b031..eb44ef4f 100644
--- a/copyparty/__main__.py
+++ b/copyparty/__main__.py
@@ -536,7 +536,7 @@ def get_sects():
dedent(
"""
\033[33m-i\033[0m takes a comma-separated list of interfaces to listen on;
- IP-addresses, unix-sockets and/or open file descriptors
+ IP-addresses, unix-sockets, and/or open file descriptors
the default (\033[32m-i ::\033[0m) means all IPv4 and IPv6 addresses
@@ -564,7 +564,7 @@ def get_sects():
\033[32m-i fd:\033[33m3\033[0m uses the socket passed to copyparty on file descriptor 3
- \033[33m-p\033[0m (tcp ports) is ignored for non ip-addresses
+ \033[33m-p\033[0m (tcp ports) is ignored for unix-sockets and FDs
"""
),
],
diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py
index b335fe4a..c982a812 100644
--- a/copyparty/httpcli.py
+++ b/copyparty/httpcli.py
@@ -262,7 +262,8 @@ class HttpCli(object):
def _assert_safe_rem(self, rem: str) -> None:
# sanity check to prevent any disasters
- if rem.startswith("/") or rem.startswith("../") or "/../" in rem:
+ # (this function hopefully serves no purpose; validation has already happened at this point, this only exists as a last-ditch effort just in case)
+ if rem.startswith(("/", "../")) or "/../" in rem:
raise Exception("that was close")
def _gen_fk(self, alg: int, salt: str, fspath: str, fsize: int, inode: int) -> str:
@@ -5031,7 +5032,7 @@ class HttpCli(object):
wvol = [x for x in wvol if "unlistcw" not in allvols[x[1:-1]].flags]
fmt = self.uparam.get("ls", "")
- if not fmt and (self.ua.startswith("curl/") or self.ua.startswith("fetch")):
+ if not fmt and self.ua.startswith(("curl/", "fetch")):
fmt = "v"
if fmt in ["v", "t", "txt"]:
@@ -5141,7 +5142,7 @@ class HttpCli(object):
t = '404 not found ┐( ´ -`)┌