V2ray/Xray multi-user management utility for configuring proxy servers with various transport protocols
Multi-user and multi-port management capabilities for V2ray/Xray proxy servers. Enables adding, deleting, and configuring users and port groups with various protocols including VMess, VLESS, Trojan, Shadowsocks, Socks5, and MTProto.
Add and remove port groups with different protocols and configurations.
def new_port(new_stream=None):
"""
Add a new port group with specified or interactive protocol selection.
Parameters:
- new_stream (str, optional): Protocol type to add automatically.
Supported: 'tcp', 'tcp_http', 'ws', 'h2',
'mkcp', 'utp', 'srtp', 'wechat-video',
'dtls', 'wireguard', 'quic', 'socks',
'mtproto', 'ss', 'vless_tcp', 'vless_tls',
'vless_ws', 'vless_reality', 'trojan'
If new_stream is None, opens interactive menu for protocol selection.
Generates random port and creates configuration for selected protocol.
Automatically opens firewall ports and restarts service.
"""
def del_port():
"""
Delete an existing port group interactively.
Displays list of configured port groups and allows selection
for deletion. Removes all associated users and configurations.
Updates firewall rules and restarts service.
"""Add and remove individual users within existing port groups.
def new_user():
"""
Add a new user to an existing port group.
Interactive process to:
1. Select target port group
2. Configure user-specific settings (UUID, email, etc.)
3. Apply changes and restart service
Supports all protocol types with appropriate user configurations.
"""
def del_user():
"""
Delete an existing user from a port group.
Interactive selection from configured users across all port groups.
Preserves port group configuration while removing specific user.
"""class User:
"""Base class for all user types"""
def __init__(self, port, uuid, email, alter_id=0):
"""
Initialize user with basic parameters.
Parameters:
- port (int): Port number for the user
- uuid (str): User UUID
- email (str): User email identifier
- alter_id (int): VMess AlterID (default: 0)
"""
def user_info(self):
"""Return user configuration information"""
def protocol(self):
"""Return protocol type string"""class Vmess(User):
"""VMess protocol user management"""
def __init__(self, port, uuid, alter_id, email, path=None):
"""
VMess user with optional WebSocket path.
Parameters:
- path (str, optional): WebSocket path for WS transport
"""
def link_vmess(self):
"""Generate VMess connection string"""
class Vless(User):
"""VLESS protocol user management"""
def __init__(self, port, uuid, email, flow=None):
"""
VLESS user with optional XTLS flow.
Parameters:
- flow (str, optional): XTLS flow type
"""
def link_vless(self):
"""Generate VLESS connection string"""
class Trojan(User):
"""Trojan protocol user management"""
def __init__(self, port, password, email):
"""
Trojan user with password authentication.
Parameters:
- password (str): Trojan password
"""
def link_trojan(self):
"""Generate Trojan connection string"""
class SS(User):
"""Shadowsocks user management"""
def __init__(self, port, password, method, email):
"""
Shadowsocks user configuration.
Parameters:
- password (str): SS password
- method (str): Encryption method
"""
class Socks(User):
"""Socks5 proxy user management"""
def __init__(self, port, username, password, email):
"""
Socks5 user with authentication.
Parameters:
- username (str): Socks5 username
- password (str): Socks5 password
"""
class Mtproto(User):
"""MTProto (Telegram) user management"""
def __init__(self, port, secret, email):
"""
MTProto user for Telegram proxy.
Parameters:
- secret (str): MTProto secret
"""
def link_mtproto(self):
"""Generate MTProto connection string"""class Group:
"""Port group management with multiple users"""
def __init__(self, port, stream_type):
"""
Initialize port group.
Parameters:
- port (int): Group port number
- stream_type (str): Transport protocol type
"""
def add_user(self, user):
"""Add user to the group"""
def del_user(self, user_index):
"""Remove user from the group"""
def group_info(self):
"""Display group configuration and user list"""class Dyport:
"""Dynamic port range management"""
def __init__(self, start_port, end_port):
"""
Configure dynamic port range.
Parameters:
- start_port (int): Range start port
- end_port (int): Range end port
"""from v2ray_util.config_modify.multiple import new_port, new_user
# Interactive port addition
new_port()
# Add specific protocol with random port
new_port('tcp') # TCP protocol
new_port('ws') # WebSocket protocol
new_port('mkcp') # mKCP protocol
new_port('trojan') # Trojan protocol
new_port('vless_tcp') # VLESS over TCP
new_port('ss') # Shadowsocks# Add new user to existing port group
new_user()
# Delete existing user
from v2ray_util.config_modify.multiple import del_user, del_port
del_user() # Remove specific user
del_port() # Remove entire port groupfrom v2ray_util.util_core.group import Group, Vmess
# Create port group
group = Group(8080, 'tcp')
# Create and add VMess user
user = Vmess(8080, 'uuid-string', 2, 'user@example.com')
group.add_user(user)
# Display group information
group.group_info()All user and port management functions provide:
Install with Tessl CLI
npx tessl i tessl/pypi-v2ray-util