Changeset - aa7bc762efce
[Not reviewed]
default
0 1 0
Dennis Fink - 11 years ago 2013-11-18 21:16:20
dennis.fink@c3l.lu
updated ennstatus
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
Scripts/update_server.py
Show inline comments
 
@@ -46,50 +46,52 @@ def get_tor_fingerprint(name='tor'):
 

	
 
    hostname, fingerprint = line.split(' ')
 
    return hostname, fingerprint
 

	
 

	
 
def get_server_type(tor_config):
 

	
 
    if 'BridgeRelay 1' in tor_config:
 
        if any(OBFS_REGEX.match(i) for i in tor_config):
 
            return 'Bridge', 'True'
 
        else:
 
            return 'Bridge', 'False'
 
    elif 'ExitPolicy reject *:*' in tor_config:
 
        return 'Relay', None
 
    else:
 
        return 'Exit', None
 

	
 

	
 
def get_ip(tor_config):
 

	
 
    for i in tor_config:
 
        match = IP_REGEX.match(i)
 

	
 
        if match is not None:
 
            print('IP is:', i.groups()[1])
 
            return i.groups()[1]
 
        else:
 
            print('No ip')
 
            return None
 

	
 

	
 
def get_config():
 

	
 
    config = configparser.ConfigParser()
 
    config.read('/etc/ennstatus_updater.conf')
 

	
 
    return config
 

	
 

	
 
def create_server_json(tor_configfile='/etc/tor/torrc', name='tor'):
 

	
 
    tor_config = read_tor_config(tor_configfile)
 
    server_type, obfs = get_server_type(tor_config)
 
    hostname, fingerprint = get_tor_fingerprint(name)
 
    tor_status = get_tor_status(name)
 
    ip = get_ip(tor_config)
 

	
 
    dictionary = {'server_type': server_type, 'server_name': hostname,
 
                  'tor_status': tor_status}
 

	
 
    if ip is not None:
 
        dictionary['ip'] = ip
0 comments (0 inline, 0 general)