Chore: remove unnecessary files

This commit is contained in:
Loyalsoldier 2021-11-03 18:56:11 +08:00
parent e220a0c625
commit f180b19b1e
No known key found for this signature in database
GPG Key ID: 23829BBC1ACF2C90
3 changed files with 0 additions and 112 deletions

View File

@ -1,70 +0,0 @@
#!/usr/bin/env python3
import sys
print(sys.argv[1], sys.argv[2])
''' Find redundant items in domain lists.
e.g. 'bar.foo.com' is redundant for 'foo.com'.
'''
def load(list):
''' Parse conf file & Prepare data structure
Returns: [ ['abc', 'com'],
['bar', 'foo', 'com'],
... ]
'''
results = []
with open(list, 'r') as f:
for line in f.readlines():
line = line.strip()
if line == '' or line.startswith('#'):
continue
# A domain name is case-insensitive and
# consists of several labels, separated by a full stop
domain_labels = line.lower().split('.')
results.append(domain_labels)
# Sort results by domain labels' length
results.sort(key=len)
return results
def find(labelses, removedDomainFile):
''' Find redundant items by a tree of top-level domain label to sub-level.
`tree` is like { 'com': { 'foo: { 'bar': LEAF },
'abc': LEAF },
'org': ... }
'''
tree = {}
LEAF = 1
for labels in labelses:
domain = '.'.join(labels)
# Init root node as current node
node = tree
while len(labels) > 0:
label = labels.pop()
if label in node:
# If child node is a LEAF node,
# current domain must be an existed domain or a subdomain of an existed.
if node[label] == LEAF:
print(f"Redundant found: {domain} at {'.'.join(labels)}")
with open(removedDomainFile, "a") as f:
f.write(domain)
f.write("\n")
break
else:
# Create a leaf node if current label is last one
if len(labels) == 0:
node[label] = LEAF
# Create a branch node
else:
node[label] = {}
# Iterate to child node
node = node[label]
if __name__ == '__main__':
find(load(sys.argv[1]), sys.argv[2])

View File

@ -1,20 +0,0 @@
payload:
- '0.0.0.0/8'
- '10.0.0.0/8'
- '100.64.0.0/10'
- '127.0.0.0/8'
- '169.254.0.0/16'
- '172.16.0.0/12'
- '192.0.0.0/24'
- '192.0.2.0/24'
- '192.88.99.0/24'
- '192.168.0.0/16'
- '198.18.0.0/15'
- '198.51.100.0/24'
- '203.0.113.0/24'
- '224.0.0.0/4'
- '240.0.0.0/4'
- '255.255.255.255/32'
- '::1/128'
- 'fc00::/7'
- 'fe80::/10'

View File

@ -1,22 +0,0 @@
payload:
- '109.239.140.0/24'
- '149.154.160.0/22'
- '149.154.164.0/22'
- '149.154.168.0/22'
- '149.154.172.0/22'
- '67.198.55.0/24'
- '91.108.12.0/22'
- '91.108.16.0/22'
- '91.108.20.0/22'
- '91.108.20.0/23'
- '91.108.4.0/22'
- '91.108.56.0/22'
- '91.108.56.0/23'
- '91.108.8.0/22'
- '95.161.64.0/20'
- '95.161.84.0/23'
- '2001:67c:4e8::/48'
- '2001:b28:f23c::/48'
- '2001:b28:f23d::/48'
- '2001:b28:f23f::/48'
- '2001:b28:f242::/48'