generated from github/dotnet-codespaces
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
import uuid
import json
def generate_vless_config(host, port, uuid_str, security, sni, path, service_name):
"""
Generates a VLESS configuration for V2RayNG with TLS support.
"""
config = {
"v": "2", # Default version
"ps": service_name, # Profile name
"add": host, # Server address
"port": port, # Server port
"id": uuid_str, # User UUID
"aid": "0", # AlterID (VLESS doesn't use this, but it's required)
"net": "ws", # Network type (WebSocket)
"type": "none", # No obfuscation
"tls": security, # TLS or None
"sni": sni, # Server Name Indication for TLS
"path": path, # Websocket path
"protocol": "vless", # Protocol type
}
return config
def save_config(config, filename):
"""
Saves the configuration to a JSON file.
"""
with open(filename, "w") as f:
json.dump(config, f, indent=4)
def main():
# User input
host = input("Enter Server Host (e.g., example.com): ")
port = int(input("Enter Server Port (e.g., 443): "))
uuid_str = input(f"Enter User UUID (press Enter to generate one): ") or str(uuid.uuid4())
security = input("Enable TLS? (y/n): ").strip().lower()
security = "tls" if security == "y" else "none"
sni = input("Enter SNI (e.g., example.com): ") if security == "tls" else ""
path = input("Enter WebSocket Path (e.g., /vless): ") or "/vless"
service_name = input("Enter Profile Name (e.g., MyVLESS): ") or "Generated VLESS Config"
# Generate configuration
config = generate_vless_config(host, port, uuid_str, security, sni, path, service_name)
# Save to file
filename = "vless_config.json"
save_config(config, filename)
print(f"VLESS configuration saved to {filename}")
# Print the configuration
print("\nGenerated VLESS Configuration:")
print(json.dumps(config, indent=4))
if __name__ == "__main__":
main()How It Works
- User Input: The script prompts the user for details like server host, port, UUID, TLS, SNI, and WebSocket path.
- Configuration: It generates a VLESS configuration in JSON format, compatible with V2RayNG.
- Save to File: The configuration is saved as
vless_config.json. - Output: The configuration is also printed to the console.
Example Input and Output
User Input:
- Server Host:
example.com - Server Port:
443 - User UUID: (Press Enter to auto-generate)
- Enable TLS?
y - SNI:
example.com - WebSocket Path:
/vless - Profile Name:
MyVLESS
Generated Configuration (vless_config.json):
{
"v": "2",
"ps": "MyVLESS",
"add": "example.com",
"port": 443,
"id": "f9b8a7c6-d5e4-4f3a-8b2c-1d0e9f8a7b6c",
"aid": "0",
"net": "ws",
"type": "none",
"tls": "tls",
"sni": "example.com",
"path": "/vless",
"protocol": "vless"
}Importing into V2RayNG
- Run the script and save the configuration to
vless_config.json. - Open V2RayNG on your Android device.
- Go to
Settings>Import/Export>Import from JSONand select thevless_config.jsonfile. - The profile will be added to your list, and you can connect to the VPN.
Notes
- TLS: If TLS is enabled, ensure your server is properly configured with a valid SSL certificate.
- UUID: You can generate a UUID using the script or provide your own.
- WebSocket Path: This must match the path configured on your server.
Let me know if you need further assistance!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels