From 5c16fdfb9f1d8b07a2a2cf72fbf8f9c4d8db1146 Mon Sep 17 00:00:00 2001 From: fancy Date: Fri, 1 May 2020 11:55:57 +0800 Subject: [PATCH] add v2ray config example --- .gitignore | 2 + CMakeLists.txt | 2 +- readme.md | 2 +- v2ray_config/00_log.json | 5 ++ v2ray_config/01_api.json | 10 ++++ v2ray_config/02_dns.json | 19 ++++++++ v2ray_config/03_routing.json | 60 ++++++++++++++++++++++++ v2ray_config/04_policy.json | 8 ++++ v2ray_config/05_inbounds_api.json | 14 ++++++ v2ray_config/05_inbounds_http.json | 13 +++++ v2ray_config/05_inbounds_socks5.json | 17 +++++++ v2ray_config/05_inbounds_tproxy.json | 30 ++++++++++++ v2ray_config/06_outbounds_blackhole.json | 19 ++++++++ v2ray_config/06_outbounds_dns.json | 13 +++++ v2ray_config/06_outbounds_freedom.json | 19 ++++++++ v2ray_config/06_outbounds_myproxy.json | 1 + v2ray_config/07_transport.json | 1 + v2ray_config/08_stats.json | 3 ++ v2ray_config/09_reverse.json | 1 + v2ray_config/merge.sh | 2 + v2ray_config/readme.md | 1 + v2ray_config/v2ray.service | 19 ++++++++ 22 files changed, 259 insertions(+), 2 deletions(-) create mode 100644 v2ray_config/00_log.json create mode 100644 v2ray_config/01_api.json create mode 100644 v2ray_config/02_dns.json create mode 100644 v2ray_config/03_routing.json create mode 100644 v2ray_config/04_policy.json create mode 100644 v2ray_config/05_inbounds_api.json create mode 100644 v2ray_config/05_inbounds_http.json create mode 100644 v2ray_config/05_inbounds_socks5.json create mode 100644 v2ray_config/05_inbounds_tproxy.json create mode 100644 v2ray_config/06_outbounds_blackhole.json create mode 100644 v2ray_config/06_outbounds_dns.json create mode 100644 v2ray_config/06_outbounds_freedom.json create mode 100644 v2ray_config/06_outbounds_myproxy.json create mode 100644 v2ray_config/07_transport.json create mode 100644 v2ray_config/08_stats.json create mode 100644 v2ray_config/09_reverse.json create mode 100644 v2ray_config/merge.sh create mode 100644 v2ray_config/readme.md create mode 100644 v2ray_config/v2ray.service diff --git a/.gitignore b/.gitignore index 661c60c..eb5df43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ build .directory .vscode +v2ray_config/proxy +v2ray_config/06_outbounds_proxy.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e88d03..5101250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) -project(cgproxy VERSION 3.4) +project(cgproxy VERSION 3.5) add_executable(cgattach cgattach.cpp) install(TARGETS cgattach DESTINATION /usr/bin diff --git a/readme.md b/readme.md index bc9577b..df831bc 100644 --- a/readme.md +++ b/readme.md @@ -172,7 +172,7 @@ sudo systemctl restart cgproxy.service ## TIPS - `systemd-cgls` to see the cgroup hierarchical tree. - +- v2ray full config exmaple in [v2ray_buid](https://github.com/springzfx/cgproxy/tree/master/v2ray_buid), more to see [v2ray multi-file config](https://www.v2fly.org/chapter_02/multiple_config.html) - Qv2ray config example diff --git a/v2ray_config/00_log.json b/v2ray_config/00_log.json new file mode 100644 index 0000000..d89d7b9 --- /dev/null +++ b/v2ray_config/00_log.json @@ -0,0 +1,5 @@ +{ + "log": { + "loglevel": "debug" + } +} diff --git a/v2ray_config/01_api.json b/v2ray_config/01_api.json new file mode 100644 index 0000000..aa36a80 --- /dev/null +++ b/v2ray_config/01_api.json @@ -0,0 +1,10 @@ +{ + "api": { + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ], + "tag": "API" + } +} diff --git a/v2ray_config/02_dns.json b/v2ray_config/02_dns.json new file mode 100644 index 0000000..a125e7a --- /dev/null +++ b/v2ray_config/02_dns.json @@ -0,0 +1,19 @@ +{ + "dns": { + "servers": [ + { + "address": "localhost", + "port": 53, + "domains": [ + "geosite:cn" + ], + "expectIPs": [ + "geoip:cn" + ] + }, + "https+local://1.1.1.1/dns-query", + "223.6.6.6" + ], + "tag": "dns_inbound" + } +} diff --git a/v2ray_config/03_routing.json b/v2ray_config/03_routing.json new file mode 100644 index 0000000..474b796 --- /dev/null +++ b/v2ray_config/03_routing.json @@ -0,0 +1,60 @@ +{ + "routing": { + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "outboundTag": "dns-out", + "port": "53", + "type": "field" + }, + { + "domain": [ + "geosite:google", + "geosite:github", + "geosite:netflix", + "geosite:steam", + "geosite:telegram", + "geosite:tumblr", + "geosite:bbc" + ], + "outboundTag": "outBound_PROXY", + "type": "field" + }, + { + "ip": [ + "geoip:private" + ], + "outboundTag": "outBound_DIRECT", + "type": "field" + }, + { + "domain": [ + "geosite:category-ads-all" + ], + "outboundTag": "outBound_BLACKHOLE", + "type": "field" + }, + { + "ip": [ + "geoip:cn" + ], + "outboundTag": "outBound_DIRECT", + "type": "field" + }, + { + "domain": [ + "geosite:cn" + ], + "outboundTag": "outBound_DIRECT", + "type": "field" + }, + { + "inboundTag": [ + "inbound_API" + ], + "outboundTag": "API", + "type": "field" + } + ] + } +} diff --git a/v2ray_config/04_policy.json b/v2ray_config/04_policy.json new file mode 100644 index 0000000..1bd8073 --- /dev/null +++ b/v2ray_config/04_policy.json @@ -0,0 +1,8 @@ +{ + "policy": { + "system": { + "statsInboundDownlink": true, + "statsInboundUplink": true + } + } +} diff --git a/v2ray_config/05_inbounds_api.json b/v2ray_config/05_inbounds_api.json new file mode 100644 index 0000000..f6d0f6d --- /dev/null +++ b/v2ray_config/05_inbounds_api.json @@ -0,0 +1,14 @@ +{ + "inbounds": [ + { + "listen": "127.0.0.1", + "port": 15490, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "sniffing": {}, + "tag": "inbound_API" + } + ] +} diff --git a/v2ray_config/05_inbounds_http.json b/v2ray_config/05_inbounds_http.json new file mode 100644 index 0000000..2b946ff --- /dev/null +++ b/v2ray_config/05_inbounds_http.json @@ -0,0 +1,13 @@ +{ + "inbounds": [ + { + "listen": "127.0.0.1", + "port": 8888, + "protocol": "http", + "sniffing": { + "enabled": false + }, + "tag": "http_IN" + } + ] +} diff --git a/v2ray_config/05_inbounds_socks5.json b/v2ray_config/05_inbounds_socks5.json new file mode 100644 index 0000000..71bcbbc --- /dev/null +++ b/v2ray_config/05_inbounds_socks5.json @@ -0,0 +1,17 @@ +{ + "inbounds": [ + { + "listen": "127.0.0.1", + "port": 1080, + "protocol": "socks", + "settings": { + "auth": "noauth", + "userLevel": 0 + }, + "sniffing": { + "enabled": false + }, + "tag": "socks_IN" + } + ] +} diff --git a/v2ray_config/05_inbounds_tproxy.json b/v2ray_config/05_inbounds_tproxy.json new file mode 100644 index 0000000..9db6a7e --- /dev/null +++ b/v2ray_config/05_inbounds_tproxy.json @@ -0,0 +1,30 @@ +{ + "inbounds": [ + { + "listen": "0.0.0.0", + "port": 12345, + "protocol": "dokodemo-door", + "settings": { + "address": "", + "followRedirect": true, + "network": "tcp,udp", + "port": 0, + "timeout": 0, + "userLevel": 0 + }, + "sniffing": { + "destOverride": [ + "http", + "tls" + ], + "enabled": true + }, + "streamSettings": { + "sockopt": { + "tproxy": "tproxy" + } + }, + "tag": "tproxy_IN" + } + ] +} diff --git a/v2ray_config/06_outbounds_blackhole.json b/v2ray_config/06_outbounds_blackhole.json new file mode 100644 index 0000000..e612438 --- /dev/null +++ b/v2ray_config/06_outbounds_blackhole.json @@ -0,0 +1,19 @@ +{ + "outbounds": [ + { + "protocol": "blackhole", + "sendThrough": "0.0.0.0", + "settings": { + "response": { + "type": "none" + } + }, + "streamSettings": { + "sockopt": { + "mark": 255 + } + }, + "tag": "outBound_BLACKHOLE" + } + ] +} diff --git a/v2ray_config/06_outbounds_dns.json b/v2ray_config/06_outbounds_dns.json new file mode 100644 index 0000000..fc7a0d2 --- /dev/null +++ b/v2ray_config/06_outbounds_dns.json @@ -0,0 +1,13 @@ +{ + "outbounds": [ + { + "protocol": "dns", + "streamSettings": { + "sockopt": { + "mark": 255 + } + }, + "tag": "dns-out" + } + ] +} diff --git a/v2ray_config/06_outbounds_freedom.json b/v2ray_config/06_outbounds_freedom.json new file mode 100644 index 0000000..ea0b585 --- /dev/null +++ b/v2ray_config/06_outbounds_freedom.json @@ -0,0 +1,19 @@ +{ + "outbounds": [ + { + "protocol": "freedom", + "sendThrough": "0.0.0.0", + "settings": { + "domainStrategy": "UseIP", + "redirect": ":0", + "userLevel": 0 + }, + "streamSettings": { + "sockopt": { + "mark": 255 + } + }, + "tag": "outBound_DIRECT" + } + ] +} diff --git a/v2ray_config/06_outbounds_myproxy.json b/v2ray_config/06_outbounds_myproxy.json new file mode 100644 index 0000000..451cbbb --- /dev/null +++ b/v2ray_config/06_outbounds_myproxy.json @@ -0,0 +1 @@ +{} diff --git a/v2ray_config/07_transport.json b/v2ray_config/07_transport.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/v2ray_config/07_transport.json @@ -0,0 +1 @@ +{} diff --git a/v2ray_config/08_stats.json b/v2ray_config/08_stats.json new file mode 100644 index 0000000..8721468 --- /dev/null +++ b/v2ray_config/08_stats.json @@ -0,0 +1,3 @@ +{ + "stats": {} +} diff --git a/v2ray_config/09_reverse.json b/v2ray_config/09_reverse.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/v2ray_config/09_reverse.json @@ -0,0 +1 @@ +{} diff --git a/v2ray_config/merge.sh b/v2ray_config/merge.sh new file mode 100644 index 0000000..8eae41a --- /dev/null +++ b/v2ray_config/merge.sh @@ -0,0 +1,2 @@ +#!/bin/bash +jq -rs 'reduce .[] as $item ({}; . + $item + {inbounds: (.inbounds + $item.inbounds)} + {outbounds: ($item.outbounds + .outbounds)})' *.json |sudo tee /etc/v2ray/config.json diff --git a/v2ray_config/readme.md b/v2ray_config/readme.md new file mode 100644 index 0000000..2331188 --- /dev/null +++ b/v2ray_config/readme.md @@ -0,0 +1 @@ +Fill `06_outbounds_myproxy.json` with your vmess proxy config with tag `outBound_PROXY`. diff --git a/v2ray_config/v2ray.service b/v2ray_config/v2ray.service new file mode 100644 index 0000000..c38e8f3 --- /dev/null +++ b/v2ray_config/v2ray.service @@ -0,0 +1,19 @@ +[Unit] +Description=V2Ray - A unified platform for anti-censorship +Documentation=https://v2ray.com https://guide.v2fly.org +After=network.target nss-lookup.target +Wants=network-online.target + +[Service] +Type=simple +User=nobody +#AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=yes +ExecStart=+/usr/lib/v2ray/v2ray -config /etc/v2ray/config.json +Restart=on-failure +# Don't restart in the case of configuration error +RestartPreventExitStatus=23 + +[Install] +WantedBy=multi-user.target