Changeset - c34648b1a4d6
[Not reviewed]
default
0 5 0
Dennis Fink - 11 years ago 2014-07-16 01:23:27
dennis.fink@c3l.lu
Add support for flashproxy an meek an version bump
5 files changed with 29 insertions and 4 deletions:
0 comments (0 inline, 0 general)
Scripts/update_server.py
Show inline comments
 
@@ -5,14 +5,15 @@ import json
 

	
 
import requests
 

	
 
from ast import literal_eval
 

	
 
OBFS_REGEX = re.compile(r'^ServerTransportPlugin (obfs\d+|scramblesuit)')
 

	
 
FTEPROXY_REGEX = re.compile(r'^ServerTransportPlugin fte')
 
FLASHPROXY_REGEX = re.compile(r'^ServerTransportPlugin webproxy')
 
MEEKPROXY_REGEX = re.compile(r'^ServerTransportPlugin meek')
 

	
 
IP_REGEX = re.compile(r'^(OutboundBindAddress)\ (\d{1,3}\.\d{1,3}\.\d{1,3}\.'
 
                      r'\d{1,3})')
 

	
 

	
 
def read_tor_config(configfile='/etc/tor/torrc'):
 
@@ -68,12 +69,22 @@ def get_obfs_proxy(tor_config):
 

	
 
def get_fte_proxy(tor_config):
 

	
 
    return any(FTEPROXY_REGEX.match(i) for i in tor_config)
 

	
 

	
 
def get_flash_proxy(tor_config):
 

	
 
    return any(FLASHPROXY_REGEX.match(i) for i in tor_config)
 

	
 

	
 
def get_meek_proxy(tor_config):
 

	
 
    return any(MEEKPROXY_REGEX.match(i) for i in tor_config)
 

	
 

	
 
def get_ip(tor_config):
 

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

	
 
        if match is not None:
 
@@ -97,16 +108,20 @@ def create_server_json(tor_configfile='/
 
    hostname, fingerprint = get_tor_fingerprint(name)
 
    tor_status = get_tor_status(name)
 
    ip = get_ip(tor_config)
 

	
 
    obfs = None
 
    fte = None
 
    flash = None
 
    meek = None
 

	
 
    if server_type == 'Bridge':
 
        obfs = get_obfs_proxy(tor_config)
 
        fte = get_fte_proxy(tor_config)
 
        flash = get_flash_proxy(tor_config)
 
        meek = get_meek_proxy(tor_config)
 

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

	
 
    if ip is not None:
 
        dictionary['ip'] = ip
 
@@ -114,12 +129,18 @@ def create_server_json(tor_configfile='/
 
    if obfs is not None:
 
        dictionary['obfs'] = obfs
 

	
 
    if fte is not None:
 
        dictionary['fteproxy'] = fte
 

	
 
    if flash is not None:
 
        dictionary['flashproxy'] = flash
 

	
 
    if meek is not None:
 
        dictionary['meek'] = meek
 

	
 
    return dictionary
 

	
 

	
 
def update_server(server_json, url):
 

	
 
    headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
ennstatus/api/functions.py
Show inline comments
 
@@ -52,13 +52,13 @@ def check_json_format(server):
 
            % server['tor_status']
 

	
 
    if FINGERPRINT_REGEX.match(server['fingerprint']) is None:
 
        raise ValueError('fingerprint has not the right format!\n')
 

	
 
    if server['server_type'] == 'bridge':
 
        for key in ('obfs', 'fteproxy'):
 
        for key in ('obfs', 'fteproxy', 'flashproxy', 'meek'):
 
            check_bridge(key, server)
 

	
 
    if 'ip' in server:
 
        if IP_REGEX.match(server['ip']) is None:
 
            raise ValueError('ip is not the right format!\n')
 
        elif PRIVATE_IP_REGEX.match(server['ip']) is not None:
ennstatus/templates/api/export/xml/server.xml
Show inline comments
 
@@ -6,10 +6,12 @@
 
    <country>{{ server['country'] }}</country>
 
    <last_updated>{{ server['last_updated'] }}</last_updated>
 
    <fingerprint>{{ server['fingerprint'] }}</fingerprint>
 
    {% if server['server_type'] == 'bridge' %}
 
    <obfs>{{ server['obfs'] }}</obfs>
 
    <fteproxy>{{ server['fteproxy'] }}</fteproxy>
 
    <flashproxy>{{ server['flashproxy'] }}</flashproxy>
 
    <meek>{{ server['meek'] }}</meek>
 
    {% else %}
 
    <ip>{{ server['ip'] }}</ip>
 
    {% endif %}
 
  </server>
ennstatus/templates/status/macros.html
Show inline comments
 
@@ -37,13 +37,13 @@
 
{% endmacro %}
 

	
 
{% macro create_server_table(server_type, servers) %}
 
  {% if server_type in ('Exit', 'Relay') %}
 
    {% set headers = ('#', 'Name', 'IP', 'Server Status', 'Tor Status', 'Country', 'Fingerprint', 'Last Updated (UTC)') %}
 
  {% else %}
 
    {% set headers = ('#', 'Name', 'Server Status', 'Tor Status', 'Country', 'Fingerprint', 'OBFS', 'FTEProxy', 'Last Updated (UTC)') %}
 
    {% set headers = ('#', 'Name', 'Server Status', 'Tor Status', 'Country', 'Fingerprint', 'OBFS', 'FTEProxy', 'Flashproxy', 'meek', 'Last Updated (UTC)') %}
 
  {% endif %}
 
  <h2>{{ server_type }}</h2>
 
  <table class="table table-bordered table-striped">
 
    <thead>
 
      <tr>
 
        {% for name in headers %}
 
@@ -66,12 +66,14 @@
 
          {% endfor %}
 
          <td>{{ create_country(server['country']) }}</td>
 
          <td>{{ create_fingerprint(server['fingerprint'], server['server_type']) }}</td>
 
          {% if server_type == 'Bridge' %}
 
            <td>{{ colorize_obfs(server['obfs']) }}</td>
 
            <td>{{ colorize_obfs(server['fteproxy']) }}</td>
 
            <td>{{ colorize_obfs(server['flashproxy']) }}</td>
 
            <td>{{ colorize_obfs(server['meek']) }}</td>
 
          {% endif %}
 
          <td>{{ server['last_updated'] }}</td>
 
        </tr>
 
      {% endfor %}
 
    </tbody>
 
  </table>
setup.py
Show inline comments
 
@@ -8,13 +8,13 @@ def _get_requirements():
 

	
 
    lines = [line[:-1] for line in lines if not line.startswith('#')]
 
    return lines
 

	
 

	
 
setup(name='Ennstatus',
 
      version='4.1.4',
 
      version='4.2.0',
 
      description=('Ennstatus provides the user with vital information about '
 
                   'the status of the organizations Tor servers.'),
 
      author='Frënn vun der Ënn',
 
      author_email='info@enn.lu',
 
      url='https://bitbucket.org/fvde/ennstatus',
 
      license='GPLv3+',
0 comments (0 inline, 0 general)