V2Conf
V2Conf helps you build V2Ray configuration files automatically and evaluate and modify configuration rules based on outbound performance.
Installation & Running
sudo apt-get install pipx && pipx install --python python3.9 v2conf;
sudo $(which v2conf) /home/ubuntu/confs -n 10 --no-geoip --country-code 'IR' --jalali --log-file /home/ubuntu/v2conf.log
Recommended Usage
sudo $(which v2conf) /home/ubuntu/confs -n 5 -s 900 --timeout-penalty 10 --ema 8,1.25 --no-geoip --country-code 'IR' --log-level error --jalali -w "https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86/alpine-minirootfs-3.17.1-x86.tar.gz" --log-file /home/ubuntu/v2conf.log
With these flags and settings, V2Conf will download the selected file every 15 minutes (900 / 60 = 15) 10 times for each outbound.
V2Conf will print logs in Jalali date times in /home/ubuntu/v2conf.log and stdout simultaneously and it will exclude IPs for Iran. (useful for domestic Iranian VPSs)
--timeout-penalty 15 makes the program to consider a failed test as a test with 15 seconds latency and based on exponential moving average of last 8 evaluations (past 2 hours) and weighting more importance on recent evaluations (2 times for every new evaluation) choose the best outbound and route all data within that.
--log-level error indicates that V2Ray log level will be error.
For using it with xray you can specify -c /usr/local/etc/xray/config.json and -p xray flags.\
Details
V2Conf expects a directory with this structure from you:
confs/
├── inbounds # an "inbounds" directory
│ └── main_entry.json
├── outbounds # an "outbounds" directory
│ ├── blocked.json
│ ├── direct.json
│ ├── trojan_h2.json
│ ├── trojan_ws_cloudflare.json
│ ├── vless_h2.json
│ └── vless_ws_cloudflare.json
└── rules # a "rules" directory
├── ir.json
└── private.json
where each inbound, outbound or rule should be saved as a json file (*.json).
e.g. main_entry.json:
{
"port": 6060,
"protocol": "trojan",
"settings": {
"clients":
...
and all configs must have a tag!
Additionally, you can have a reverse directory for reverse proxy configurations, which is not mandatory.
P.S.: Thanks to Tushar V2Conf now supports JSON5 format for configs.
Usage
usage: v2conf [-h] [-c CONFIG_FILE] [-p PROCESS_NAME] [--country-code COUNTRY_CODE] [--no-geoip] [-t TIMEOUT] [-w WEBSITE] [-n NUM_OF_TRIES]
[--timeout-penalty TIMEOUT_PENALTY] [--freedom-tag FREEDOM_TAG] [--default-outbound DEFAULT_OUTBOUND] [--use-default-when-all-down]
[--backup-outbounds BACKUP_OUTBOUNDS] [--ema EMA] [-s SLEEP_TIME] [-l {debug,info,warning,error,none}] [-q | --log-file LOG_FILE]
[--jalali] [--stats] [--stats-port STATS_PORT] [--sys-only | --users-only] [-v]
[path_conf_dir]
positional arguments:
path_conf_dir Select configuration directory, default is $PWD.
optional arguments:
-h, --help show this help message and exit
-c CONFIG_FILE, --config-file CONFIG_FILE
Select configuration file, default is '/usr/local/etc/v2ray/config.json'.
-p PROCESS_NAME, --process-name PROCESS_NAME
Select the process name, default is 'v2ray'. If you are using 'xray' set it here and in the custom config file path in '-c'
flag.
--country-code COUNTRY_CODE
Exclude a country from the list of IPs to be routed; default is 'IR'. (ISO 3166-1 alpha-2)
--no-geoip Instead of using V2Ray GeoIP database, downloading IPs from 'ripe.net' (more recent IPs but may slow V2Ray)
-t TIMEOUT, --timeout TIMEOUT
Set the timeout for checking the health of proxies, default is 15 seconds.
-w WEBSITE, --website WEBSITE
Set the website to be used for checking the health of proxies, default is 'https://facebook.com'.
-n NUM_OF_TRIES, --num-of-tries NUM_OF_TRIES
Set the number of tries for checking the health of proxies, default is 10.
--timeout-penalty TIMEOUT_PENALTY
Converting timeouts to latency by this factor (in seconds), DISABLED by default.
--freedom-tag FREEDOM_TAG
Explicitly set the tag for the freedom (direct) outbound.
--default-outbound DEFAULT_OUTBOUND
Default outbound to use for first configuration file.
--use-default-when-all-down
If all outbounds are down, use the default outbound instead of the first ranked outbound.
--backup-outbounds BACKUP_OUTBOUNDS
Choosing a list of outbounds to be only used as backups in case of other outbounds failure.
--ema EMA Instead of choosing OutBound based on latest evaluation, rank based on exponential moving average of last Nth tests and
smoothing variable. (e.g. --ema 10,2.5) DISABLED by default.
-s SLEEP_TIME, --sleep-time SLEEP_TIME
Set the sleep time between each checkup, default is 1,800s. (in seconds)
-l {debug,info,warning,error,none}, --log-level {debug,info,warning,error,none}
Set the V2Ray log level, default is 'warning'.
-q, --quiet No log file (V2Conf). (printing to stdout anyway)
--log-file LOG_FILE Path for V2Conf log file. default is '$PWD/V2Conf.log'
--jalali Use Jalali datetime for V2Conf logging
--stats Activating traffic statistics
--stats-port STATS_PORT
Set the port for statistics API. Default is: 10085
--sys-only Only system traffic statistics
--users-only Only users traffic statistics
-v, --version Show version and exit.
Written by: Mahyar Mahdavi <Mahyar@Mahyar24.com>. License: GNU GPLv3. Source Code: <https://github.com/mahyar24/V2Conf>. Reporting Bugs and PRs are
welcomed. :)
More Tools
Check out these Gist files for more tools:
- V2Ray-Traffic - a script for monitoring V2Ray traffic.
- V2Ray-Abnormal - a script for monitoring V2Ray abnormal IP connections.
- V2Ray-Abnormal-Polars - a script for monitoring V2Ray abnormal IP connections implemented with Polars.
- V2Ray-IP-GeoLocation - a script for checking IP GeoLocations of users.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Contact me: OSS@Mahyar24.com :)
License
Metadata
Release files for v2conf 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| v2conf-0.2.0.tar.gz | 28.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| v2conf-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.0 kB
Release files / v2conf-0.2.0.tar.gz
| Download URL | v2conf-0.2.0.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d98d52230d393fb352dcd281dfa470377a087e9253a3ea23a2200ac3fa678641
|
|
BLAKE2b-256 checksum How to use checksums |
c35dbd1642db5f141d280ba5fbe9eb9ad646eeb8de5845e6f1cef4c52f244ce5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.5 Linux/6.8.0-64-generic
|
Release files / v2conf-0.2.0-py3-none-any.whl
| Download URL | v2conf-0.2.0-py3-none-any.whl |
|---|---|
| Size | 28.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8b32c210fa4456abce0e2f976a10c6eaa16b5a859faa140e4eb38b7011cff92
|
|
BLAKE2b-256 checksum How to use checksums |
452a558e4c6c8ed49c13206321265cbc753d8949b5ddb56ac92e9ff2001e88bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.5 Linux/6.8.0-64-generic
|