Esempio n. 1
0
def global_setting():
    show_text = (_("{} ESTADISTICAS DE TRAFICO".format(run_type.capitalize())),
                 _("Iptables Traffic Statistics"), _("Ban Bittorrent"),
                 _("Schedule Update {}".format(run_type.capitalize())),
                 _("Clean {} Log".format(run_type.capitalize())),
                 _("Change Language"))
    print("")
    for index, text in enumerate(show_text):
        print("{}.{}".format(index + 1, text))
    choice = loop_input_choice_number(_("POR FAVOR SELECCIONE: "),
                                      len(show_text))
    if choice == 1:
        stats_ctr.manage()
    elif choice == 2:
        iptables_ctr.manage()
    elif choice == 3:
        ban_bt.manage()
    elif choice == 4:
        update_timer.manage()
    elif choice == 5:
        V2ray.cleanLog()
    elif choice == 6:
        from .util_core.config import Config
        config = Config()
        lang = config.get_data("lang")
        config.set_data("lang", "zh" if lang == "en" else "en")
        print(ColorStr.yellow(_("please run again to become effective!")))
        sys.exit(0)
Esempio n. 2
0
def menu():
    V2ray.check()
    parse_arg()
    while True:
        print("")
        print(ColorStr.cyan(_("Welcome to {} manager".format(run_type))))
        print("")
        show_text = (_("1.{} Manage".format(run_type.capitalize())), _("2.Group Manage"), _("3.Modify Config"), _("4.Check Config"), _("5.Global Setting"), _("6.Update {}".format(run_type.capitalize())), _("7.Generate Client Json"))
        for index, text in enumerate(show_text): 
            if index % 2 == 0:
                print('{:<20}'.format(text), end="")   
            else:
                print(text)
                print("")
        print("")
        choice = loop_input_choice_number(_("please select: "), len(show_text))
        if choice == 1:
            service_manage()
        elif choice == 2:
            user_manage()
        elif choice == 3:
            profile_alter()
        elif choice == 4:
            V2ray.info()
        elif choice == 5:
            global_setting()
        elif choice == 6:
            V2ray.update()
        elif choice == 7:
            from .util_core import client
            client.generate()
        else:
            break
Esempio n. 3
0
def tfo():
    gs = GroupSelector(_('modify tcpFastOpen'))
    group = gs.group

    if group == None:
        pass
    else:
        if type(group.node_list[0]) == Mtproto or type(group.node_list[0]) == SS:
            print(_("{} MTProto/Shadowsocks don't support tcpFastOpen!!!".format(run_type.capitalize())))
            print("")
            return
        
        print('{}: {}'.format(_("group tcpFastOpen"), group.tfo))
        print("")
        print(_("1.open TFO(force open)"))
        print(_("2.close TFO(force close)"))
        print(_("3.delete TFO(use system default profile)"))
        choice = readchar(_("please select: "))
        if not choice:
            return
        if not choice in ("1", "2", "3"):
            print(_("input error, please input again"))
            return
        
        gw = GroupWriter(group.tag, group.index)
        if choice == "1":
            gw.write_tfo('on')
        elif choice == "2":
            gw.write_tfo('off')
        elif choice == "3":
            gw.write_tfo('del')

        return True
Esempio n. 4
0
def menu():
    V2ray.check()
    parse_arg()
    while True:
        print("")
        print(ColorStr.cyan(_("BIENVENIDO AL PANEL V2RAY".format(run_type))))
        print("")
        show_text = (_("1.ADM. SISTEMA".format(run_type.capitalize())),
                     _("2.ADM. CLIENTES"), _("3.ADM. CONFIG."),
                     _("4.VER INFO CLIENTES"), _("5.AJUSTES GLOBALES"),
                     _("6.ACTUALIZAR {}".format(run_type.capitalize())),
                     _("7.GENERAR JSON"))
        for index, text in enumerate(show_text):
            if index % 2 == 0:
                print('{:<20}'.format(text), end="")
            else:
                print(text)
                print("")
        print("")
        choice = loop_input_choice_number(_("POR FAVOR SELECCIONE: "),
                                          len(show_text))
        if choice == 1:
            service_manage()
        elif choice == 2:
            user_manage()
        elif choice == 3:
            profile_alter()
        elif choice == 4:
            V2ray.info()
        elif choice == 5:
            global_setting()
        elif choice == 6:
            V2ray.update()
        elif choice == 7:
            from .util_core import client
            client.generate()
        else:
            break
Esempio n. 5
0
def modify(group=None, sType=None):
    need_restart = False
    if group == None:
        need_restart = True
        gs = GroupSelector(_('modify protocol'))
        group = gs.group

    if group == None:
        pass
    else:
        sm = StreamModifier(group.tag, group.index)

        if sType != None:
            sm.select([v for v in StreamType if v.value == sType][0])
            print(_("modify protocol success"))
            return

        if need_restart:
            print("")
            print("{}: {}".format(_("group protocol"),
                                  group.node_list[0].stream()))

        print("")
        for index, stream_type in enumerate(sm.stream_type):
            print("{0}.{1}".format(index + 1, stream_type[1]))

        print("")
        choice = input(_("please select new protocol: "))

        if not choice.isdecimal():
            print(_("please input number!"))
        else:
            choice = int(choice)
            if choice > 0 and choice <= len(sm.stream_type):
                if sm.stream_type[choice - 1][1] in (
                        "MTProto", "Shadowsocks") and group.tls in ('tls',
                                                                    'xtls'):
                    print(
                        _("{} MTProto/Shadowsocks not support https, close tls success!"
                          .format(run_type.capitalize())))
                sm.select(sm.stream_type[choice - 1][0])
                print(_("modify protocol success"))
                if need_restart:
                    return True
