feat: adds onions list to api
This commit is contained in:
parent
2ca4ddffb0
commit
04f5a0345b
2 changed files with 65 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
import base64
|
||||
import hashlib
|
||||
from typing import Optional
|
||||
from typing import Optional, TypedDict
|
||||
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
|
@ -10,6 +10,12 @@ from app.models import AbstractConfiguration, AbstractResource
|
|||
from app.models.base import Group
|
||||
|
||||
|
||||
class OnionDict(TypedDict):
|
||||
Id: int
|
||||
DomainName: str
|
||||
OnionName: str
|
||||
|
||||
|
||||
class Onion(AbstractConfiguration):
|
||||
@property
|
||||
def brn(self) -> BRN:
|
||||
|
@ -49,6 +55,13 @@ class Onion(AbstractConfiguration):
|
|||
onion = base64.b32encode(result).decode("utf-8").strip("=")
|
||||
return onion.lower()
|
||||
|
||||
def to_dict(self) -> OnionDict:
|
||||
return {
|
||||
"Id": self.id,
|
||||
"DomainName": self.domain_name,
|
||||
"OnionName": self.onion_name,
|
||||
}
|
||||
|
||||
|
||||
class Eotk(AbstractResource):
|
||||
group_id: Mapped[int] = mapped_column(db.Integer(), db.ForeignKey("group.id"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue