V2ray/Xray multi-user management utility for configuring proxy servers with various transport protocols
npx @tessl/cli install tessl/pypi-v2ray-util@3.11.0A comprehensive V2ray/Xray management utility that enables system administrators to configure and manage multi-user proxy servers with various transport protocols. It offers a wizard-style interface for adding, deleting, and modifying transmission protocols and provides both interactive menu-driven and command-line argument-based management interfaces for enterprise proxy infrastructure deployment and maintenance.
pip install v2ray-utilimport v2ray_util
from v2ray_util.main import menuFor programmatic access to core components:
from v2ray_util.util_core.v2ray import V2ray
from v2ray_util.util_core.utils import ColorStr, open_port, get_ip, clean_iptables
from v2ray_util.util_core.config import Config
from v2ray_util.util_core.profile import Profile
from v2ray_util.util_core.trans import _ # Translation function
from v2ray_util.util_core.writer import Writer, StreamWriter, GroupWriter, ClientWriter, GlobalWriterThe package provides a console script for interactive management:
# Start the interactive menu
v2ray-util
# Direct commands
v2ray-util start # Start v2ray service
v2ray-util stop # Stop v2ray service
v2ray-util status # Check service status
v2ray-util info # Show configuration
v2ray-util add # Add new port/user interactively
v2ray-util add tcp # Add TCP protocol with random portfrom v2ray_util.util_core.v2ray import V2ray
from v2ray_util.util_core.config import Config
# Service management
V2ray.start()
V2ray.stop()
V2ray.restart()
V2ray.status()
# Configuration management
config = Config()
lang = config.get_data('lang')
config.set_data('lang', 'en')
# Get service information
V2ray.info()
V2ray.version()The package is organized into several key modules:
The system supports both v2ray and xray management through runtime type detection, automatically adapting commands and configurations based on the detected or specified proxy type.
Essential service management operations including starting, stopping, restarting services, version management, and configuration operations. Handles both Docker and systemd deployments.
class V2ray:
@classmethod
def start(cls): ...
@classmethod
def stop(cls): ...
@classmethod
def restart(cls): ...
@staticmethod
def status(): ...
@staticmethod
def version(): ...
@staticmethod
def info(): ...
@staticmethod
def update(version=None): ...
@classmethod
def new(cls): ...
@classmethod
def remove(cls): ...Multi-user and multi-port management capabilities for adding, deleting, and configuring users and port groups with various protocols.
def new_port(new_stream=None): ...
def new_user(): ...
def del_port(): ...
def del_user(): ...Protocol configuration and modification capabilities including stream protocols, TLS settings, Shadowsocks, CDN configuration, and base configuration options.
class StreamModifier:
def modify_stream(self, group, stream_type): ...
class TLSModifier:
def modify_tls(self, group): ...
def port(): ...
def new_uuid(): ...
def alterid(): ...
def tfo(): ...Traffic monitoring through V2ray's official API and iptables, providing comprehensive traffic statistics and analysis capabilities.
class StatsFactory:
def get_stats(self, group_list): ...
def get_inbound_stats(self, group_list): ...
def manage(stat_type=''): ...
def calcul_iptables_traffic(port, ipv6=False): ...Utility functions for network operations, color output, validation, certificate generation, and global system settings.
class ColorStr:
@classmethod
def red(cls, s): ...
@classmethod
def green(cls, s): ...
@classmethod
def yellow(cls, s): ...
def get_ip(): ...
def port_is_use(port): ...
def random_port(start_port, end_port): ...
def is_email(email): ...
def gen_cert(domain, cert_type, email=""): ...class StreamType(Enum):
"""Transport protocol types"""
TCP = 'tcp'
TCP_HOST = 'tcp_host'
SOCKS = 'socks'
SS = 'ss'
MTPROTO = 'mtproto'
H2 = 'h2'
WS = 'ws'
GRPC = 'grpc'
QUIC = 'quic'
KCP = 'kcp'
KCP_UTP = 'utp'
KCP_SRTP = 'srtp'
KCP_DTLS = 'dtls'
KCP_WECHAT = 'wechat'
KCP_WG = 'wireguard'
VLESS_KCP = 'vless_kcp'
VLESS_UTP = 'vless_utp'
VLESS_SRTP = 'vless_srtp'
VLESS_DTLS = 'vless_dtls'
VLESS_WECHAT = 'vless_wechat'
VLESS_WG = 'vless_wireguard'
VLESS_TCP = 'vless_tcp'
VLESS_TLS = 'vless_tls'
VLESS_WS = 'vless_ws'
VLESS_GRPC = 'vless_grpc'
VLESS_REALITY = 'vless_reality'
TROJAN = 'trojan'class Config:
"""Configuration management"""
def get_data(self, key: str): ...
def set_data(self, key: str, value): ...
def get_path(self, key: str): ...
class Profile:
"""V2ray profile management"""
def read_json(self): ...
def parse_group(self, part_json, group_index, local_ip): ...def _(text):
"""
Translation function for internationalization.
Parameters:
- text (str): Text to translate
Returns:
str: Translated text based on configured language (en/zh)
"""The package provides extensive command-line functionality:
start, stop, restart, statusnew, info, port, tls, tfo, stream, cdnadd [protocol], delupdate [version], update.sh, clean, log [error|access], rmstats [type], iptables [type]