onions: add onion service management
This commit is contained in:
parent
9987c996c9
commit
8efb7d9186
11 changed files with 327 additions and 2 deletions
|
@ -1,5 +1,10 @@
|
|||
from typing import Optional
|
||||
|
||||
from tldextract import extract
|
||||
|
||||
from app import db
|
||||
from app.models import AbstractConfiguration, AbstractResource
|
||||
from app.models.onions import Onion
|
||||
|
||||
|
||||
class Origin(AbstractConfiguration):
|
||||
|
@ -23,6 +28,13 @@ class Origin(AbstractConfiguration):
|
|||
for proxy in self.proxies:
|
||||
proxy.destroy()
|
||||
|
||||
def onion(self) -> Optional[str]:
|
||||
tld = extract(self.domain_name).registered_domain
|
||||
onion = Onion.query.filter(Onion.domain_name == tld).first()
|
||||
if not onion:
|
||||
return None
|
||||
return self.domain_name.replace(tld, f"{onion.onion_name}")
|
||||
|
||||
|
||||
class Proxy(AbstractResource):
|
||||
origin_id = db.Column(db.Integer, db.ForeignKey("origin.id"), nullable=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue