v3 auth file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@
|
||||
/dist/
|
||||
/data/
|
||||
data.storage
|
||||
*.auth
|
||||
__pycache__
|
||||
|
||||
poetry.lock
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
from dragonion_server.utils.onion import Onion
|
||||
from dragonion_server.utils.generated_auth.db import AuthFile
|
||||
from dragonion_server.utils.config.db import services
|
||||
|
||||
|
||||
def integrate_onion(port: int, name: str) -> Onion:
|
||||
onion = Onion()
|
||||
onion.connect()
|
||||
onion.write_onion_service(name, port)
|
||||
print(f'Available on {onion.start_onion_service(name)}')
|
||||
print(f'Available on {(onion_host := onion.start_onion_service(name))}')
|
||||
auth = AuthFile(name)
|
||||
auth['host'] = onion_host
|
||||
auth['auth'] = onion.auth_string
|
||||
print(f'To connect to server share .onion host and auth string (next line), '
|
||||
f'also you can just share {auth.filename} file')
|
||||
print(onion.auth_string)
|
||||
print(f'Raw url auth string: {services[name].client_auth_priv_key}')
|
||||
return onion
|
||||
|
||||
1
dragonion_server/utils/generated_auth/__init__.py
Normal file
1
dragonion_server/utils/generated_auth/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
pass
|
||||
10
dragonion_server/utils/generated_auth/db.py
Normal file
10
dragonion_server/utils/generated_auth/db.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import sqlitedict
|
||||
|
||||
|
||||
class AuthFile(sqlitedict.SqliteDict):
|
||||
def __init__(self, service):
|
||||
super().__init__(
|
||||
filename=f'{service}.auth',
|
||||
tablename='auth',
|
||||
autocommit=True
|
||||
)
|
||||
@@ -237,7 +237,8 @@ class Onion(object):
|
||||
service.key_type = "ED25519-V3"
|
||||
service.key_content = res.private_key
|
||||
|
||||
self.auth_string = service.client_auth_priv_key
|
||||
self.auth_string = \
|
||||
base64.b64encode(f'{res.service_id}:descriptor:x25519:{service.client_auth_priv_key}'.encode()).decode()
|
||||
|
||||
services[name] = service
|
||||
|
||||
|
||||
Reference in New Issue
Block a user