mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
logging fixes
This commit is contained in:
parent
91d132c2b4
commit
cd2513ec16
|
@ -678,7 +678,7 @@ def run_argparse(
|
||||||
ap2 = ap.add_argument_group('FTP options')
|
ap2 = ap.add_argument_group('FTP options')
|
||||||
ap2.add_argument("--ftp", metavar="PORT", type=int, help="enable FTP server on PORT, for example \033[32m3921")
|
ap2.add_argument("--ftp", metavar="PORT", type=int, help="enable FTP server on PORT, for example \033[32m3921")
|
||||||
ap2.add_argument("--ftps", metavar="PORT", type=int, help="enable FTPS server on PORT, for example \033[32m3990")
|
ap2.add_argument("--ftps", metavar="PORT", type=int, help="enable FTPS server on PORT, for example \033[32m3990")
|
||||||
ap2.add_argument("--ftp-dbg", action="store_true", help="enable debug logging")
|
ap2.add_argument("--ftpv", action="store_true", help="verbose")
|
||||||
ap2.add_argument("--ftp-nat", metavar="ADDR", type=u, help="the NAT address to use for passive connections")
|
ap2.add_argument("--ftp-nat", metavar="ADDR", type=u, help="the NAT address to use for passive connections")
|
||||||
ap2.add_argument("--ftp-pr", metavar="P-P", type=u, help="the range of TCP ports to use for passive connections, for example \033[32m12000-13000")
|
ap2.add_argument("--ftp-pr", metavar="P-P", type=u, help="the range of TCP ports to use for passive connections, for example \033[32m12000-13000")
|
||||||
|
|
||||||
|
@ -692,8 +692,10 @@ def run_argparse(
|
||||||
ap2.add_argument("--smbw", action="store_true", help="enable write support (please dont)")
|
ap2.add_argument("--smbw", action="store_true", help="enable write support (please dont)")
|
||||||
ap2.add_argument("--smb1", action="store_true", help="disable SMBv2, only enable SMBv1 (CIFS)")
|
ap2.add_argument("--smb1", action="store_true", help="disable SMBv2, only enable SMBv1 (CIFS)")
|
||||||
ap2.add_argument("--smb-port", metavar="PORT", type=int, default=445, help="port to listen on -- if you change this value, you must NAT from TCP:445 to this port using iptables or similar")
|
ap2.add_argument("--smb-port", metavar="PORT", type=int, default=445, help="port to listen on -- if you change this value, you must NAT from TCP:445 to this port using iptables or similar")
|
||||||
ap2.add_argument("--smb-dbg", action="store_true", help="show debug messages")
|
|
||||||
ap2.add_argument("--smb-nwa-1", action="store_true", help="disable impacket#1433 workaround (truncate directory listings to 64kB)")
|
ap2.add_argument("--smb-nwa-1", action="store_true", help="disable impacket#1433 workaround (truncate directory listings to 64kB)")
|
||||||
|
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")
|
||||||
|
|
||||||
ap2 = ap.add_argument_group('opt-outs')
|
ap2 = ap.add_argument_group('opt-outs')
|
||||||
ap2.add_argument("-nw", action="store_true", help="never write anything to disk (debug/benchmark)")
|
ap2.add_argument("-nw", action="store_true", help="never write anything to disk (debug/benchmark)")
|
||||||
|
|
|
@ -401,7 +401,7 @@ class Ftpd(object):
|
||||||
h2.masquerade_address = self.args.ftp_nat
|
h2.masquerade_address = self.args.ftp_nat
|
||||||
|
|
||||||
lgr = logging.getLogger("pyftpdlib")
|
lgr = logging.getLogger("pyftpdlib")
|
||||||
lgr.setLevel(logging.DEBUG if self.args.ftp_dbg else logging.INFO)
|
lgr.setLevel(logging.DEBUG if self.args.ftpv else logging.INFO)
|
||||||
|
|
||||||
ioloop = IOLoop()
|
ioloop = IOLoop()
|
||||||
for ip in self.args.i:
|
for ip in self.args.i:
|
||||||
|
|
|
@ -185,7 +185,8 @@ class MCast(object):
|
||||||
sck = srv.sck
|
sck = srv.sck
|
||||||
if srv.v6:
|
if srv.v6:
|
||||||
if self.args.zmv:
|
if self.args.zmv:
|
||||||
self.log("v6({}) idx({}) {}".format(srv.ip, srv.idx, srv.ips), 6)
|
zsl = list(srv.ips.keys())
|
||||||
|
self.log("v6({}) idx({}) {}".format(srv.ip, srv.idx, zsl), 6)
|
||||||
|
|
||||||
for ip in srv.ips:
|
for ip in srv.ips:
|
||||||
bip = socket.inet_pton(socket.AF_INET6, ip)
|
bip = socket.inet_pton(socket.AF_INET6, ip)
|
||||||
|
|
|
@ -21,6 +21,10 @@ if TYPE_CHECKING:
|
||||||
from .svchub import SvcHub
|
from .svchub import SvcHub
|
||||||
|
|
||||||
|
|
||||||
|
lg = logging.getLogger("smb")
|
||||||
|
debug, info, warning, error = (lg.debug, lg.info, lg.warning, lg.error)
|
||||||
|
|
||||||
|
|
||||||
class SMB(object):
|
class SMB(object):
|
||||||
def __init__(self, hub: "SvcHub") -> None:
|
def __init__(self, hub: "SvcHub") -> None:
|
||||||
self.hub = hub
|
self.hub = hub
|
||||||
|
@ -29,9 +33,10 @@ class SMB(object):
|
||||||
self.log = hub.log
|
self.log = hub.log
|
||||||
self.files: dict[int, tuple[float, str]] = {}
|
self.files: dict[int, tuple[float, str]] = {}
|
||||||
|
|
||||||
|
lg.setLevel(logging.DEBUG if self.args.smbvvv else logging.INFO)
|
||||||
for x in ["impacket", "impacket.smbserver"]:
|
for x in ["impacket", "impacket.smbserver"]:
|
||||||
lgr = logging.getLogger(x)
|
lgr = logging.getLogger(x)
|
||||||
lgr.setLevel(logging.DEBUG if self.args.smb_dbg else logging.INFO)
|
lgr.setLevel(logging.DEBUG if self.args.smbvv else logging.INFO)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from impacket import smbserver
|
from impacket import smbserver
|
||||||
|
@ -109,7 +114,7 @@ class SMB(object):
|
||||||
# cf = inspect.currentframe().f_back
|
# cf = inspect.currentframe().f_back
|
||||||
# c1 = cf.f_back.f_code.co_name
|
# c1 = cf.f_back.f_code.co_name
|
||||||
# c2 = cf.f_code.co_name
|
# c2 = cf.f_code.co_name
|
||||||
logging.debug('%s("%s", %s)\033[K\033[0m', caller, vpath, str(a))
|
debug('%s("%s", %s)\033[K\033[0m', caller, vpath, str(a))
|
||||||
|
|
||||||
# TODO find a way to grab `identity` in smbComSessionSetupAndX and smb2SessionSetup
|
# TODO find a way to grab `identity` in smbComSessionSetupAndX and smb2SessionSetup
|
||||||
vfs, rem = self.asrv.vfs.get(vpath, LEELOO_DALLAS, True, True)
|
vfs, rem = self.asrv.vfs.get(vpath, LEELOO_DALLAS, True, True)
|
||||||
|
@ -118,7 +123,7 @@ class SMB(object):
|
||||||
def _listdir(self, vpath: str, *a: Any, **ka: Any) -> list[str]:
|
def _listdir(self, vpath: str, *a: Any, **ka: Any) -> list[str]:
|
||||||
vpath = vpath.replace("\\", "/").lstrip("/")
|
vpath = vpath.replace("\\", "/").lstrip("/")
|
||||||
# caller = inspect.currentframe().f_back.f_code.co_name
|
# caller = inspect.currentframe().f_back.f_code.co_name
|
||||||
logging.debug('listdir("%s", %s)\033[K\033[0m', vpath, str(a))
|
debug('listdir("%s", %s)\033[K\033[0m', vpath, str(a))
|
||||||
vfs, rem = self.asrv.vfs.get(vpath, LEELOO_DALLAS, False, False)
|
vfs, rem = self.asrv.vfs.get(vpath, LEELOO_DALLAS, False, False)
|
||||||
_, vfs_ls, vfs_virt = vfs.ls(
|
_, vfs_ls, vfs_virt = vfs.ls(
|
||||||
rem, LEELOO_DALLAS, not self.args.no_scandir, [[False, False]]
|
rem, LEELOO_DALLAS, not self.args.no_scandir, [[False, False]]
|
||||||
|
@ -135,7 +140,7 @@ class SMB(object):
|
||||||
for n, fn in enumerate(ls):
|
for n, fn in enumerate(ls):
|
||||||
if sz >= 64000:
|
if sz >= 64000:
|
||||||
t = "listing only %d of %d files (%d byte); see impacket#1433"
|
t = "listing only %d of %d files (%d byte); see impacket#1433"
|
||||||
logging.warning(t, n, len(ls), sz)
|
warning(t, n, len(ls), sz)
|
||||||
break
|
break
|
||||||
|
|
||||||
nsz = len(fn.encode("utf-16", "replace"))
|
nsz = len(fn.encode("utf-16", "replace"))
|
||||||
|
@ -168,7 +173,7 @@ class SMB(object):
|
||||||
oldest = min([x[0] for x in self.files.values()])
|
oldest = min([x[0] for x in self.files.values()])
|
||||||
cutoff = oldest + (now - oldest) / 2
|
cutoff = oldest + (now - oldest) / 2
|
||||||
self.files = {k: v for k, v in self.files.items() if v[0] > cutoff}
|
self.files = {k: v for k, v in self.files.items() if v[0] > cutoff}
|
||||||
logging.info("was tracking %d files, now %d", nf, len(self.files))
|
info("was tracking %d files, now %d", nf, len(self.files))
|
||||||
|
|
||||||
vpath = vpath.replace("\\", "/").lstrip("/")
|
vpath = vpath.replace("\\", "/").lstrip("/")
|
||||||
self.files[ret] = (now, vpath)
|
self.files[ret] = (now, vpath)
|
||||||
|
@ -269,7 +274,7 @@ class SMB(object):
|
||||||
|
|
||||||
def _hook(self, *a: Any, **ka: Any) -> None:
|
def _hook(self, *a: Any, **ka: Any) -> None:
|
||||||
src = inspect.currentframe().f_back.f_code.co_name
|
src = inspect.currentframe().f_back.f_code.co_name
|
||||||
logging.error("\033[31m%s:hook(%s)\033[0m", src, a)
|
error("\033[31m%s:hook(%s)\033[0m", src, a)
|
||||||
raise Exception("nope")
|
raise Exception("nope")
|
||||||
|
|
||||||
def _disarm(self) -> None:
|
def _disarm(self) -> None:
|
||||||
|
@ -303,5 +308,5 @@ class SMB(object):
|
||||||
|
|
||||||
|
|
||||||
def yeet(msg: str) -> None:
|
def yeet(msg: str) -> None:
|
||||||
logging.info(msg)
|
info(msg)
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SvcHub(object):
|
||||||
lg = logging.getLogger()
|
lg = logging.getLogger()
|
||||||
lh = HLog(self.log)
|
lh = HLog(self.log)
|
||||||
lg.handlers = [lh]
|
lg.handlers = [lh]
|
||||||
lg.setLevel(logging.INFO)
|
lg.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
if args.stackmon:
|
if args.stackmon:
|
||||||
start_stackmon(args.stackmon, 0)
|
start_stackmon(args.stackmon, 0)
|
||||||
|
|
|
@ -125,6 +125,9 @@ class TcpSrv(object):
|
||||||
title_vars = [x[1:] for x in self.args.wintitle.split(" ") if x.startswith("$")]
|
title_vars = [x[1:] for x in self.args.wintitle.split(" ") if x.startswith("$")]
|
||||||
t = "available @ {}://{}:{}/ (\033[33m{}\033[0m)"
|
t = "available @ {}://{}:{}/ (\033[33m{}\033[0m)"
|
||||||
for ip, desc in sorted(eps.items(), key=lambda x: x[1]):
|
for ip, desc in sorted(eps.items(), key=lambda x: x[1]):
|
||||||
|
if ip.startswith("fe80"):
|
||||||
|
continue
|
||||||
|
|
||||||
for port in sorted(self.args.p):
|
for port in sorted(self.args.p):
|
||||||
if (
|
if (
|
||||||
port not in ok.get(ip, [])
|
port not in ok.get(ip, [])
|
||||||
|
|
|
@ -179,7 +179,9 @@ IMPLICATIONS = [
|
||||||
["e2v", "e2d"],
|
["e2v", "e2d"],
|
||||||
["smbw", "smb"],
|
["smbw", "smb"],
|
||||||
["smb1", "smb"],
|
["smb1", "smb"],
|
||||||
["smb_dbg", "smb"],
|
["smbvvv", "smbvv"],
|
||||||
|
["smbvv", "smbv"],
|
||||||
|
["smbv", "smb"],
|
||||||
["zmvv", "zmv"],
|
["zmvv", "zmv"],
|
||||||
["zmv", "zm"],
|
["zmv", "zm"],
|
||||||
["zms", "zm"],
|
["zms", "zm"],
|
||||||
|
|
Loading…
Reference in a new issue