update retard asn blocker script
This commit is contained in:
parent
385b7314ee
commit
4024e11fdb
1 changed files with 38 additions and 0 deletions
|
@ -37,6 +37,14 @@ class IPParser:
|
||||||
print("Using NGINX format")
|
print("Using NGINX format")
|
||||||
self.writeNginx()
|
self.writeNginx()
|
||||||
return
|
return
|
||||||
|
case "nginxGeo":
|
||||||
|
print("Using NGINX Geo format")
|
||||||
|
self.writeNginxGeo()
|
||||||
|
return
|
||||||
|
case "nginxMap":
|
||||||
|
print("Using NGINX Map format")
|
||||||
|
self.writeNginxMap()
|
||||||
|
return
|
||||||
case "iptables":
|
case "iptables":
|
||||||
print("Using IPTables format")
|
print("Using IPTables format")
|
||||||
self.writeIptables()
|
self.writeIptables()
|
||||||
|
@ -62,6 +70,36 @@ class IPParser:
|
||||||
for ip in self.ip_v6:
|
for ip in self.ip_v6:
|
||||||
f.write('deny %s;\n' % ip)
|
f.write('deny %s;\n' % ip)
|
||||||
|
|
||||||
|
def writeNginxGeo(self):
|
||||||
|
with open(f'{args.asn}-nginx-geo-ipv4.conf', 'w') as f:
|
||||||
|
f.write('geo $asn-%s {\n' % args.asn)
|
||||||
|
f.write('\tdefault 0;\n')
|
||||||
|
for ip in self.ip_v4:
|
||||||
|
f.write('\t%s 1;\n' % ip)
|
||||||
|
f.write('}')
|
||||||
|
|
||||||
|
with open(f'{args.asn}-nginx-geo-ipv6.conf', 'w') as f:
|
||||||
|
f.write('geo $asn-%s {\n' % args.asn)
|
||||||
|
f.write('\tdefault 0;\n')
|
||||||
|
for ip in self.ip_v6:
|
||||||
|
f.write('\t%s 1;\n' % ip)
|
||||||
|
f.write('}')
|
||||||
|
|
||||||
|
def writeNginxMap(self):
|
||||||
|
with open(f'{args.asn}-nginx-map-ipv4.conf', 'w') as f:
|
||||||
|
f.write('map $remote_addr $asn {\n')
|
||||||
|
f.write('\tdefault 0;\n')
|
||||||
|
for ip in self.ip_v4:
|
||||||
|
f.write('\t%s %s;\n' % (ip, args.asn))
|
||||||
|
f.write('}')
|
||||||
|
|
||||||
|
with open(f'{args.asn}-nginx-map-ipv6.conf', 'w') as f:
|
||||||
|
f.write('map $remote_addr $asn {\n')
|
||||||
|
f.write('\tdefault 0;\n')
|
||||||
|
for ip in self.ip_v6:
|
||||||
|
f.write('\t%s %s;\n' % (ip, args.asn))
|
||||||
|
f.write('}')
|
||||||
|
|
||||||
def writeIptables(self):
|
def writeIptables(self):
|
||||||
with open(f'{args.asn}-iptables-ipv4.txt', 'w') as f:
|
with open(f'{args.asn}-iptables-ipv4.txt', 'w') as f:
|
||||||
for ip in self.ip_v4:
|
for ip in self.ip_v4:
|
||||||
|
|
Loading…
Add table
Reference in a new issue