mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-08-21 14:37:16 +00:00
Fixed sub links generation
This commit is contained in:
@@ -32,7 +32,7 @@ class BaseProtocol(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def generate_client_link(self, user: User, hostname: str) -> str:
|
||||
def generate_client_link(self, user: User, hostname: str, network: str = None, security: str = None, **kwargs) -> str:
|
||||
"""Generate client connection link."""
|
||||
pass
|
||||
|
||||
|
@@ -63,9 +63,23 @@ class TrojanProtocol(BaseProtocol):
|
||||
}
|
||||
}
|
||||
|
||||
def generate_client_link(self, user: TrojanUser, hostname: str) -> str:
|
||||
def generate_client_link(self, user: TrojanUser, hostname: str, network: str = None, security: str = None, **kwargs) -> str:
|
||||
"""Generate Trojan client link."""
|
||||
return f"trojan://{user.password}@{hostname}:{self.port}#{user.email}"
|
||||
from urllib.parse import urlencode
|
||||
|
||||
# Use provided parameters or defaults
|
||||
network_type = network or self.network
|
||||
|
||||
params = {
|
||||
'type': network_type
|
||||
}
|
||||
|
||||
# Add security if provided
|
||||
if security and security != 'none':
|
||||
params['security'] = security
|
||||
|
||||
query_string = urlencode(params)
|
||||
return f"trojan://{user.password}@{hostname}:{self.port}?{query_string}#{user.email}"
|
||||
|
||||
def get_client_note(self) -> str:
|
||||
"""Get note for client configuration when using self-signed certificates."""
|
||||
|
@@ -42,9 +42,25 @@ class VlessProtocol(BaseProtocol):
|
||||
}
|
||||
}
|
||||
|
||||
def generate_client_link(self, user: VlessUser, hostname: str) -> str:
|
||||
def generate_client_link(self, user: VlessUser, hostname: str, network: str = None, security: str = None, **kwargs) -> str:
|
||||
"""Generate VLESS client link."""
|
||||
return f"vless://{user.uuid}@{hostname}:{self.port}?encryption=none&type={self.network}#{user.email}"
|
||||
from urllib.parse import urlencode
|
||||
|
||||
# Use provided parameters or defaults
|
||||
network_type = network or self.network
|
||||
encryption = kwargs.get('encryption', 'none')
|
||||
|
||||
params = {
|
||||
'encryption': encryption,
|
||||
'type': network_type
|
||||
}
|
||||
|
||||
# Add security if provided
|
||||
if security and security != 'none':
|
||||
params['security'] = security
|
||||
|
||||
query_string = urlencode(params)
|
||||
return f"vless://{user.uuid}@{hostname}:{self.port}?{query_string}#{user.email}"
|
||||
|
||||
def _user_to_client(self, user: VlessUser) -> Dict[str, Any]:
|
||||
"""Convert VlessUser to client configuration."""
|
||||
|
@@ -43,8 +43,12 @@ class VmessProtocol(BaseProtocol):
|
||||
}
|
||||
}
|
||||
|
||||
def generate_client_link(self, user: VmessUser, hostname: str) -> str:
|
||||
def generate_client_link(self, user: VmessUser, hostname: str, network: str = None, security: str = None, **kwargs) -> str:
|
||||
"""Generate VMess client link."""
|
||||
# Use provided parameters or defaults
|
||||
network_type = network or self.network
|
||||
encryption = kwargs.get('encryption', 'auto')
|
||||
|
||||
config = {
|
||||
"v": "2",
|
||||
"ps": user.email,
|
||||
@@ -52,11 +56,11 @@ class VmessProtocol(BaseProtocol):
|
||||
"port": str(self.port),
|
||||
"id": user.uuid,
|
||||
"aid": str(user.alter_id),
|
||||
"net": self.network,
|
||||
"net": network_type,
|
||||
"type": "none",
|
||||
"host": "",
|
||||
"path": "",
|
||||
"tls": ""
|
||||
"tls": security if security and security != 'none' else ""
|
||||
}
|
||||
|
||||
config_json = json.dumps(config, separators=(',', ':'))
|
||||
|
Reference in New Issue
Block a user