V2ray/Xray multi-user management utility for configuring proxy servers with various transport protocols
Protocol configuration and modification capabilities for V2ray/Xray proxy servers. Provides comprehensive control over transport protocols, TLS settings, Shadowsocks configuration, CDN integration, and core configuration parameters.
Fundamental configuration options including ports, UUIDs, AlterID, TCP Fast Open, and dynamic ports.
def port():
"""
Modify port configuration for existing groups.
Interactive selection of port group and new port assignment.
Handles port conflict detection and firewall rule updates.
Supports both single port and port range modifications.
"""
def new_uuid():
"""
Generate and assign new UUID to existing users.
Interactive user selection with automatic UUID generation.
Updates configuration and provides new connection strings.
"""
def alterid():
"""
Modify VMess AlterID for enhanced security.
Interactive user selection and AlterID value input.
Valid range: 0-65535, with 0 recommended for better performance.
"""
def new_email():
"""
Change user email identifier.
Interactive user selection and email input with validation.
Updates user configuration while preserving other settings.
"""
def tfo():
"""
Toggle TCP Fast Open (TFO) setting.
Enables or disables TCP Fast Open for improved connection performance.
Applies globally to all TCP-based connections.
"""
def dyn_port():
"""
Configure dynamic port range for load balancing.
Interactive configuration of port range (start-end ports).
Enables automatic port distribution for high-traffic scenarios.
"""Modify transport layer protocols and their specific settings.
class StreamModifier:
"""Stream protocol modification and configuration"""
def __init__(self, group_list):
"""
Initialize stream modifier with group list.
Parameters:
- group_list (list): List of configured port groups
"""
def modify_stream(self, group, stream_type):
"""
Modify stream transport protocol for a group.
Parameters:
- group: Target port group
- stream_type (str): New stream type
Supported stream types:
- 'tcp': Standard TCP
- 'tcp_http': TCP with HTTP masquerading
- 'ws': WebSocket
- 'h2': HTTP/2 over TLS
- 'mkcp': mKCP with header options
- 'quic': QUIC protocol
"""
def modify(group=None, sType=None):
"""
Interactive stream protocol modification.
Parameters:
- group (optional): Specific group to modify
- sType (optional): Specific stream type to apply
If parameters are None, provides interactive selection menus.
"""SSL/TLS certificate management and configuration for secure connections.
class TLSModifier:
"""TLS configuration and certificate management"""
def __init__(self, group_list):
"""
Initialize TLS modifier.
Parameters:
- group_list (list): List of configured groups
"""
def modify_tls(self, group):
"""
Configure TLS settings for a group.
Parameters:
- group: Target port group
Handles certificate generation, domain configuration,
and TLS protocol settings.
"""
def modify():
"""
Interactive TLS configuration modification.
Provides options for:
- Enable/disable TLS
- Domain configuration
- Certificate management
- TLS version settings
"""Shadowsocks-specific settings including encryption methods and passwords.
class SSFactory:
"""Shadowsocks configuration factory"""
def __init__(self, port, password, method, email):
"""
Initialize Shadowsocks configuration.
Parameters:
- port (int): SS port number
- password (str): SS password
- method (str): Encryption method
- email (str): User identifier
"""
def create_ss_inbound(self):
"""Create Shadowsocks inbound configuration"""
def create_ss_outbound(self):
"""Create Shadowsocks outbound configuration"""
def modify(alter_type='method'):
"""
Modify Shadowsocks configuration parameters.
Parameters:
- alter_type (str): Type of modification
'method' - Change encryption method
'password' - Change password
Supported encryption methods:
- aes-256-gcm, aes-128-gcm
- chacha20-poly1305, chacha20-ietf-poly1305
- xchacha20-poly1305, xchacha20-ietf-poly1305
"""CloudFlare CDN integration for traffic routing and obfuscation.
class CDNModifier:
"""CDN configuration and management"""
def __init__(self, group_list):
"""
Initialize CDN modifier.
Parameters:
- group_list (list): Configured port groups
"""
def set_cdn(self, group, domain):
"""
Configure CDN settings for a group.
Parameters:
- group: Target port group
- domain (str): Domain name for CDN routing
Configures CloudFlare CDN proxy settings and updates
client connection information.
"""
def modify():
"""
Interactive CDN configuration.
Provides domain input, CDN enable/disable options,
and automatic client configuration updates.
"""Low-level JSON configuration manipulation classes for advanced usage.
class Writer:
"""Base configuration writer for JSON manipulation"""
def __init__(self, group_tag='A', group_index=0):
"""
Initialize configuration writer.
Parameters:
- group_tag (str): Group identifier tag
- group_index (int): Group index in configuration
"""
def load(self, path):
"""
Load V2ray configuration from file.
Parameters:
- path (str): Configuration file path
Returns:
dict: Parsed JSON configuration
"""
def load_template(self, template_name):
"""
Load configuration template.
Parameters:
- template_name (str): Template filename
Returns:
dict: Template configuration
"""
def save(self):
"""Save current configuration to file"""
class StreamWriter(Writer):
"""Stream protocol configuration writer"""
def __init__(self, group_tag, group_index, stream_type=None):
"""
Initialize stream writer.
Parameters:
- group_tag (str): Group identifier
- group_index (int): Group index
- stream_type (str, optional): Target stream protocol
"""
def to_mtproto(self, template_json):
"""Convert configuration to MTProto protocol"""
def to_kcp(self, header_type):
"""
Convert configuration to mKCP protocol.
Parameters:
- header_type (str): Header masquerading type
"""
def write(self, **kw):
"""
Write stream configuration with specified parameters.
Supports various stream types: TCP, WebSocket, HTTP/2,
mKCP, QUIC, VLESS, Trojan protocols.
"""
class GroupWriter(Writer):
"""Port group configuration writer"""
def __init__(self, group_tag, group_index):
"""Initialize group writer"""
def write_port(self, port):
"""Update group port number"""
def write_ss_password(self, new_password):
"""Update Shadowsocks password"""
def write_ss_method(self, new_method):
"""Update Shadowsocks encryption method"""
def write_dyp(self, status=False, aid='32'):
"""Configure dynamic port settings"""
def write_tls(self, status=False, crt_file=None, key_file=None, domain=None, alpn=None):
"""Configure TLS settings for the group"""
def write_tfo(self, action='del'):
"""Configure TCP Fast Open settings"""
class ClientWriter(Writer):
"""Individual client configuration writer"""
def __init__(self, group_tag='A', group_index=0, client_index=0):
"""
Initialize client writer.
Parameters:
- group_tag (str): Group identifier
- group_index (int): Group index
- client_index (int): Client index within group
"""
def write_aid(self, aid=32):
"""Update VMess AlterID"""
def write_uuid(self, new_uuid):
"""Update client UUID"""
def write_email(self, email):
"""Update client email identifier"""
class GlobalWriter(Writer):
"""Global configuration writer"""
def __init__(self, group_list):
"""
Initialize global writer.
Parameters:
- group_list (list): List of configured groups
"""
def write_ban_bittorrent(self, status=False):
"""Configure BitTorrent blocking rules"""
def write_stats(self, status=False):
"""Configure traffic statistics collection"""
def create_new_port(self, newPort):
"""Create new port group configuration"""
def create_new_user(self, **kw):
"""Create new user configuration"""
def del_user(self, group, client_index):
"""Delete user from group"""
def del_port(self, group):
"""Delete entire port group"""from v2ray_util.config_modify import base
# Change port interactively
base.port()
# Generate new UUID
base.new_uuid()
# Modify AlterID
base.alterid()
# Toggle TCP Fast Open
base.tfo()from v2ray_util.config_modify.stream import modify, StreamModifier
# Interactive stream modification
modify()
# Programmatic stream modification
from v2ray_util.util_core.profile import Profile
profile = Profile()
groups = profile.load()
modifier = StreamModifier(groups)
# Change to WebSocket
modifier.modify_stream(groups[0], 'ws')from v2ray_util.config_modify.tls import modify, TLSModifier
# Interactive TLS configuration
modify()
# Programmatic TLS setup
profile = Profile()
groups = profile.load()
tls_modifier = TLSModifier(groups)
tls_modifier.modify_tls(groups[0])from v2ray_util.config_modify.ss import modify
# Change encryption method
modify('method')
# Change password
modify('password')from v2ray_util.config_modify.cdn import modify
# Interactive CDN configuration
modify()srtp: FaceTime call simulationutp: BitTorrent traffic simulationwechat-video: WeChat video call simulationdtls: DTLS 1.2 simulationwireguard: WireGuard VPN simulationConfiguration modification functions handle:
All functions provide detailed error messages and rollback capabilities to maintain service availability.
Install with Tessl CLI
npx tessl i tessl/pypi-v2ray-util