diff --git a/Scripts/update_server.py b/Scripts/update_server.py --- a/Scripts/update_server.py +++ b/Scripts/update_server.py @@ -9,6 +9,8 @@ from ast import literal_eval OBFS_REGEX = re.compile(r'^ServerTransportPlugin (obfs\d+|scramblesuit)') +FTEPROXY_REGEX = re.compile(r'^ServerTransportPlugin fte') + IP_REGEX = re.compile(r'^(OutboundBindAddress)\ (\d{1,3}\.\d{1,3}\.\d{1,3}\.' r'\d{1,3})') @@ -52,16 +54,29 @@ def get_tor_fingerprint(name='tor'): 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' + return 'Bridge' elif 'ExitPolicy reject *:*' in tor_config: return 'Relay', None else: return 'Exit', None +def get_obfs_proxy(tor_config): + + if any(OBFS_REGEX.match(i) for i in tor_config): + return 'True' + else: + return 'False' + + +def get_fte_proxy(tor_config): + + if any(FTEPROXY_REGEX.match(i) for i in tor_config): + return 'True' + else: + return 'False' + + def get_ip(tor_config): for i in tor_config: @@ -84,11 +99,18 @@ def get_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) + server_type = get_server_type(tor_config) hostname, fingerprint = get_tor_fingerprint(name) tor_status = get_tor_status(name) ip = get_ip(tor_config) + obfs = None + fte = None + + if server_type == 'Bridge': + obfs = get_obfs_proxy(tor_config) + fte = get_fte_proxy(tor_config) + dictionary = {'server_type': server_type, 'server_name': hostname, 'tor_status': tor_status, 'fingerprint': fingerprint} @@ -98,6 +120,9 @@ def create_server_json(tor_configfile='/ if obfs is not None: dictionary['obfs'] = obfs + if fte is not None: + dictionary['fteproxy'] = fte + return dictionary