Migrated to dragonion_core
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from attrs import define
|
from attrs import define
|
||||||
from fastapi import WebSocket
|
from fastapi import WebSocket
|
||||||
from ..objects.webmessage import (
|
from dragonion_core.proto.web import (
|
||||||
webmessages_union,
|
webmessages_union,
|
||||||
webmessage_error_message_literal,
|
webmessage_error_message_literal,
|
||||||
WebErrorMessage,
|
WebErrorMessage,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from .connection import Connection
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
from fastapi import WebSocket
|
from fastapi import WebSocket
|
||||||
|
|
||||||
from ..objects.webmessage import (
|
from dragonion_core.proto.web import (
|
||||||
webmessages_union,
|
webmessages_union,
|
||||||
WebMessageMessage,
|
WebMessageMessage,
|
||||||
WebNotificationMessage,
|
WebNotificationMessage,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from .connection import Connection
|
|||||||
from .room import Room
|
from .room import Room
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from ..objects.webmessage import (
|
from dragonion_core.proto.web import (
|
||||||
webmessage_error_message_literal
|
webmessage_error_message_literal
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
pass
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
from typing import Literal, Final, Union
|
|
||||||
from dataclasses_json import dataclass_json
|
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
|
|
||||||
webmessage_type_literal = Literal[
|
|
||||||
"connect", "message", "disconnect", "error", "notification"
|
|
||||||
]
|
|
||||||
webmessage_error_message_literal = Literal[
|
|
||||||
"unknown", "username_exists", "invalid_webmessage"
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass_json
|
|
||||||
@dataclass
|
|
||||||
class _WebAnyMessage:
|
|
||||||
username: str | None = None
|
|
||||||
type: webmessage_type_literal = "message"
|
|
||||||
message: str | None = None
|
|
||||||
error_message: webmessage_error_message_literal | None = None
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass_json
|
|
||||||
@dataclass
|
|
||||||
class WebMessageMessage:
|
|
||||||
username: str
|
|
||||||
message: str
|
|
||||||
type: Final = "message"
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass_json
|
|
||||||
@dataclass
|
|
||||||
class WebErrorMessage:
|
|
||||||
error_message: webmessage_error_message_literal
|
|
||||||
type: Final = "error"
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass_json
|
|
||||||
@dataclass
|
|
||||||
class WebUserMessage:
|
|
||||||
type: Literal["connect", "disconnect"]
|
|
||||||
username: str
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass_json
|
|
||||||
@dataclass
|
|
||||||
class WebNotificationMessage:
|
|
||||||
message: str
|
|
||||||
type: Final = "notification"
|
|
||||||
|
|
||||||
|
|
||||||
webmessages_union = Union[
|
|
||||||
WebMessageMessage,
|
|
||||||
WebErrorMessage,
|
|
||||||
WebUserMessage,
|
|
||||||
WebNotificationMessage
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class WebMessage:
|
|
||||||
@staticmethod
|
|
||||||
def from_json(data) -> webmessages_union:
|
|
||||||
return {
|
|
||||||
"connect": WebUserMessage.from_json,
|
|
||||||
"disconnect": WebUserMessage.from_json,
|
|
||||||
"message": WebMessageMessage.from_json,
|
|
||||||
"error": WebErrorMessage.from_json,
|
|
||||||
"notification": WebNotificationMessage.from_json
|
|
||||||
}[_WebAnyMessage.from_json(data).type](data)
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from fastapi import WebSocket, WebSocketDisconnect
|
from fastapi import WebSocket, WebSocketDisconnect
|
||||||
from .managers.service import Service
|
from .managers.service import Service
|
||||||
from .objects.webmessage import (
|
from dragonion_core.proto.web import (
|
||||||
webmessages_union,
|
webmessages_union,
|
||||||
WebMessage
|
WebMessage
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from dragonion_server.utils.onion import Onion
|
from dragonion_server.utils.onion import Onion
|
||||||
from dragonion_server.utils.generated_auth.db import AuthFile
|
from dragonion_core.proto.file import AuthFile
|
||||||
from dragonion_server.utils.config.db import services
|
from dragonion_server.utils.config.db import services
|
||||||
|
|
||||||
from rich import print
|
from rich import print
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
pass
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import sqlitedict
|
|
||||||
|
|
||||||
|
|
||||||
class AuthFile(sqlitedict.SqliteDict):
|
|
||||||
"""
|
|
||||||
Valid AuthFile has fields:
|
|
||||||
host - .onion url of service
|
|
||||||
auth - v3 onion auth string in format, that can be written to .auth_private file
|
|
||||||
"""
|
|
||||||
def __init__(self, service):
|
|
||||||
super().__init__(
|
|
||||||
filename=f'{service}.auth',
|
|
||||||
tablename='auth',
|
|
||||||
autocommit=True
|
|
||||||
)
|
|
||||||
@@ -12,13 +12,15 @@ psutil = "^5.9.5"
|
|||||||
pynacl = "^1.5.0"
|
pynacl = "^1.5.0"
|
||||||
requests = "^2.31.0"
|
requests = "^2.31.0"
|
||||||
sqlitedict = "^2.1.0"
|
sqlitedict = "^2.1.0"
|
||||||
fastapi = "^0.99.0"
|
fastapi = "^0.100.0"
|
||||||
uvicorn = "^0.22.0"
|
uvicorn = "^0.23.0"
|
||||||
rich = "^13.4.2"
|
rich = "^13.4.2"
|
||||||
click = "^8.1.3"
|
click = "^8.1.3"
|
||||||
attrs = "^23.1.0"
|
attrs = "^23.1.0"
|
||||||
dataclasses-json = "^0.5.9"
|
dataclasses-json = "^0.5.9"
|
||||||
websockets = "^11.0.3"
|
websockets = "^11.0.3"
|
||||||
|
dragonion-core = { git = "https://github.com/dragonionx/dragonion-core.git" }
|
||||||
|
|
||||||
|
|
||||||
[tool.poetry.scripts]
|
[tool.poetry.scripts]
|
||||||
dragonion-server = "dragonion_server:main"
|
dragonion-server = "dragonion_server:main"
|
||||||
|
|||||||
Reference in New Issue
Block a user