max websocket max size customizable

This commit is contained in:
wh1te909 2024-03-10 00:14:04 +00:00
parent ab543ddf0c
commit c3637afe69
5 changed files with 10 additions and 9 deletions

View File

@ -5,14 +5,14 @@ import websockets
from django.core.management.base import BaseCommand
from core.utils import get_mesh_ws_url
from tacticalrmm.constants import WS_MAX_SIZE
from tacticalrmm.constants import TRMM_WS_MAX_SIZE
class Command(BaseCommand):
help = "Sets up initial mesh central configuration"
async def websocket_call(self, uri):
async with websockets.connect(uri, max_size=WS_MAX_SIZE) as websocket:
async with websockets.connect(uri, max_size=TRMM_WS_MAX_SIZE) as websocket:
# Get Invitation Link
await websocket.send(
json.dumps(

View File

@ -6,14 +6,14 @@ from django.conf import settings
from django.core.management.base import BaseCommand
from core.utils import get_core_settings, get_mesh_ws_url
from tacticalrmm.constants import WS_MAX_SIZE
from tacticalrmm.constants import TRMM_WS_MAX_SIZE
class Command(BaseCommand):
help = "Sets up initial mesh central configuration"
async def websocket_call(self, uri):
async with websockets.connect(uri, max_size=WS_MAX_SIZE) as websocket:
async with websockets.connect(uri, max_size=TRMM_WS_MAX_SIZE) as websocket:
# Get Device groups to see if it exists
await websocket.send(json.dumps({"action": "meshes"}))

View File

@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Any
import websockets
from accounts.utils import is_superuser
from tacticalrmm.constants import WS_MAX_SIZE
from tacticalrmm.constants import TRMM_WS_MAX_SIZE
from tacticalrmm.helpers import make_random_password
from tacticalrmm.logger import logger
@ -86,7 +86,7 @@ class MeshSync:
self, *, payload: dict[str, Any], wait=True
) -> dict[str, Any] | None:
async def _do(payload):
async with websockets.connect(self.uri, max_size=WS_MAX_SIZE) as ws:
async with websockets.connect(self.uri, max_size=TRMM_WS_MAX_SIZE) as ws:
await ws.send(json.dumps(payload))
if wait:
while 1:

View File

@ -16,7 +16,7 @@ from tacticalrmm.constants import (
AGENT_TBL_PEND_ACTION_CNT_CACHE_PREFIX,
CORESETTINGS_CACHE_KEY,
ROLE_CACHE_PREFIX,
WS_MAX_SIZE,
TRMM_WS_MAX_SIZE,
AgentPlat,
MeshAgentIdent,
)
@ -100,7 +100,7 @@ def get_mesh_ws_url() -> str:
async def get_mesh_device_id(uri: str, device_group: str) -> None:
async with websockets.connect(uri, max_size=WS_MAX_SIZE) as ws:
async with websockets.connect(uri, max_size=TRMM_WS_MAX_SIZE) as ws:
payload = {"action": "meshes", "responseid": "meshctrl"}
await ws.send(json.dumps(payload))

View File

@ -1,6 +1,7 @@
import zoneinfo
from enum import Enum
from django.conf import settings
from django.db import models
@ -32,7 +33,7 @@ AGENT_OUTAGES_LOCK = "agent-outages-task-lock-key"
ORPHANED_WIN_TASK_LOCK = "orphaned-win-task-lock-key"
SYNC_MESH_PERMS_TASK_LOCK = "sync-mesh-perms-lock-key"
WS_MAX_SIZE = 100 * 2**20
TRMM_WS_MAX_SIZE = getattr(settings, "TRMM_WS_MAX_SIZE", 100 * 2**20)
class GoArch(models.TextChoices):