From a5d859d2b18f53ccf236bc6229856f79139d531c Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 11 Apr 2026 00:17:05 +0000 Subject: [PATCH] smb: add ipv6 support; closes #1417 --- copyparty/__main__.py | 1 + copyparty/smbd.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 286e358f..727404f1 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1520,6 +1520,7 @@ def add_smb(ap): ap2.add_argument("--smb-nwa-1", action="store_true", help="truncate directory listings to 64kB (~400 files); avoids impacket-0.11 bug, fixes impacket-0.12 performance") ap2.add_argument("--smb-nwa-2", action="store_true", help="disable impacket workaround for filecopy globs") ap2.add_argument("--smba", action="store_true", help="small performance boost: disable per-account permissions, enables account coalescing instead (if one user has write/delete-access, then everyone does)") + ap2.add_argument("--smb6", action="store_true", help="enable IPv6") ap2.add_argument("--smbv", action="store_true", help="verbose") ap2.add_argument("--smbvv", action="store_true", help="verboser") ap2.add_argument("--smbvvv", action="store_true", help="verbosest") diff --git a/copyparty/smbd.py b/copyparty/smbd.py index e0ca920c..3ae41091 100644 --- a/copyparty/smbd.py +++ b/copyparty/smbd.py @@ -89,13 +89,15 @@ class SMB(object): smbserver.isInFileJail = self._is_in_file_jail self._disarm() - ip = next((x for x in self.args.smb_i if ":" not in x), None) + zs = " " if self.args.smb6 else ":" + ip = next((x for x in self.args.smb_i if zs not in x), None) if not ip: - self.log("smb", "IPv6 not supported for SMB; listening on 0.0.0.0", 3) + self.log("smb", "IPv6 not enabled with --smb6; listening on 0.0.0.0", 3) ip = "0.0.0.0" port = int(self.args.smb_port) - srv = smbserver.SimpleSMBServer(listenAddress=ip, listenPort=port) + kw = {"ipv6": True} if ":" in ip else {} + srv = smbserver.SimpleSMBServer(listenAddress=ip, listenPort=port, **kw) try: if self.accs: srv.setAuthCallback(self._auth_cb) @@ -121,6 +123,7 @@ class SMB(object): self.srv = srv self.stop = srv.stop + ip = "[%s]" % (ip,) if kw else ip self.log("smb", "listening @ {}:{}".format(ip, port)) def nlog(self, msg: str, c: Union[int, str] = 0) -> None: