コード例 #1
0
def gen_client(vc):
    Others.get_all()
    cc = vmess2client(load_TPL("CLIENT"), vc)
    cc = fill_dns(cc, Others.get_all()['LOCALDNS'])
    cc = fill_inbounds(cc, Others.get_all()['INBOUNDS'])
    cc = fill_domainStrategy(cc, Others.get_all()['DOMAINSTRATEGY'])
    cc = fill_rules(cc, Others.get_all()['RULES'])
    cc['log']['access'] = Others.get_all()['V2RAY_ACCESS_LOG']
    cc['log']['error'] = Others.get_all()['V2RAY_ERROR_LOG']
    with open(Others.get_all()['V2RAY_PATH'], "w+") as f:
        json.dump(cc, f, indent=2)
コード例 #2
0
def others():
    otherConfig = Others.get_all()
    socks5 = otherConfig['INBOUNDS'].split(',')[0][6:]
    http = otherConfig['INBOUNDS'].split(',')[1][5:]
    return render_template('others.html',
                           title="其余配置",
                           config=otherConfig,
                           socks5=socks5,
                           http=http)
コード例 #3
0
def get_error_log():
    try:
        with open(Others.get_all()['V2RAY_ERROR_LOG']) as f:
            content = f.read().split("\n")
            min_length = min(20, len(content))
            content = content[-min_length:]
            string = ""
            for i in range(min_length):
                string = string + content[i] + "<br>"
        return string
    except PermissionError as e:
        return " Permission denied "
コード例 #4
0
def changeOthers():
    data = json.loads(request.get_data(as_text=True))
    print(data)
    # = "socks:10808,http:10809"
    socks = int(data['socks5'])
    http = int(data['http'])

    if socks <= 0 or socks > 65535:
        return set_message(400)
    if http <= 0 or http > 65535:
        return set_message(400)
    route = data['route']
    strategy = data['strategy']

    Others.set_info('INBOUNDS',
                    "socks:" + str(socks) + "," + "http:" + str(http))

    # 路由处理
    if route == "全局":
        Others.set_info('RULES', 'all')
    elif route == "绕过局域网地址":
        Others.set_info('RULES', 'bpL')
    elif route == "绕过大陆地址":
        Others.set_info('RULES', 'bpA')
    else:
        Others.set_info('RULES', 'bpLAA')

    # 策略处理
    Others.set_info('DOMAINSTRATEGY', strategy)
    restart()
    return set_message(200, url_for('index'))