Esempio n. 6
0
def tfo():
    gs = GroupSelector(_('modify tcpFastOpen'))
    group = gs.group

    if group == None:
        pass
    else:
        if type(group.node_list[0]) == Mtproto or type(
                group.node_list[0]) == SS:
            print(
                _("{} LOS PROTOCOLOS MTProto/Shadowsocks NO SOPORTAN TcpFastOpen!!!"
                  .format(run_type.capitalize())))
            print("")
            return

        print('{}: {}'.format(_("ESTADO tcpFastOpen"), group.tfo))
        print("")
        print(_("1.ABRIR TFO(FUERZA APERTURA)"))
        print(_("2.CERRAR TFO(FUERZA CIERRE)"))
        print(_("3.ELIMINAR TFO(use system default profile)"))
        choice = readchar(_("SELECCIONE POR FAVOR: "))
        if not choice:
            return
        if not choice in ("1", "2", "3"):
            print(_("ERROR, ELIJA UNA OPCION"))
            return

        gw = GroupWriter(group.tag, group.index)
        if choice == "1":
            gw.write_tfo('on')
        elif choice == "2":
            gw.write_tfo('off')
        elif choice == "3":
            gw.write_tfo('del')

        return True
Esempio n. 7
0
def manage():

    FIND_V2RAY_CRONTAB_CMD = "crontab -l|grep {}".format(run_type)

    DEL_UPDATE_TIMER_CMD = "crontab -l|sed '/SHELL=/d;/{}/d' > crontab.txt && crontab crontab.txt >/dev/null 2>&1 && rm -f crontab.txt >/dev/null 2>&1".format(
        run_type)

    while True:
        loader = Loader()

        profile = loader.profile

        group_list = profile.group_list

        print("{}: {}".format(
            _("{} Traffic Statistics Status".format(run_type.capitalize())),
            profile.stats.status))

        print("")
        print(_("1.open statistics"))
        print("")
        print(_("2.close statistics"))
        print("")
        print(_("3.check user statistics result"))
        print("")
        print(_("4.check group statistics result"))
        print("")
        print(_("5.reset statistics"))
        print("")
        print(
            _("tip: restart {} will reset traffic statistics!!!".format(
                run_type)))
        print("")

        choice = readchar(_("please select: "))

        if choice in ("3", "4", "5") and not profile.stats.status:
            print(_("only open traffic statistics to operate"))
            print("")
            continue

        if choice == "1":
            if os.popen(FIND_V2RAY_CRONTAB_CMD).readlines():
                rchoice = readchar(
                    _("open traffic statistics will close schedule update {}, continue?(y/n): "
                      .format(run_type)))
                if rchoice == "y" or rchoice == "Y":
                    #关闭定时更新v2ray服务
                    os.system(DEL_UPDATE_TIMER_CMD)
                else:
                    print(_("undo open traffic statistics!!"))
                    continue
            gw = GlobalWriter(group_list)
            gw.write_stats(True)
            V2ray.restart()
            print(_("open traffic statistics success!"))
            print("")

        elif choice == "2":
            gw = GlobalWriter(group_list)
            gw.write_stats(False)
            V2ray.restart()
            print(_("close traffic statistics success!"))
            print("")

        elif choice == "3":
            sf = StatsFactory(profile.stats.door_port)
            print("")
            for group in group_list:
                port_way = "-{}".format(
                    group.end_port) if group.end_port else ""
                for node in group.node_list:
                    print('''
Group: {group.tag}
IP: {color_ip}
Port: {group.port}{port_way}
{node}             
                    '''.format(group=group,
                               color_ip=ColorStr.fuchsia(group.ip),
                               node=node,
                               port_way=port_way).strip())
                    if node.user_info:
                        sf.get_stats(node.user_info, False)
                        sf.print_stats(horizontal=True)
                    else:
                        print(ColorStr.yellow(_("no effective email!!!")))
                    print("")

        elif choice == "4":
            sf = StatsFactory(profile.stats.door_port)
            print("")
            for group in group_list:
                tls = _("open") if group.tls == "tls" else _("close")
                port_way = "-{}".format(
                    group.end_port) if group.end_port else ""
                print('''
Group: {group.tag}
IP: {color_ip}
Port: {group.port}{port_way}
TLS: {tls}
                '''.format(group=group,
                           color_ip=ColorStr.fuchsia(group.ip),
                           tls=tls,
                           port_way=port_way).strip())
                sf.get_stats(group.tag, False, True)
                sf.print_stats(horizontal=True)
                print("")

        elif choice == "5":
            if group_list[-1].node_list[-1].user_number > 1:
                print(profile)
                schoice = input(
                    _("please input number or group alphabet to reset: "))
            else:
                schoice = "A"

            sf = StatsFactory(profile.stats.door_port)
            schoice = schoice.upper()
            if schoice.isnumeric():
                schoice = int(schoice)
                if schoice > 0 and schoice <= group_list[-1].node_list[
                        -1].user_number:
                    find = False
                    for group in group_list:
                        if find:
                            break
                        for node in group.node_list:
                            if node.user_number == schoice:
                                if node.user_info:
                                    sf.get_stats(node.user_info, True)
                                    sf.print_stats()
                                else:
                                    print(_("no effective email!!!"))
                                    print("")
                                find = True
                                break
            elif schoice.isalpha() and schoice <= group_list[-1].tag:
                sf.get_stats(schoice, True, True)
                sf.print_stats()
            else:
                print(_("input error, please input again"))
                print("")
        else:
            break