Creating JSONRPC Server

This commit is contained in:
adator
2025-11-16 19:13:26 +01:00
parent 2e422c93e5
commit c371910066
11 changed files with 347 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
from datetime import datetime
from json import dumps
from dataclasses import dataclass, field, asdict, fields
from dataclasses import dataclass, field, asdict, fields, replace
from typing import Literal, Any, Optional
from os import sep
@@ -14,6 +14,10 @@ class MainModel:
def to_json(self) -> str:
"""Return the object of a dataclass a json str."""
return dumps(self.to_dict())
def copy(self):
"""Return the object of a dataclass a json str."""
return replace(self)
def get_attributes(self) -> list[str]:
"""Return a list of attributes name"""
@@ -205,6 +209,9 @@ class MConfig(MainModel):
PASSWORD: str = "password"
"""The password of the admin of the service"""
RPC_USERS: list[dict] = field(default_factory=list)
"""The Defender rpc users"""
JSONRPC_URL: str = None
"""The RPC url, if local https://127.0.0.1:PORT/api should be fine"""