Exemplo n.º 1
0
def userData(request):
    '''
    返回用户信息:
    在线人数、今日签到、从未签到、从未使用
    '''

    data = [
        NodeOnlineLog.totalOnlineUser(),
        User.get_today_register_user().count(),
        Suser.get_today_checked_user_num(),
        Suser.get_never_checked_user_num(),
        Suser.get_never_used_num(),
    ]
    return JsonResponse({'data': data})
Exemplo n.º 2
0
def get_node_user(node_id):
    '''
    返回所有当前节点可以使用的用户信息
    '''
    from apps.ssserver.models import Node, Suser
    node = Node.objects.filter(node_id=node_id).first()
    if node:
        data = []
        level = node.level
        user_list = Suser.get_vaild_user(level)
        for user in user_list:
            cfg = {
                'port': user.port,
                'u': user.upload_traffic,
                'd': user.download_traffic,
                'transfer_enable': user.transfer_enable,
                'passwd': user.password,
                'enable': user.enable,
                'user_id': user.user_id,
                'id': user.user_id,
                'method': user.method,
                'obfs': user.obfs,
                'obfs_param': user.obfs_param,
                'protocol': user.protocol,
                'protocol_param': user.protocol_param,
            }
            data.append(cfg)
        return data
Exemplo n.º 3
0
def user_status(request):
    """站内用户分析"""
    # 查询今日注册的用户
    todayRegistered = User.get_today_register_user().values()
    for t in todayRegistered:
        try:
            t["inviter"] = User.objects.get(pk=t["invited_by"])
        except User.DoesNotExist:
            t["inviter"] = "ehco"
    todayRegisteredNum = len(todayRegistered)
    # 查询消费水平前十的用户
    richUser = Donate.richPeople()
    # 查询流量用的最多的用户
    coreUser = Suser.get_user_by_traffic(num=10)
    context = {
        "userNum": User.get_total_user_num(),
        "todayChecked": Suser.get_today_checked_user_num(),
        "aliveUser": NodeOnlineLog.totalOnlineUser(),
        "todayRegistered": todayRegistered[:10],
        "todayRegisteredNum": todayRegisteredNum,
        "richUser": richUser,
        "coreUser": coreUser,
    }
    return render(request, "backend/userstatus.html", context=context)
Exemplo n.º 4
0
def user_status(request):
    '''站内用户分析'''
    # 查询今日注册的用户
    todayRegistered = User.get_today_register_user().values()
    for t in todayRegistered:
        try:
            t['inviter'] = User.objects.get(pk=t['invited_by'])
        except User.DoesNotExist:
            t['inviter'] = 'ehco'
    todayRegisteredNum = len(todayRegistered)
    # 查询消费水平前十的用户
    richUser = Donate.richPeople()
    # 查询流量用的最多的用户
    coreUser = Suser.get_user_by_traffic(num=10)
    context = {
        'userNum': User.get_user_num(),
        'todayChecked': Suser.get_today_checked_user_num(),
        'aliveUser': NodeOnlineLog.totalOnlineUser(),
        'todayRegistered': todayRegistered[:10],
        'todayRegisteredNum': todayRegisteredNum,
        'richUser': richUser,
        'coreUser': coreUser,
    }
    return render(request, 'backend/userstatus.html', context=context)
Exemplo n.º 5
0
def change_ss_port(request):
    '''
    随机重置用户用端口
    返回是否成功
    '''
    user = request.user.ss_user
    # 找到端口池中最大的端口
    port = Suser.get_random_port()
    user.port = port
    user.save()
    registerinfo = {
        'title': '修改成功!',
        'subtitle': '端口修改为:{}!'.format(port),
        'status': 'success',
    }
    return JsonResponse(registerinfo)
Exemplo n.º 6
0
def change_ss_port(request):
    """
    随机重置用户用端口
    返回是否成功
    """
    user = request.user.ss_user
    # 找到端口池中最大的端口
    port = Suser.get_random_port()
    user.port = port
    user.save()
    registerinfo = {
        "title": "修改成功!",
        "subtitle": "端口修改为:{}!".format(port),
        "status": "success",
    }
    return JsonResponse(registerinfo)
Exemplo n.º 7
0
 def add_new_user(cls, cleaned_data):
     from apps.ssserver.models import Suser
     with transaction.atomic():
         username = cleaned_data['username']
         email = cleaned_data['email']
         password = cleaned_data['password1']
         invitecode = cleaned_data['invitecode']
         user = cls.objects.create_user(username, email, password)
         code = InviteCode.objects.get(code=invitecode)
         code.isused = True
         code.save()
         # 将user和ssuser关联
         Suser.objects.create(user_id=user.id, port=Suser.get_random_port())
         # 绑定邀请人
         user.invited_by = code.code_id
         user.invitecode = invitecode
         user.save()
         return user
Exemplo n.º 8
0
def get_node_user(node_id):
    """
    返回所有当前节点可以使用的用户信息
    """
    from apps.ssserver.models import Node, Suser

    node = Node.objects.filter(node_id=node_id).first()
    if node:
        data = []
        level = node.level
        user_list = Suser.get_vaild_user(level)
        for user in user_list:
            cfg = {
                "port": user.port,
                "u": user.upload_traffic,
                "d": user.download_traffic,
                "transfer_enable": user.transfer_enable,
                "passwd": user.password,
                "enable": user.enable,
                "user_id": user.user_id,
                "id": user.user_id,
                "method": user.method,
                "obfs": user.obfs,
                "obfs_param": user.obfs_param,
                "protocol": user.protocol,
                "protocol_param": user.protocol_param,
                "speed_limit_per_user": user.speed_limit,
            }
            if node.speed_limit > 0:
                if user.speed_limit > 0:
                    cfg["speed_limit_per_user"] = min(user.speed_limit,
                                                      node.speed_limit)
                else:
                    cfg["speed_limit_per_user"] = node.speed_limit

            data.append(cfg)
        return data
Exemplo n.º 9
0
def node_user_configs(request, node_id):
    res = {"ret": 1, "data": Suser.get_user_configs_by_node_id(node_id)}
    return JsonResponse(res)