Fix #1 : Fix Override word 'static''transparent' in unbound -> RPZ converter
This commit is contained in:
parent
3bddb013cb
commit
1909ee7bb9
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
from re import sub
|
||||
from shutil import copyfile
|
||||
|
||||
@ -29,6 +30,15 @@ with open(infile, 'w') as f1:
|
||||
f1.writelines(["%s\n" % item for item in file])
|
||||
f.close()
|
||||
|
||||
with open(infile) as f:
|
||||
file = f.read().split('\n')
|
||||
for i in range(len(file)):
|
||||
file[i] = sub('static$', '', file[i])
|
||||
#print(file)
|
||||
with open(infile, 'w') as f1:
|
||||
f1.writelines(["%s\n" % item for item in file])
|
||||
f.close()
|
||||
|
||||
with open(infile, 'r') as f: # load file
|
||||
lines = f.read().splitlines() # read lines
|
||||
with open(infile, 'w') as f: # load file in write mode
|
||||
@ -37,24 +47,33 @@ with open(infile, 'w') as f: # load file in write mode
|
||||
f.write('\n'.join([line + '\n']))
|
||||
elif not line.strip():
|
||||
f.write('\n'.join([line + '\n']))
|
||||
elif line.endswith('transparent'):
|
||||
f.write('\n'.join([line + '\n']))
|
||||
elif line.strip() and not line.startswith(';') and not line.endswith('transparent') and not line.endswith('redirect'):
|
||||
f.write('\n'.join([line + ' CNAME .\n'])) # add CNAME . if file does not start with ;
|
||||
elif line.endswith('transparent'):
|
||||
f.write('\n'.join([line + ' CNAME rpz-passthru.\n']))
|
||||
f.close()
|
||||
|
||||
f = open(infile,'r')
|
||||
a = ['transparent','static']
|
||||
lst = []
|
||||
for line in f:
|
||||
for word in a:
|
||||
if word in line:
|
||||
line = line.replace(word,'')
|
||||
lst.append(line)
|
||||
with open(infile) as f:
|
||||
file = f.read().split('\n')
|
||||
for i in range(len(file)):
|
||||
file[i] = sub('transparent$', '', file[i])
|
||||
#print(file)
|
||||
with open(infile, 'w') as f1:
|
||||
f1.writelines(["%s\n" % item for item in file])
|
||||
f.close()
|
||||
f = open(infile,'w')
|
||||
for line in lst:
|
||||
f.write(line)
|
||||
|
||||
with open(infile, 'r') as f: # load file
|
||||
lines = f.read().splitlines() # read lines
|
||||
with open(infile, 'w') as f: # load file in write mode
|
||||
for line in lines:
|
||||
if line.startswith(';'):
|
||||
f.write('\n'.join([line + '\n']))
|
||||
elif not line.strip():
|
||||
f.write('\n'.join([line + '\n']))
|
||||
elif line.endswith('.'):
|
||||
f.write('\n'.join([line + '\n']))
|
||||
elif line.strip() and not line.endswith('.'):
|
||||
f.write('\n'.join([line + ' CNAME rpz-passthru.\n']))
|
||||
f.close()
|
||||
|
||||
copyfile(infile, outfile) # copy input file to output file
|
||||
|
Loading…
Reference in New Issue
Block a user