Skip to content

Commit

Permalink
update 0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
downature committed Jan 14, 2017
1 parent 6232fc7 commit 4e3602f
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 3,258 deletions.
4 changes: 2 additions & 2 deletions dns.py → bin/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def Load_config():
global Local_dns_server
global Local_dns_port
dict_wdata={}
with open ("config.json",'r') as d:
with open ("./conf/config.json",'r') as d:
dict_config = json.load(d)

with open (dict_config['Rpz_json_path'],'r') as c:
dict_data = json.load(c)

with open("./wrcd.base64",'r') as f:
with open("./data//wrcd.base64",'r') as f:
data = base64.b64decode(f.read())
dict_wdata = json.loads(data)
dict_data.update(dict_wdata)
Expand Down
File renamed without changes.
File renamed without changes.
60 changes: 60 additions & 0 deletions bin/update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding:utf-8 -*-
import urllib2
import json
import base64
def Get_host(url):
list1 = []
list2 = []
data = urllib2.urlopen(url) .read()
with open("./data/tmp",'w') as f:
f.write(data)
with open("./data/tmp",'r') as f:
for line in f:
if len(line)>4 and line[0:1] != '#' and '\n' and '\r' and '\r\n':
linedata = (' '.join(line.split())).split(' ')
list1.append(linedata[1])
list2.append(linedata[0])
dict_data = dict(zip(list1,list2))
return dict_data

def Update_record(data):
print ("Starting [ 1 ] updating...")

with open("./data/rpz.json",'w') as f:
json.dump(data, f)
print ("success! [ 1 ] have done ! ")
def GetWildcardsrcd(url):
print ("Starting [ 2 ] updating...")
data = urllib2.urlopen(url) .read()
with open("./data/wrcd.base64",'w') as f:
f.write(data)
print ("success! [ 2 ] have done ! ")

def main():
with open ("./conf/data.json",'r') as d:
dict_config = json.load(d)
dict_host={}

for key1 in dict_config:
if key1 == "hosts":
for key2 in dict_config[key1]:
url = dict_config[key1][key2]
dict1 = Get_host(url)
dict_host.update(dict1)
elif key1 == "jsonb64":
pass
else:
print("Sorry,%s is not support"%key1)

url = dict_config['jsonb64']
Update_record(dict_host)
GetWildcardsrcd(url)


if __name__ == '__main__':
try:
main()
#Update_record()
#GetWildcardsrcd()
except Exception as e:
raise e
2 changes: 1 addition & 1 deletion config.json → conf/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Remote_dns_server" : "114.114.114.114",
"Remote_dns_port":53,
"Rpz_json_path":"rpz.json",
"Rpz_json_path":"./data/rpz.json",
"Local_dns_server" : "127.0.0.1",
"Local_dns_port" : 53
}
9 changes: 9 additions & 0 deletions conf/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"hosts":{
"racaljk":"https://coding.net/u/scaffrey/p/hosts/git/raw/master/hosts",
"yhosts":"https://raw.githubusercontent.com/vokins/yhosts/master/hosts"
},
"DNSMasq":"I'm too lazy, you know",
"jsonb64":"https://raw.githubusercontent.com/dowsnature/dowsDNS/master/wrcd.base64"

}
1 change: 1 addition & 0 deletions data/rpz.json

Large diffs are not rendered by default.

File renamed without changes.
Loading

0 comments on commit 4e3602f

Please sign in to comment.