Skip to main content

A V2ray vpn Client with a focus on config managment

Project description

P2Ray

A powerful, user-friendly command-line manager for V2Ray configurations. Parse, store, test, share, and connect to VLESS, VMess, Shadowsocks, and Trojan servers—all from a single interactive CLI.


🚀 Features

  • Protocol Support: VLESS, VMess, Shadowsocks (SS), Trojan
  • Parsing & Storage: Import server URIs, track metadata (added time, ping count, last latency, working count, usage times, custom IDs & remarks)
  • Interactive Listing: Tabulated view with sorting, filtering, aliases, ANSI‐colored, underlined hot-keys
  • Protocol-Level Tests: Ping (via v2ray-core) and download‐speed tests through a local SOCKS5 inbound
  • Connection Management: Launch V2Ray subprocess, toggle Windows system proxy, reconnect automatically after tests
  • Share & QR Code: Reconstruct URIs or export all URIs to .txt; generate QR codes with clipboard copy
  • Archiving: Move configs between active and archive DBs, with forced ID‐conflict resolution
  • Extensible CLI: Add, remove, edit, archive, unarchive, test single/all, connect, toggle proxy—all with one-letter aliases

📦 Installation

pip install P2Ray

Requires

  • Python 3.10+
  • v2ray-core in your PATH
  • Windows 10+ for system-proxy toggling
  • Optional (for speed tests): requests[socks]

🎬 Quickstart

# Run the interactive CLI
python -m P2Ray
# — or, if you’ve added `p2ray.bat` to your PATH:
p2ray

Upon launch, you’ll see a pseudo-graphic menu:

+------------------------------------------+
|                                          |
|           P2Ray Config Manager           |
|                                          |
|  1.Connect                               |
|  2.Disconnect                            |
|  3.Toggle Sys Proxy                      |
|  ──────────────────                      |
|  4.List Configs        View configs      |
|  5.Test All            Latency test all  |
|  6.Add Configs         Import URIs       |
|  7.Share               Share URI by ID   |
|  8.Share All           Share All URIs    |
|  9.Log Con             Log connection    |
|  ──────────────────                      |
|  10.Archive Config     Archive Config    |
|  11.Unarchive          Unrchive Config   |
|  12.List Archive                         |
|  13.Remove Config      Delete by ID      |
|  ──────────────────                      |
|  14.Test Ping                            |
|  15.Test Speed                           |
|  0. Exit                                 |
|                                          |
+------------------------------------------+
[h3] System Proxy: Set

Type the number or its underlined alias letter (e.g. l for List, c for Connect), then press Enter.


🔧 CLI Commands

1. Add Configs

Loop‐mode import:

6        ← Number for Add Configs
uri: vless://…#Remark  
id : myserver  
uri: q   ← finish (quite the loop)

2. List Configs

Interactive table with commands at the bottom.

In Main Menu

4  ← Number for List Configs
or
l  ← Alias letter for List Configs

In the List Menu

(list) › sort lp        ← sort by Last Ping  (or s lp)
(list) › reverse        ← toggle order       (or r)
(list) › export my.csv  
(list) › share 3  
(list) › remove 5  
(list) › archive 7  
(list) › unarchive 2  
(list) › edit 4, remark, New Remark  
(list) › test 3  
(list) › connect 3  
(list) › toggle         ← toggle system proxy  
(list) › q              ← back to main menu  

3. Share / Share All

  • Share: copy URI of one config to clipboard + show QR
  • Share All: export every URI to all_uris.txt

4. Test All

Ping every stored server via v2ray-core and log results.

5. Connect / Toggle Proxy

  • Connect: spawn a v2ray subprocess with local SOCKS5 on port 1081
  • Toggle Proxy: flip Windows system proxy between “Clear” and “127.0.0.1:1081”

⚙️ Configuration Storage

  • Active DB: config_db.json in current working directory

  • Archive DB: archive_db.json

  • Each entry stores full parsed fields + metadata:

    {
      "type": "vless",
      "address": "example.com",
      "port": 443,
      "params": { "security":["tls"], ... },
      "remark": "My Server",
      "added": 1625078400.0,
      "ping_count": 3,
      "last_ping": 1625082000.0,
      "last_latency": 74.2,
      "working_count": 5,
      "working_times": [ ... ],
      "id": "srv1",
      "parsed": { /* full parse structure */ }
    }
    

📖 Examples

# Import a batch, then list & sort by speed
$ p2ray
...
|  4.List Configs        View configs      |
|  5.Test All            Latency test all  |
|  6.Add Configs         Import URIs       |
|  7.Share               Share URI by ID   |
...
> 1
uri: vless://uuid@host:port?encryption=none#FastServer
id : fast1
uri: ss://YWVzLTI1Ni1jZmI6pass@ss.example:443#SS-1
id : ss1
uri: q

> 4
[list shows two servers]
(list)  sort lp
(list)  test 1

🛠️ Advanced

  • Custom v2ray path:

    app = CLIApp(db_path="mydb.json", v2ray_binary="C:\\v2ray\\v2ray.exe")
    
  • Force‐archive with ID collision:

    mgr.move_config("srv1", arc_mgr, force=True)
    
  • Speed testing: Downloads 1 MiB over SOCKS5 using requests[socks].


📂 Repository & PyPI

Contributions and issues are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

p2ray-0.0.1.3.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

p2ray-0.0.1.3-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file p2ray-0.0.1.3.tar.gz.

File metadata

  • Download URL: p2ray-0.0.1.3.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for p2ray-0.0.1.3.tar.gz
Algorithm Hash digest
SHA256 df9b65dccb7e0e05fca3f7e5b4ae9a25053af66a634f8f342d6654c3d755cb52
MD5 8305df7c839ed4208ca4c98fa15ec16f
BLAKE2b-256 71740f6cfe823ecc51f5349341f14d5b13006dd2b1d58392c042b6741b90abb8

See more details on using hashes here.

File details

Details for the file p2ray-0.0.1.3-py3-none-any.whl.

File metadata

  • Download URL: p2ray-0.0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for p2ray-0.0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad7613e6c7a09ed663197103ff34a641d7ded9ccf06723b9da407f38ec1c7ac4
MD5 df702dbcf2a5e8dbda5e50eab7b3b679
BLAKE2b-256 f19fa722d75dd0477b33006e6ef4a96594ffd87b3a6ab553f07584d67966de12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page