or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

config-modification.mdcore-management.mdindex.mdtraffic-statistics.mduser-port-management.mdutilities-global-settings.md
tile.json

tessl/pypi-v2ray-util

V2ray/Xray multi-user management utility for configuring proxy servers with various transport protocols

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/v2ray-util@3.11.x

To install, run

npx @tessl/cli install tessl/pypi-v2ray-util@3.11.0

index.mddocs/

V2ray Util

A 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.

Package Information

  • Package Name: v2ray-util
  • Language: Python
  • Installation: pip install v2ray-util
  • Requirements: Python 3.4+, root/sudo privileges

Core Imports

import v2ray_util
from v2ray_util.main import menu

For 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, GlobalWriter

Basic Usage

Command Line Interface

The 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 port

Programmatic Usage

from 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()

Architecture

The package is organized into several key modules:

  • v2ray_util.main: Interactive menu system and command-line argument parsing
  • v2ray_util.util_core: Core functionality including service management, utilities, and configuration
  • v2ray_util.config_modify: Protocol and configuration modification capabilities
  • v2ray_util.global_setting: Traffic statistics, iptables management, and global settings

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.

Capabilities

Core V2ray Management

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): ...

Core V2ray Management

User and Port Management

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(): ...

User and Port Management

Configuration Modification

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(): ...

Configuration Modification

Traffic Statistics and Monitoring

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): ...

Traffic Statistics

Utilities and Global Settings

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=""): ...

Utilities and Global Settings

Types

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): ...

Internationalization

def _(text):
    """
    Translation function for internationalization.
    
    Parameters:
    - text (str): Text to translate
    
    Returns:
    str: Translated text based on configured language (en/zh)
    """

Command Line Reference

The package provides extensive command-line functionality:

  • Service Control: start, stop, restart, status
  • Configuration: new, info, port, tls, tfo, stream, cdn
  • User Management: add [protocol], del
  • Maintenance: update [version], update.sh, clean, log [error|access], rm
  • Statistics: stats [type], iptables [type]