From 5f2447e4540786f1c614e1df9b85872da7bb9f38 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Wed, 29 Jun 2022 15:26:24 +0200 Subject: [PATCH] Anonymize all IP adresses --- src/utils/yunopaste.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/utils/yunopaste.py b/src/utils/yunopaste.py index 35e829991..83e52a12a 100644 --- a/src/utils/yunopaste.py +++ b/src/utils/yunopaste.py @@ -5,7 +5,7 @@ import json import logging from yunohost.domain import _get_maindomain, domain_list -from yunohost.utils.network import get_public_ip +from yunohost.utils.network import get_public_ips from yunohost.utils.error import YunohostError logger = logging.getLogger("yunohost.utils.yunopaste") @@ -82,13 +82,26 @@ def anonymize(data): count += 1 # We also want to anonymize the ips - ipv4 = get_public_ip() - ipv6 = get_public_ip(6) + ipsv4 = get_public_ips(4) + ipsv6 = get_public_ips(6) - if ipv4: - data = data.replace(str(ipv4), "xx.xx.xx.xx") + def gen_anonymized_ip(length,counter,sep='.'): + # Generate anonymized IPs like "xx.xx.xx.yy" + chars = "xy" + binary_str = format(counter, 'b') + indexes = [int(x) for x in binary_str] + if len(indexes)