(self, **kw)
初始化时需传入group_tag, group_index参数, 自动调用父构造器来初始化
初始化时需传入group_tag, group_index参数, 自动调用父构造器来初始化
初始化时需传入group_tag group_index参数 自动调用父构造器来初始化
def create_new_user(self, **kw):
        '''
        初始化时需传入group_tag, group_index参数, 自动调用父构造器来初始化
        '''
        if self.part_json['protocol'] == 'socks':
            user = {"user": kw["user"], "pass": kw["pass"]}
            self.part_json["settings"]["accounts"].append(user)
            print("{0} user: {1}, pass: {2}".format(_("add socks5 user success!"), kw["user"], kw["pass"]))
        
        elif self.part_json['protocol'] == 'trojan':
            user = {"password": kw["password"]}
            email_info = ""
            if "email" in kw and kw["email"] != "":
                user.update({"email": kw["email"]})
                email_info = ", email: " + kw["email"]
            self.part_json["settings"]["clients"].append(user)
            print("{0} pass: {1}{2}".format(_("add trojan user success!"), kw["password"], email_info))
        
        elif self.part_json['protocol'] == 'vmess':
            new_uuid = uuid.uuid1()
            email_info = ""
            user = {
                "alterId": 0,
                "id": "ae1bc6ce-e575-4ee2-85f1-350a0aa506cb"
            }
            if "email" in kw and kw["email"] != "":
                user.update({"email":kw["email"]})
                email_info = ", email: " + kw["email"]
            user["id"]=str(new_uuid)
            self.part_json["settings"]["clients"].append(user)
            print("{0} uuid: {1}, alterId: 32{2}".format(_("add user success!"), str(new_uuid), email_info))

        elif self.part_json['protocol'] == 'vless':
            new_uuid = uuid.uuid1()
            info = ""
            user = {
                "id": str(new_uuid)
            }
            if "email" in kw and kw["email"] != "":
                user.update({"email":kw["email"]})
                info = ", email: " + kw["email"]
            if self.part_json["streamSettings"]["security"] == "xtls":
                user["flow"] = kw["flow"]
                info += ", flow: " + kw["flow"]
            self.part_json["settings"]["clients"].append(user)
            print("{0} id: {1}{2}".format(_("add user success!"), str(new_uuid), info))

        self.save()
def create_new_user ( self , * * kw ) : if self . part_json [ 'protocol' ] == 'socks' : user = { "user" : kw [ "user" ] , "pass" : kw [ "pass" ] } self . part_json [ "settings" ] [ "accounts" ] . append ( user ) print ( "{0} user: {1}, pass: {2}" . format ( _ ( "add socks5 user success!" ) , kw [ "user" ] , kw [ "pass" ] ) ) elif self . part_json [ 'protocol' ] == 'trojan' : user = { "password" : kw [ "password" ] } email_info = "" if "email" in kw and kw [ "email" ] != "" : user . update ( { "email" : kw [ "email" ] } ) email_info = ", email: " + kw [ "email" ] self . part_json [ "settings" ] [ "clients" ] . append ( user ) print ( "{0} pass: {1}{2}" . format ( _ ( "add trojan user success!" ) , kw [ "password" ] , email_info ) ) elif self . part_json [ 'protocol' ] == 'vmess' : new_uuid = uuid . uuid1 ( ) email_info = "" user = { "alterId" : 0 , "id" : "ae1bc6ce-e575-4ee2-85f1-350a0aa506cb" } if "email" in kw and kw [ "email" ] != "" : user . update ( { "email" : kw [ "email" ] } ) email_info = ", email: " + kw [ "email" ] user [ "id" ] = str ( new_uuid ) self . part_json [ "settings" ] [ "clients" ] . append ( user ) print ( "{0} uuid: {1}, alterId: 32{2}" . format ( _ ( "add user success!" ) , str ( new_uuid ) , email_info ) ) elif self . part_json [ 'protocol' ] == 'vless' : new_uuid = uuid . uuid1 ( ) info = "" user = { "id" : str ( new_uuid ) } if "email" in kw and kw [ "email" ] != "" : user . update ( { "email" : kw [ "email" ] } ) info = ", email: " + kw [ "email" ] if self . part_json [ "streamSettings" ] [ "security" ] == "xtls" : user [ "flow" ] = kw [ "flow" ] info += ", flow: " + kw [ "flow" ] self . part_json [ "settings" ] [ "clients" ] . append ( user ) print ( "{0} id: {1}{2}" . format ( _ ( "add user success!" ) , str ( new_uuid ) , info ) ) self . save ( )