示例#1
0
 def link(self, ip, port, tls):
     if tls == "tls":
         return ColorStr.red("HTTPS的Socks5不支持tg的分享连接. 请自行配合设置BifrostV等软件使用")
     else:
         return ColorStr.green(
             "tg://socks?server={0}&port={1}&user={2}&pass={3}".format(
                 ip, port, self.user_info, self.password))
示例#2
0
    def print_stats(self):
        print('''
downlink: {0}  
uplink: {1} 
total: {2}
        '''.format(
            ColorStr.cyan(bytes_2_human_readable(self.downlink_value, 2)),
            ColorStr.cyan(bytes_2_human_readable(self.uplink_value, 2)),
            ColorStr.cyan(
                bytes_2_human_readable(self.downlink_value + self.uplink_value,
                                       2))))
示例#3
0
    def __str__(self):
        tls = "开启" if self.tls == "tls" else "关闭"
        tfo = "TcpFastOpen: {}".format(self.tfo) if self.tfo != None else ""
        dyp = "DynamicPort: {}".format(self.dyp) if self.dyp.status else ""
        port_way = "-{}".format(self.end_port) if self.end_port else ""
        result = ""
        for node in self.node_list:
            temp = '''
{node.user_number}.
Group: {self.tag}
IP: {color_ip}
Port: {self.port}{port_way}
TLS: {tls}
{node}{tfo}
{dyp}
            '''.format(self=self,
                       color_ip=ColorStr.fuchsia(self.ip),
                       node=node,
                       tfo=tfo,
                       dyp=dyp,
                       tls=tls,
                       port_way=port_way)
            result = "{0}{1}\n\n{2}\n\n".format(
                result, temp.strip(),
                node.link(self.ip, int(self.port), self.tls))
        return result
示例#4
0
 def select_group(self):
     print(self.profile)
     choice = input("请输入要{}的节点Group字母: ".format(self.action))
     group_list = [x for x in self.group_list if x.tag == choice]
     if len(group_list) == 0:
         print(ColorStr.red('输入有误,请检查 {} Group是否存在'.format(choice)))
         self.group = None
     else:
         self.group = group_list[0]
示例#5
0
 def __init__(self, action):
     super(GroupSelector, self).__init__(action)
     if "删除" in action and len(self.group_list) == 1:
         print(ColorStr.red("仅剩最后一个端口无法删除!!!"))
         self.group = None
     elif len(self.group_list) > 1:
         self.select_group()
     else:
         self.group = self.group_list[0]
示例#6
0
 def __init__(self, action):
     super(ClientSelector, self).__init__(action)
     self.list_size = self.group_list[-1].node_list[-1].user_number
     if "删除" in action and self.list_size == 1:
         print(ColorStr.red("仅剩最后一个节点无法删除!!!"))
         self.group = None
     elif self.list_size > 1: 
         self.select_client()
     else:
         self.group = self.group_list[0]
         self.client_index = 0
示例#7
0
    def select_client(self):
        print(self.profile)
        self.group = None
        choice = input("请输入要{}的节点序号数字: ".format(self.action))

        if not choice.isnumeric():
            print(ColorStr.red('输入错误,请检查是否为数字'))
            return

        choice = int(choice)
        if choice < 1 or choice > self.list_size:
            print(ColorStr.red('输入错误,请检查是否符合范围中'))
        else:
            find = False
            for group in self.group_list:
                if find:
                    break
                for index, node in enumerate(group.node_list):
                    if node.user_number == choice:
                        self.client_index = index
                        self.group = group
                        find = True
                        break
示例#8
0
 def link(self, ip, port, tls):
     json_dict = {
         "v": "2",
         "ps": "",
         "add": ip,
         "port": port,
         "aid": self.alter_id,
         "type": self.header,
         "net": self.network,
         "path": self.path,
         "host": self.host,
         "id": self.password,
         "tls": tls
     }
     json_data = json.dumps(json_dict)
     result_link = "vmess://{}".format(
         bytes.decode(base64.b64encode(bytes(
             json_data, 'utf-8')))) if self.network != 'quic' else ''
     return ColorStr.green(result_link)
示例#9
0
    def show_node(self, index):
        tls = "开启" if self.tls == "tls" else "关闭"
        tfo = "TcpFastOpen: {}".format(self.tfo) if self.tfo != None else ""
        dyp = "DynamicPort: {}".format(self.dyp) if self.dyp.status else ""
        port_way = "-{}".format(self.end_port) if self.end_port else ""
        node = self.node_list[index]
        result = '''
{node.user_number}.
Group: {self.tag}
IP: {color_ip}
Port: {self.port}{port_way}
TLS: {tls}
{node}{tfo}
{dyp}
{link}'''.format(self=self,
                 color_ip=ColorStr.fuchsia(self.ip),
                 port_way=port_way,
                 node=node,
                 tfo=tfo,
                 dyp=dyp,
                 tls=tls,
                 link=node.link(self.ip, int(self.port), self.tls))
        return result
示例#10
0
loader = Loader()

profile = loader.profile

group_list = profile.group_list

while True:
    print("Iptables 端口流量统计")
    print("")
    print("1.查看流量统计\n")
    print("2.重置流量统计\n")
    print("tip: v2ray功能端口默认自动开启iptables的流量统计\n")

    choice = input("请输入数字选择功能:")
    if choice == "1":
        print("")
        for group in group_list:
            print(calcul_iptables_traffic(group.port))
        print("")

    elif choice == "2":
        port = input("请输入要重置流量的端口:")
        if port and port.isnumeric():
            os.system(
                "bash /usr/local/multi-v2ray/global_setting/clean_traffic.sh {}"
                .format(str(port)))
        else:
            print(ColorStr.red("输入有误!"))
    else:
        break
示例#11
0
 def link(self, ip, port, tls):
     return ColorStr.green(
         "tg://proxy?server={0}&port={1}&secret={2}".format(
             ip, port, self.password))
示例#12
0
 def link(self, ip, port, tls):
     ss_origin_url = "{0}:{1}@{2}:{3}".format(self.method, self.password,
                                              ip, port)
     return ColorStr.green("ss://{}".format(
         bytes.decode(base64.b64encode(bytes(ss_origin_url, 'utf-8')))))