Esempio n. 1
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
Esempio 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,
                "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