diff --git a/daemon.py b/daemon.py index 6eb73c27b..ceb5c2bfe 100644 --- a/daemon.py +++ b/daemon.py @@ -464,7 +464,7 @@ class PubServer(BaseHTTPRequestHandler): # The presence if these headers on their own indicates a MiTM mitm_headers = ( 'CF-Connecting-IP', 'CF-RAY', 'CF-IPCountry', 'CF-Visitor', - 'CDN-Loop', 'CF-Worker' + 'CDN-Loop', 'CF-Worker', 'CF-Cache-Status' ) for header_name in mitm_headers: if self.headers.get(header_name): @@ -13802,13 +13802,22 @@ class PubServer(BaseHTTPRequestHandler): self._404() return True - def _show_q_rcode(self, calling_domain: str, path: str, - base_dir: str, domain: str, port: int, - getreq_start_time) -> bool: + def _show_qrcode(self, calling_domain: str, path: str, + base_dir: str, domain: str, + onion_domain: str, i2p_domain: str, + port: int, getreq_start_time) -> bool: """Shows a QR code for an account """ nickname = get_nickname_from_actor(path) - save_person_qrcode(base_dir, nickname, domain, port) + if onion_domain: + qrcode_domain = onion_domain + port = 80 + elif i2p_domain: + qrcode_domain = i2p_domain + port = 80 + else: + qrcode_domain = domain + save_person_qrcode(base_dir, nickname, domain, qrcode_domain, port) qr_filename = \ acct_dir(base_dir, nickname, domain) + '/qrcode.png' if os.path.isfile(qr_filename): @@ -13825,7 +13834,7 @@ class PubServer(BaseHTTPRequestHandler): media_binary = av_file.read() break except BaseException as ex: - print('EX: _show_q_rcode ' + str(tries) + ' ' + str(ex)) + print('EX: _show_qrcode ' + str(tries) + ' ' + str(ex)) time.sleep(1) tries += 1 if media_binary: @@ -13837,7 +13846,7 @@ class PubServer(BaseHTTPRequestHandler): self._write(media_binary) fitness_performance(getreq_start_time, self.server.fitness, - '_GET', '_show_q_rcode', + '_GET', '_show_qrcode', self.server.debug) return True self._404() @@ -16143,11 +16152,13 @@ class PubServer(BaseHTTPRequestHandler): # QR code for account handle if users_in_path and \ self.path.endswith('/qrcode.png'): - if self._show_q_rcode(calling_domain, self.path, - self.server.base_dir, - self.server.domain, - self.server.port, - getreq_start_time): + if self._show_qrcode(calling_domain, self.path, + self.server.base_dir, + self.server.domain, + self.server.onion_domain, + self.server.i2p_domain, + self.server.port, + getreq_start_time): return fitness_performance(getreq_start_time, self.server.fitness, @@ -20633,7 +20644,12 @@ def run_daemon(crawlers_allowed: [], httpd.domain = domain httpd.port = port httpd.domain_full = get_full_domain(domain, port) - save_domain_qrcode(base_dir, http_prefix, httpd.domain_full) + if onion_domain: + save_domain_qrcode(base_dir, 'http', onion_domain) + elif i2p_domain: + save_domain_qrcode(base_dir, 'http', i2p_domain) + else: + save_domain_qrcode(base_dir, http_prefix, httpd.domain_full) httpd.http_prefix = http_prefix httpd.debug = debug httpd.federation_list = fed_list.copy() diff --git a/person.py b/person.py index c6ddc773c..0294b8a8a 100644 --- a/person.py +++ b/person.py @@ -582,15 +582,15 @@ def create_group(base_dir: str, nickname: str, domain: str, port: int, def save_person_qrcode(base_dir: str, - nickname: str, domain: str, port: int, - scale=6) -> None: + nickname: str, domain: str, qrcode_domain: str, + port: int, scale=6) -> None: """Saves a qrcode image for the handle of the person This helps to transfer onion or i2p handles to a mobile device """ qrcode_filename = acct_dir(base_dir, nickname, domain) + '/qrcode.png' if os.path.isfile(qrcode_filename): return - handle = get_full_domain('@' + nickname + '@' + domain, port) + handle = get_full_domain('@' + nickname + '@' + qrcode_domain, port) url = pyqrcode.create(handle) url.png(qrcode_filename, scale) @@ -707,7 +707,7 @@ def create_person(base_dir: str, nickname: str, domain: str, port: int, registrations_remaining -= 1 set_config_param(base_dir, 'registrationsRemaining', str(registrations_remaining)) - save_person_qrcode(base_dir, nickname, domain, port) + save_person_qrcode(base_dir, nickname, domain, domain, port) return private_key_pem, public_key_pem, new_person, webfinger_endpoint diff --git a/theme/blue/icons/qrcode.png b/theme/blue/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/blue/icons/qrcode.png and b/theme/blue/icons/qrcode.png differ diff --git a/theme/debian/icons/qrcode.png b/theme/debian/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/debian/icons/qrcode.png and b/theme/debian/icons/qrcode.png differ diff --git a/theme/default/icons/qrcode.png b/theme/default/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/default/icons/qrcode.png and b/theme/default/icons/qrcode.png differ diff --git a/theme/hacker/icons/qrcode.png b/theme/hacker/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/hacker/icons/qrcode.png and b/theme/hacker/icons/qrcode.png differ diff --git a/theme/henge/icons/qrcode.png b/theme/henge/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/henge/icons/qrcode.png and b/theme/henge/icons/qrcode.png differ diff --git a/theme/indymediaclassic/icons/qrcode.png b/theme/indymediaclassic/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/indymediaclassic/icons/qrcode.png and b/theme/indymediaclassic/icons/qrcode.png differ diff --git a/theme/indymediamodern/icons/qrcode.png b/theme/indymediamodern/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/indymediamodern/icons/qrcode.png and b/theme/indymediamodern/icons/qrcode.png differ diff --git a/theme/lcd/icons/qrcode.png b/theme/lcd/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/lcd/icons/qrcode.png and b/theme/lcd/icons/qrcode.png differ diff --git a/theme/light/icons/qrcode.png b/theme/light/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/light/icons/qrcode.png and b/theme/light/icons/qrcode.png differ diff --git a/theme/night/icons/qrcode.png b/theme/night/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/night/icons/qrcode.png and b/theme/night/icons/qrcode.png differ diff --git a/theme/pixel/icons/qrcode.png b/theme/pixel/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/pixel/icons/qrcode.png and b/theme/pixel/icons/qrcode.png differ diff --git a/theme/purple/icons/qrcode.png b/theme/purple/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/purple/icons/qrcode.png and b/theme/purple/icons/qrcode.png differ diff --git a/theme/rc3/icons/qrcode.png b/theme/rc3/icons/qrcode.png index 933a2671c..a59fe9a03 100644 Binary files a/theme/rc3/icons/qrcode.png and b/theme/rc3/icons/qrcode.png differ diff --git a/theme/solidaric/icons/qrcode.png b/theme/solidaric/icons/qrcode.png index 933a2671c..561ad14ff 100644 Binary files a/theme/solidaric/icons/qrcode.png and b/theme/solidaric/icons/qrcode.png differ diff --git a/theme/starlight/icons/qrcode.png b/theme/starlight/icons/qrcode.png index 933a2671c..d9bbd5b89 100644 Binary files a/theme/starlight/icons/qrcode.png and b/theme/starlight/icons/qrcode.png differ diff --git a/theme/zen/icons/qrcode.png b/theme/zen/icons/qrcode.png index 933a2671c..71c2450c3 100644 Binary files a/theme/zen/icons/qrcode.png and b/theme/zen/icons/qrcode.png differ