def filter(self, record): if not plexpy.CONFIG.LOG_BLACKLIST: return True try: # Currently only checking for ipv4 addresses ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})', record.msg) for ip in ipv4: if helpers.is_public_ip(ip): record.msg = record.msg.replace( ip, ip.partition('.')[0] + '.***.***.***') args = [] for arg in record.args: ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})', arg) if isinstance(arg, basestring) else [] for ip in ipv4: if helpers.is_public_ip(ip): arg = arg.replace( ip, ip.partition('.')[0] + '.***.***.***') args.append(arg) record.args = tuple(args) except: pass return True
def replace(self, text, ip): if helpers.is_public_ip(ip.replace('-', '.')): partition = '-' if '-' in ip else '.' return text.replace( ip, ip.partition(partition)[0] + (partition + '***') * 3) return text
def replace(self, text, ip): if helpers.is_public_ip(ip.replace('-', '.')): partition = '-' if '-' in ip else '.' return text.replace(ip, partition.join(['***'] * 4)) return text
def replace(self, text, ip): if helpers.is_public_ip(ip): return text.replace(ip, ip.partition('.')[0] + '.***.***.***') return text
def replace(self, text, ip): if helpers.is_public_ip(ip.replace('-', '.')): return text.replace(ip, '-'.join(['***'] * 4)) return text