From bf5850785f77cfb7f6c7a67d18d12ef93730fcb0 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 18 Apr 2024 17:16:00 +0000 Subject: [PATCH] add opt-out from storing uploader IPs --- copyparty/__main__.py | 1 + copyparty/up2k.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 4f02dd69..4e72447b 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1091,6 +1091,7 @@ def add_optouts(ap): ap2.add_argument("--no-zip", action="store_true", help="disable download as zip/tar") ap2.add_argument("--no-tarcmp", action="store_true", help="disable download as compressed tar (?tar=gz, ?tar=bz2, ?tar=xz, ?tar=gz:9, ...)") ap2.add_argument("--no-lifetime", action="store_true", help="do not allow clients (or server config) to schedule an upload to be deleted after a given time") + ap2.add_argument("--no-db-ip", action="store_true", help="do not write uploader IPs into the database") def add_safety(ap): diff --git a/copyparty/up2k.py b/copyparty/up2k.py index e9b13197..21df9559 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -3240,14 +3240,20 @@ class Up2k(object): """mutex(main) me""" self.db_rm(db, rd, fn, sz) + if not ip: + db_ip = "" + else: + # plugins may expect this to look like an actual IP + db_ip = "1.1.1.1" if self.args.no_db_ip else ip + sql = "insert into up values (?,?,?,?,?,?,?)" - v = (wark, int(ts), sz, rd, fn, ip or "", int(at or 0)) + v = (wark, int(ts), sz, rd, fn, db_ip, int(at or 0)) try: db.execute(sql, v) except: assert self.mem_cur rd, fn = s3enc(self.mem_cur, rd, fn) - v = (wark, int(ts), sz, rd, fn, ip or "", int(at or 0)) + v = (wark, int(ts), sz, rd, fn, db_ip, int(at or 0)) db.execute(sql, v) self.volsize[db] += sz