hostnames registration application for I2P
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
953 B

#!/usr/bin/python
import os
import sys
import argparse
# parse command line options
parser = argparse.ArgumentParser(
description='Hosts builder for py-i2phosts.',
epilog='Report bugs to http://zzz.i2p/topics/733')
parser.add_argument('-c', '--config', default='/etc/py-i2phosts/builder.conf', dest='config_file',
help='config file to use')
args = parser.parse_args()
# django setup
DJANGO_SETTINGS_MODULE = 'settings'
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/web'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
from web.postkey.models import i2phost
# result hosts.txt
hostsfile = 'hosts.txt'
f = open(hostsfile, 'w')
# get activated hosts
qs = i2phost.objects.filter(activated=True)
# select theirs name and base64 hash
l = qs.values('name', 'b64hash')
# write final hosts.txt-format file
for entry in l:
f.write(entry['name'] + '=' + entry['b64hash'] + '\n')
f.close()