Пример #1
0
def home_page(environ, start_response):
    print(environ)
    global default_interface_ip
    with open(HOME_HTML_FILE) as f:
        template = jinja2.Template(unicode(f.read(), 'utf8'))
    start_response(httplib.OK, [('Content-Type', 'text/html')])
    is_root = 0 == os.getuid()
    if not default_interface_ip:
        default_interface_ip = fqlan.get_default_interface_ip()
    args = dict(
        _=environ['select_text'],
        domain_name=environ.get('HTTP_HOST') or '127.0.0.1:2515',
        tcp_scrambler_enabled=proxy_client.tcp_scrambler_enabled,
        google_scrambler_enabled=proxy_client.google_scrambler_enabled,
        china_shortcut_enabled=proxy_client.china_shortcut_enabled,
        direct_access_enabled=proxy_client.direct_access_enabled,
        config=config_file.read_config(),
        is_root=is_root,
        default_interface_ip=default_interface_ip,
        http_gateway=http_gateway,
        httpd=httpd,
        spi_wifi_repeater=downstream.spi_wifi_repeater if is_root else None)
    html = template.render(**args).encode('utf8')
    return [html]
Пример #2
0
def get_default_interface_ip():
    global default_interface_ip_cache
    if not default_interface_ip_cache:
        default_interface_ip_cache = fqlan.get_default_interface_ip()
    return default_interface_ip_cache
Пример #3
0
def get_default_interface_ip():
    global default_interface_ip_cache
    if not default_interface_ip_cache:
        default_interface_ip_cache = fqlan.get_default_interface_ip()
    return default_interface_ip_cache
Пример #4
0
def pac_page(environ, start_response):
    with open(WHITELIST_PAC_FILE) as f:
        template = jinja2.Template(unicode(f.read(), 'utf8'))
    ip = fqlan.get_default_interface_ip()
    start_response(httplib.OK, [('Content-Type', 'application/x-ns-proxy-autoconfig')])
    return [template.render(http_gateway='%s:2516' % ip).encode('utf8')]