add a helper file and some config examples
This commit is contained in:
parent
ebba0e94b9
commit
b519355789
|
@ -0,0 +1,8 @@
|
|||
vmess_server.json: This is the simplest config, and could used as a chain after other chains.
|
||||
vmess_ws_server.json: Could also be used with Cloudflare CDN to hide your IP.
|
||||
nginx_vmess_ws.conf: This is used with vmess_ws_server for the Nginx.
|
||||
|
||||
vmess_ws_client.json: Client config for vmess_ws_server.json
|
||||
jOr.JSON: used for adding chain to exist config. Cpoy this file to upper directory and run `python v2j.py --add_chain jOr`
|
||||
vmess_client_from_airport.json: A example json from airport.
|
||||
vmess_client_from_airport_with_chain.json: A example json from airport after add a chain.
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "129.1.2.3",
|
||||
"port": 4052,
|
||||
"users": [
|
||||
{
|
||||
"id": "7c441d76-d521-49d2-a7b1-129287a2cee1",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"proxySettings": {
|
||||
"tag": "jump"
|
||||
},
|
||||
"tag": "proxy"
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443;
|
||||
server_name test.eu.org;
|
||||
root /usr/share/nginx/html/test.eu.org;
|
||||
index index.html index.htm;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/test.eu.org/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/test.eu.org/privkey.pem;
|
||||
|
||||
location /con/generate_204 { return 204; }
|
||||
|
||||
location /fLH5idn2iQm3Bz {
|
||||
if ($http_upgrade != "websocket") {
|
||||
return 404;
|
||||
}
|
||||
proxy_redirect off;
|
||||
proxy_pass http://127.0.0.1:10000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
|
||||
# Show realip in log
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"log": {
|
||||
"access": "",
|
||||
"error": "",
|
||||
"loglevel": "error"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "socks-in",
|
||||
"port": 44082,
|
||||
"listen": "::",
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": true,
|
||||
"ip": "127.0.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "http-in",
|
||||
"port": 44083,
|
||||
"listen": "::",
|
||||
"protocol": "http"
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "air.port.com",
|
||||
"port": 4401,
|
||||
"users": [
|
||||
{
|
||||
"email": "user@air.com",
|
||||
"id": "5208a9d7-415f-138d-cq36-87a0cAe38b26",
|
||||
"alterId": 2,
|
||||
"security": "auto"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp"
|
||||
},
|
||||
"mux": {
|
||||
"enabled": true
|
||||
},
|
||||
"tag": "proxy"
|
||||
},
|
||||
{
|
||||
"protocol": "freedom",
|
||||
"tag": "direct",
|
||||
"settings": {
|
||||
"domainStrategy": "UseIP"
|
||||
}
|
||||
}
|
||||
],
|
||||
"dns": {
|
||||
"servers": [
|
||||
"1.0.0.1",
|
||||
"localhost"
|
||||
]
|
||||
},
|
||||
"routing": {
|
||||
"domainStrategy": "IPIfNonMatch",
|
||||
"rules": [
|
||||
{
|
||||
"type": "field",
|
||||
"ip": [
|
||||
"geoip:private",
|
||||
"geoip:cn"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"domain": [
|
||||
"geosite:cn"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
{
|
||||
"log": {
|
||||
"access": "",
|
||||
"error": "",
|
||||
"loglevel": "error"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "socks-in",
|
||||
"port": 44082,
|
||||
"listen": "::",
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": true,
|
||||
"ip": "127.0.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "http-in",
|
||||
"port": 44083,
|
||||
"listen": "::",
|
||||
"protocol": "http"
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "129.1.2.3",
|
||||
"port": 4052,
|
||||
"users": [
|
||||
{
|
||||
"id": "7c441d76-d521-49d2-a7b1-129287a2cee1",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"proxySettings": {
|
||||
"tag": "jump"
|
||||
},
|
||||
"tag": "proxy"
|
||||
},
|
||||
{
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "air.port.com",
|
||||
"port": 4401,
|
||||
"users": [
|
||||
{
|
||||
"email": "user@air.com",
|
||||
"id": "5208a9d7-415f-138d-cq36-87a0cAe38b26",
|
||||
"alterId": 2,
|
||||
"security": "auto"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp"
|
||||
},
|
||||
"mux": {
|
||||
"enabled": true
|
||||
},
|
||||
"tag": "jump"
|
||||
},
|
||||
{
|
||||
"protocol": "freedom",
|
||||
"tag": "direct",
|
||||
"settings": {
|
||||
"domainStrategy": "UseIP"
|
||||
}
|
||||
}
|
||||
],
|
||||
"dns": {
|
||||
"servers": [
|
||||
"1.0.0.1",
|
||||
"localhost"
|
||||
]
|
||||
},
|
||||
"routing": {
|
||||
"domainStrategy": "IPIfNonMatch",
|
||||
"rules": [
|
||||
{
|
||||
"type": "field",
|
||||
"ip": [
|
||||
"geoip:private",
|
||||
"geoip:cn"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"domain": [
|
||||
"geosite:cn"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
}
|
||||
],
|
||||
"domainMatcher": "mph"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"inbounds": [
|
||||
{
|
||||
"port": 4052,
|
||||
"listen": "0.0.0.0",
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "7c441d76-d521-49d2-a7b1-129287a2cee1",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "freedom",
|
||||
"settings": {}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"log": {
|
||||
"loglevel": "warning",
|
||||
"access": "/home/opc/42/access.log",
|
||||
"error": "/home/opc/42/error.log"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"port": 2052,
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "7c441d76-d521-49d2-a7b1-129287a2cee1",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"servers": [
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"port": 40000,
|
||||
"users":[
|
||||
{
|
||||
"user":"proxyipv4user",
|
||||
"pass": "yEw6R5ErR3",
|
||||
"level": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"tag": "direct"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"log": {
|
||||
"loglevel": "warning",
|
||||
"access": "/home/opc/42/access.log",
|
||||
"error": "/home/opc/42/error.log"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"port": 4052,
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "7c441d76-d521-49d2-a7b1-129287a2cee1",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"servers": [
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"port": 40000
|
||||
}
|
||||
]
|
||||
},
|
||||
"tag": "direct"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"inbounds": [
|
||||
{
|
||||
"port": 44482,
|
||||
"listen": "127.0.0.1",
|
||||
"protocol": "socks",
|
||||
"sniffing": {
|
||||
"enabled": true,
|
||||
"destOverride": ["http", "tls"]
|
||||
},
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "http-in",
|
||||
"port": 44083,
|
||||
"listen": "::",
|
||||
"protocol": "http"
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "test.eu.org",
|
||||
"port": 443,
|
||||
"users": [
|
||||
{
|
||||
"id": "8fdb7732-13a7-4d83-8f05-6260c5c12701",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "ws",
|
||||
"security": "tls",
|
||||
"wsSettings": {
|
||||
"path": "/fLH5idn2iQm3Bz"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
"log": {
|
||||
"loglevel": "warning",
|
||||
"error": "error.log"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"port": 44482,
|
||||
"listen": "127.0.0.1",
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"udp": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "http",
|
||||
"port": 44483,
|
||||
"listen": "127.0.0.1",
|
||||
"protocol": "http",
|
||||
"sniffing": {
|
||||
"enabled": true,
|
||||
"destOverride": [
|
||||
"http",
|
||||
"tls"
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"udp": false,
|
||||
"allowTransparent": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "test.eu.org",
|
||||
"port": 443,
|
||||
"users": [
|
||||
{
|
||||
"id": "8fdb7732-13a7-4d83-8f05-6260c5c12701",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "ws",
|
||||
"security": "tls",
|
||||
"wsSettings": {
|
||||
"path": "/fLH5idn2iQm3Bz"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"protocol": "freedom",
|
||||
"settings": {},
|
||||
"tag": "direct"
|
||||
},
|
||||
{
|
||||
"protocol": "blackhole",
|
||||
"settings": {},
|
||||
"tag": "block"
|
||||
}
|
||||
],
|
||||
"routing": {
|
||||
"domainStrategy": "IPOnDemand",
|
||||
"rules": [
|
||||
{
|
||||
"type": "field",
|
||||
"outboundTag": "direct",
|
||||
"domain": [
|
||||
"geosite:cn",
|
||||
"jd.com",
|
||||
"baidu.com"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"outboundTag": "direct",
|
||||
"ip": [
|
||||
"geoip:cn",
|
||||
"geoip:private"
|
||||
]
|
||||
},
|
||||
{
|
||||
"domain": [
|
||||
"tanx.com"
|
||||
],
|
||||
"type": "field",
|
||||
"outboundTag": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dns": {
|
||||
"hosts": {
|
||||
"domain:v2fly.org": "www.vicemc.net",
|
||||
"domain:github.io": "pages.github.com",
|
||||
"domain:wikipedia.org": "www.wikimedia.org",
|
||||
"domain:shadowsocks.org": "electronicsrealm.com"
|
||||
},
|
||||
"servers": [
|
||||
"1.1.1.1",
|
||||
{
|
||||
"address": "114.114.114.114",
|
||||
"port": 53,
|
||||
"domains": [
|
||||
"geosite:cn"
|
||||
]
|
||||
},
|
||||
"8.8.8.8",
|
||||
"localhost"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"inbounds": [
|
||||
{
|
||||
"port": 10000,
|
||||
"listen": "127.0.0.1",
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "8fdb7732-13a7-4d83-8f05-6260c5c12701",
|
||||
"alterId": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "ws",
|
||||
"wsSettings": {
|
||||
"path": "/fLH5idn2iQm3Bz"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "freedom",
|
||||
"settings": {}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
import json, os, re
|
||||
import argparse
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import subprocess
|
||||
from argparse import RawTextHelpFormatter
|
||||
|
||||
SUBSCRIBTION_TEXT = "vs.txt"
|
||||
directory_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def remove_chinese_letters(text):
|
||||
pattern = re.compile("[\u4e00-\u9fff]+") # Matches any Chinese character
|
||||
return re.sub(pattern, "", text).replace(" ", "")
|
||||
|
||||
|
||||
def add_chain(chain_name):
|
||||
with open(os.path.join(directory_path, chain_name + ".JSON"), "r") as jump:
|
||||
jump_obj = json.loads(jump.read())
|
||||
|
||||
dns_str = """{
|
||||
"servers": [
|
||||
"https://dns.nextdns.io/76bcfa/v2",
|
||||
"https://1.1.1.1/dns-query",
|
||||
"localhost"
|
||||
],
|
||||
|
||||
"queryStrategy": "UseIPv4",
|
||||
"disableCache": false,
|
||||
"disableFallback": true,
|
||||
"tag": "dns_inbound"
|
||||
}"""
|
||||
dns_obj = json.loads(dns_str)
|
||||
|
||||
for filename in os.listdir(directory_path):
|
||||
if not filename.startswith("j") and filename.endswith(".json"):
|
||||
with open(filename, "r") as js0:
|
||||
original_json = json.loads(js0.read())
|
||||
original_json["outbounds"].insert(0, jump_obj)
|
||||
original_json["outbounds"][1]["tag"] = "jump"
|
||||
# original_json['dns'] = dns_obj
|
||||
original_json["routing"]["domainMatcher"] = "mph"
|
||||
|
||||
# filename_without_extension = os.path.splitext(filename)[0]
|
||||
with open(chain_name + remove_chinese_letters(filename), "w") as js1:
|
||||
js1.write(json.dumps(original_json))
|
||||
|
||||
|
||||
def read_subscribe(sub_url):
|
||||
print("Reading from subscribe ...")
|
||||
|
||||
if sub_url.startswith("http"):
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3"
|
||||
}
|
||||
req = urllib.request.Request(url=sub_url, headers=headers)
|
||||
with urllib.request.urlopen(req) as response:
|
||||
_subs = response.read()
|
||||
with open(SUBSCRIBTION_TEXT, "wb") as f:
|
||||
f.write(_subs)
|
||||
print("subscribe saved to vs.txt")
|
||||
|
||||
|
||||
def parse_all():
|
||||
command = f"python vmess2json.py --parse_all --inbounds socks:44082,http:44083 < {SUBSCRIBTION_TEXT}"
|
||||
subprocess.run(command, shell=True)
|
||||
|
||||
|
||||
def clear_files(starts_with):
|
||||
command = f"rm -f {starts_with}*"
|
||||
subprocess.run(command, shell=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
description="""vmess2json convert vmess link to client json config.
|
||||
python v2j.py --save_vmess_subscribtion ''
|
||||
python v2j.py --parse_all_subscribtion 1
|
||||
python v2j.py --clear jLsj
|
||||
python v2j.py --add_chain jOr
|
||||
""",
|
||||
formatter_class=RawTextHelpFormatter,
|
||||
)
|
||||
parser.add_argument("--save_subscribtion", help="save the subscribtion to vs.txt")
|
||||
|
||||
parser.add_argument(
|
||||
"--parse_all_subscribtion",
|
||||
default="",
|
||||
help="parse all the subscribtion in vs.txt",
|
||||
)
|
||||
|
||||
parser.add_argument("--add_chain", help="add chain to jsons")
|
||||
|
||||
parser.add_argument("--clear", help="clear files starts with")
|
||||
|
||||
option = parser.parse_args()
|
||||
|
||||
if option.save_subscribtion:
|
||||
read_subscribe(option.save_subscribtion)
|
||||
|
||||
if option.parse_all_subscribtion != "":
|
||||
parse_all()
|
||||
|
||||
if option.add_chain:
|
||||
add_chain(option.add_chain)
|
||||
|
||||
if option.clear:
|
||||
clear_files(option.clear)
|
Loading…
Reference in New Issue