CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-v2ray-util

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

Overview
Eval results
Files

core-management.mddocs/

Core V2ray Management

Essential service management operations for controlling V2ray/Xray proxy services. Handles service lifecycle, configuration management, version control, and supports both Docker and systemd deployments.

Capabilities

Service Control

Start, stop, and restart V2ray/Xray services with automatic status checking and error handling.

class V2ray:
    @classmethod
    def start(cls):
        """
        Start the V2ray/Xray service.
        
        Detects Docker or systemd environment and uses appropriate commands.
        Automatically checks status after starting and reports success/failure.
        """
    
    @classmethod
    def stop(cls):
        """
        Stop the V2ray/Xray service.
        
        Gracefully stops the service and verifies shutdown.
        """
    
    @classmethod
    def restart(cls):
        """
        Restart the V2ray/Xray service.
        
        Performs stop followed by start with status verification.
        """

Status and Information

Check service status and display configuration information.

@staticmethod
def status():
    """
    Check V2ray/Xray service status.
    
    Reports whether service is active, inactive, or failed.
    """

@staticmethod
def info():
    """
    Display current V2ray configuration information.
    
    Shows configured users, ports, protocols, and connection details
    including VMess/VLESS connection strings.
    """

@staticmethod
def version():
    """
    Display V2ray/Xray version information.
    
    Shows currently installed version and build information.
    """

Configuration Management

Create, modify, and remove V2ray configurations.

@classmethod
def new(cls):
    """
    Create new V2ray configuration from scratch.
    
    Generates random ports and selects random mKCP header masquerading.
    Displays configuration information after creation.
    """

@classmethod
def check(cls):
    """
    Check V2ray installation and configuration validity.
    
    Verifies service installation, configuration file syntax,
    and required dependencies.
    """

@classmethod
def remove(cls):
    """
    Uninstall V2ray/Xray completely.
    
    Removes service, configuration files, and all related components.
    """

Version Management

Update V2ray/Xray to specific or latest versions.

@staticmethod
def update(version=None):
    """
    Update V2ray/Xray to specified or latest version.
    
    Parameters:
    - version (str, optional): Specific version to install.
                              If None, installs latest release.
    
    Downloads and installs the specified version, preserving
    existing configuration files.
    """

Log Management

Access and manage V2ray logs for debugging and monitoring.

@staticmethod
def log(error_log=False):
    """
    Display V2ray logs.
    
    Parameters:
    - error_log (bool): If True, shows error logs.
                       If False, shows access logs.
    
    Displays real-time or recent log entries for debugging.
    """

@staticmethod
def cleanLog():
    """
    Clean V2ray log files.
    
    Removes old log files to free disk space.
    """

Docker Support

Specialized methods for Docker deployments.

@staticmethod
def docker_run(command, keyword):
    """
    Execute Docker commands for V2ray container management.
    
    Parameters:
    - command (str): Docker command to execute
    - keyword (str): Operation description for logging
    
    Executes Docker commands with status monitoring and reporting.
    """

@staticmethod
def docker_status():
    """
    Check Docker V2ray container status.
    
    Returns:
    bool: True if container is running, False otherwise
    """

Usage Examples

Basic Service Management

from v2ray_util.util_core.v2ray import V2ray

# Start the service
V2ray.start()

# Check if it's running
V2ray.status()

# View configuration
V2ray.info()

# Restart service
V2ray.restart()

Version Management

# Update to latest version
V2ray.update()

# Update to specific version
V2ray.update("4.45.2")

# Check current version
V2ray.version()

Configuration and Logs

# Create new configuration
V2ray.new()

# Check installation
V2ray.check()

# View logs
V2ray.log()  # Access logs
V2ray.log(error_log=True)  # Error logs

# Clean old logs
V2ray.cleanLog()

Decorator

def restart(port_open=False):
    """
    Decorator to automatically restart V2ray after function execution.
    
    Parameters:
    - port_open (bool): If True, also opens ports in firewall after restart
    
    Usage:
    @restart(port_open=True)
    def modify_config():
        # Configuration modifications
        pass
    """

Error Handling

All service management functions handle common error conditions:

  • Service not installed or not found
  • Permission denied (requires root/sudo)
  • Configuration file syntax errors
  • Network connectivity issues for updates
  • Docker daemon not running (for Docker deployments)

Functions provide colored output indicating success (green) or failure (red) status.

Install with Tessl CLI

npx tessl i tessl/pypi-v2ray-util

docs

config-modification.md

core-management.md

index.md

traffic-statistics.md

user-port-management.md

utilities-global-settings.md

tile.json