gitscope
← marzneshin / Diff · 24112b4 → 24112b4
Changes 24112b4..24112b4
Patch commit
diff --git a/app/utils/keygen.py b/app/utils/keygen.py
index dde1d98..afa21c1 100644
--- a/app/utils/keygen.py
+++ b/app/utils/keygen.py
@@ -1,5 +1,9 @@
-import xxhash
+import base64
import uuid
+
+import xxhash
+from nacl.public import PrivateKey
+
from app.config.env import AuthAlgorithm, AUTH_GENERATION_ALGORITHM
@@ -15,3 +19,7 @@ def gen_password(key: str) -> str:
return key
else:
return xxhash.xxh128(key.encode()).hexdigest()
+
+
+def generate_curve25519_pbk(key: str) -> str:
+ return base64.b64encode(PrivateKey(key.encode()).encode()).decode()
diff --git a/app/utils/share.py b/app/utils/share.py
index 1bf9ed3..c29009f 100644
--- a/app/utils/share.py
+++ b/app/utils/share.py
@@ -1,4 +1,5 @@
import base64
+import ipaddress
import json
import random
import secrets
@@ -32,7 +33,7 @@ from app.models.proxy import (
from app.models.settings import SubscriptionSettings
from app.models.user import UserResponse, UserExpireStrategy
from app.templates import render_template
-from app.utils.keygen import gen_uuid, gen_password
+from app.utils.keygen import gen_uuid, gen_password, generate_curve25519_pbk
from app.utils.system import get_public_ip, readable_size
SERVER_IP = get_public_ip()
@@ -115,6 +116,7 @@ def generate_subscription(
configs = generate_user_configs(
user.inbounds,
user.key,
+ user.id,
format_variables,
)
@@ -209,6 +211,7 @@ def setup_format_variables(extra_data: dict) -> dict:
def generate_user_configs(
inbounds: list,
key: str,
+ user_id: int,
format_variables: dict,
) -> Union[List, str]:
@@ -274,10 +277,19 @@ def generate_user_configs(
fingerprint=host.fingerprint.value or inbound.get("fp"),
reality_pbk=inbound.get("pbk"),
reality_sid=inbound.get("sid"),
+ client_address=(
+ ipaddress.ip_network(inbound["address"], strict=False)[
+ user_id
+ ].compressed
+ + "/32"
+ if inbound.get("address")
+ else None
+ ),
flow=inbound.get("flow"),
allow_insecure=host.allowinsecure,
uuid=UUID(gen_uuid(key)),
password=gen_password(key),
+ ed25519=generate_curve25519_pbk(key),
enable_mux=host.mux,
http_headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.3"
diff --git a/requirements.txt b/requirements.txt
index 35589af..4205925 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -23,5 +23,9 @@ aiohttp==3.10.2
xxhash==3.4.1
grpcio==1.65.4
psycopg==3.1.18
-v2share==0.1.0b19
-PyJWT~=2.8.0
\ No newline at end of file
+v2share==0.1.0b21
+PyJWT~=2.8.0
+PyNaCl==1.5.0
+starlette==0.37.2
+uvicorn==0.30.4
+rich==13.7.1
\ No newline at end of file