diff --git a/config/client/h2.json b/config/client/h2.json index 156944b..0e8bc45 100644 --- a/config/client/h2.json +++ b/config/client/h2.json @@ -9,12 +9,12 @@ "settings": { "vnext": [ { - "address": "233blog.com", - "port": 2333, + "address": "__VMADDR__", + "port": __VMPORT__, "users": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", - "alterId": 233, + "id": "__VMUSERID__", + "alterId": __VMALTID__, "security": "auto" } ] @@ -26,9 +26,9 @@ "security": "tls", "httpSettings": { "host": [ - "233blog.com" + "__H2DOMAIN__" ], - "path": "/233blog" + "path": "__H2PATH__" } }, "mux": { diff --git a/config/client/http.json b/config/client/http.json index 385d172..a88b520 100644 --- a/config/client/http.json +++ b/config/client/http.json @@ -9,12 +9,12 @@ "settings": { "vnext": [ { - "address": "233blog.com", - "port": 2333, + "address": "__VMADDR__", + "port": __VMPORT__, "users": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", - "alterId": 233, + "id": "__VMUSERID__", + "alterId": __VMALTID__, "security": "auto" } ] diff --git a/config/client/kcp.json b/config/client/kcp.json index 86fb479..ddc0b87 100644 --- a/config/client/kcp.json +++ b/config/client/kcp.json @@ -9,12 +9,12 @@ "settings": { "vnext": [ { - "address": "233blog.com", - "port": 2333, + "address": "__VMADDR__", + "port": __VMPORT__, "users": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", - "alterId": 233, + "id": "__VMUSERID__", + "alterId": __VMALTID__, "security": "auto" } ] diff --git a/config/client/quic.json b/config/client/quic.json index 2ffe55c..ab58c7d 100644 --- a/config/client/quic.json +++ b/config/client/quic.json @@ -9,12 +9,12 @@ "settings": { "vnext": [ { - "address": "233blog.com", - "port": 2333, + "address": "__VMADDR__", + "port": __VMPORT__, "users": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", - "alterId": 233, + "id": "__VMUSERID__", + "alterId": __VMALTID__, "security": "auto" } ] diff --git a/config/client/tcp.json b/config/client/tcp.json index 9a8b35e..103c692 100644 --- a/config/client/tcp.json +++ b/config/client/tcp.json @@ -9,12 +9,12 @@ "settings": { "vnext": [ { - "address": "233blog.com", - "port": 2333, + "address": "__VMADDR__", + "port": __VMPORT__, "users": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", - "alterId": 233, + "id": "__VMUSERID__", + "alterId": __VMALTID__, "security": "auto" } ] diff --git a/config/client/ws.json b/config/client/ws.json index f122878..fafda6b 100644 --- a/config/client/ws.json +++ b/config/client/ws.json @@ -9,12 +9,12 @@ "settings": { "vnext": [ { - "address": "233blog.com", - "port": 2333, + "address": "__VMADDR__", + "port": __VMPORT__, "users": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", - "alterId": 233, + "id": "__VMUSERID__", + "alterId": __VMALTID__, "security": "auto" } ] diff --git a/config/client/ws_tls.json b/config/client/ws_tls.json index 9f47d62..4359df2 100644 --- a/config/client/ws_tls.json +++ b/config/client/ws_tls.json @@ -9,12 +9,12 @@ "settings": { "vnext": [ { - "address": "233blog.com", - "port": 2333, + "address": "__VMADDR__", + "port": __VMPORT__, "users": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", - "alterId": 233, + "id": "__VMUSERID__", + "alterId": __VMALTID__, "security": "auto" } ] diff --git a/config/server/dynamic/http.json b/config/server/dynamic/http.json index 4661469..0965531 100644 --- a/config/server/dynamic/http.json +++ b/config/server/dynamic/http.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ], "detour": { @@ -129,6 +164,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/dynamic/kcp.json b/config/server/dynamic/kcp.json index 48e3b8b..f2533c9 100644 --- a/config/server/dynamic/kcp.json +++ b/config/server/dynamic/kcp.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ], "detour": { @@ -101,6 +136,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/dynamic/quic.json b/config/server/dynamic/quic.json index 16911b4..0f854ca 100644 --- a/config/server/dynamic/quic.json +++ b/config/server/dynamic/quic.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ], "detour": { @@ -105,6 +140,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/dynamic/tcp.json b/config/server/dynamic/tcp.json index 7c4d90b..fa6c603 100644 --- a/config/server/dynamic/tcp.json +++ b/config/server/dynamic/tcp.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ], "detour": { @@ -88,6 +123,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/dynamic/ws.json b/config/server/dynamic/ws.json index 51c889a..805ec2e 100644 --- a/config/server/dynamic/ws.json +++ b/config/server/dynamic/ws.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ], "detour": { @@ -91,6 +126,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/h2.json b/config/server/h2.json index 6be2a38..4ef95d0 100644 --- a/config/server/h2.json +++ b/config/server/h2.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ] }, @@ -84,6 +119,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/http.json b/config/server/http.json index 77e1a8b..c1009b3 100644 --- a/config/server/http.json +++ b/config/server/http.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ] }, @@ -102,6 +137,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/include/socks.json b/config/server/include/socks.json index 41aa472..070a074 100644 --- a/config/server/include/socks.json +++ b/config/server/include/socks.json @@ -1,4 +1,5 @@ { + "tag": "socks-in", "protocol": "socks", "port": 6666, "settings": { diff --git a/config/server/include/ss.json b/config/server/include/ss.json index 537ceb1..bdba112 100644 --- a/config/server/include/ss.json +++ b/config/server/include/ss.json @@ -1,4 +1,5 @@ { + "tag": "ss-in", "protocol": "shadowsocks", "port": 6666, "settings": { diff --git a/config/server/kcp.json b/config/server/kcp.json index bca8dad..6478c3d 100644 --- a/config/server/kcp.json +++ b/config/server/kcp.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ] }, @@ -74,6 +109,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/quic.json b/config/server/quic.json index 2379fd1..9e0e44c 100644 --- a/config/server/quic.json +++ b/config/server/quic.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ] }, @@ -76,6 +111,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/tcp.json b/config/server/tcp.json index 01819bf..c297a0a 100644 --- a/config/server/tcp.json +++ b/config/server/tcp.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ] }, @@ -69,6 +104,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/config/server/ws.json b/config/server/ws.json index 4a45f22..e19e5dd 100644 --- a/config/server/ws.json +++ b/config/server/ws.json @@ -1,4 +1,29 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + }, + "1": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", @@ -6,14 +31,24 @@ }, "inbounds": [ { - "port": 2333, + "listen": "127.0.0.1", + "port": 10086, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + }, + { + "tag": "vmess-in", + "port": __VMPORT__, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "__VMUSERID__", "level": 1, - "alterId": 233 + "alterId": __VMALTID__ } ] }, @@ -69,6 +104,13 @@ "routing": { "domainStrategy": "IPOnDemand", "rules": [ + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + }, { "type": "field", "ip": [ diff --git a/src/download-ssray.sh b/src/download-ssray.sh index 69685c4..70d6523 100644 --- a/src/download-ssray.sh +++ b/src/download-ssray.sh @@ -37,7 +37,7 @@ _install_ssray_service() { if [[ $systemd ]]; then install -m644 /etc/v2ray/233boy/v2ray/src/ssray.service "/lib/systemd/system/" install -m644 /etc/v2ray/233boy/v2ray/src/ssray.conf /etc/v2ray/ - sed -i "s/##REMOTEPORT##/${ssrayport}/; s/##LOCALPORT##/${ssport}/; s/##OPTION##/${ssrayopt}/;" /etc/v2ray/ssray.conf + sed -i "s/__REMOTEPORT__/${ssrayport}/; s/__LOCALPORT__/${ssport}/; s/__OPTION__/${ssrayopt}/;" /etc/v2ray/ssray.conf systemctl enable ssray else $red 暂时不资瓷...$none @@ -54,7 +54,7 @@ _update_ssray_version() { _download_ssray_file do_service restart ssray echo - echo -e " $green 更新成功啦...当前 V2Ray 版本: ${cyan}$ssray_latest_ver$none" + echo -e " $green 更新成功啦...当前 V2Ray plugin 版本: ${cyan}$ssray_latest_ver$none" echo echo -e " $yellow 温馨提示: 为了避免出现莫名其妙的问题...V2Ray 客户端的版本最好和服务器的版本保持一致$none" echo @@ -65,3 +65,10 @@ _update_ssray_version() { fi } +_uninstall_ssray() { + if [[ $systemd ]]; then + systemctl disable ssray + rm -f "/lib/systemd/system/ssray.service" /etc/v2ray/ssray.conf + fi + rm -f /usr/local/bin/v2ray-plugin +} \ No newline at end of file diff --git a/src/ss-info.sh b/src/ss-info.sh index b4f2747..6f8b469 100644 --- a/src/ss-info.sh +++ b/src/ss-info.sh @@ -22,7 +22,13 @@ if [[ $shadowsocks ]]; then echo -e "$yellow SS 链接 = ${cyan}$ss$none" echo if [[ $ssray ]]; then - echo -e "$yellow SS + V2ray - Plugin 链接 = ${cyan}$ssplugin$none" + echo -e "$yellow SS + V2ray - Plugin 地址 = ${cyan}${ssray_domain}$none" + echo + echo -e "$yellow SS + V2ray - Plugin 端口 = ${cyan}${ssrayport}$none" + echo + echo -e "$yellow SS + V2ray - Plugin 参数 = ${cyan}${clientopt}$none" + echo + echo -e "$yellow SS + V2ray - Plugin 链接 = ${cyan}${ssplugin}$none" echo fi echo -e "提示: 输入$cyan v2ray ssqr $none可生成 Shadowsocks 二维码链接" diff --git a/src/ssray.conf b/src/ssray.conf index 8cb522e..89e7426 100644 --- a/src/ssray.conf +++ b/src/ssray.conf @@ -1,5 +1,5 @@ SS_REMOTE_HOST=0.0.0.0 -SS_REMOTE_PORT=##REMOTEPORT## +SS_REMOTE_PORT=__REMOTEPORT__ SS_LOCAL_HOST=127.0.0.1 -SS_LOCAL_PORT=##LOCALPORT## -SS_PLUGIN_OPTIONS="##OPTION##" +SS_LOCAL_PORT=__LOCALPORT__ +SS_PLUGIN_OPTIONS="__OPTION__" diff --git a/src/v2ray-traffic.sh b/src/v2ray-traffic.sh new file mode 100644 index 0000000..46d303c --- /dev/null +++ b/src/v2ray-traffic.sh @@ -0,0 +1,33 @@ + +_V2CTL=/usr/bin/v2ray/v2ctl +_APISERVER=127.0.0.1:10086 + +v2_inbound() { + local inbound=$1 + local direct=$2 + $_V2CTL api --server=$_APISERVER StatsService.GetStats "name: \"inbound>>>${inbound}>>>traffic>>>${direct}\"" \ + | awk '{ + if (match($1, /name:/)){ f=1; gsub(/"$/, "", $2); split($2, p, ">>>"); print p[2]":"p[4] } + else if (match($1, /value:/)){ f=0; print $2} + else if (match($0, /^>$/) && f == 1) print "0" + else {} + }' \ + | sed '$!N;s/\n/ /; s/link//' \ + | numfmt --field=2 --suffix=B --to=iec \ + | sort \ + | column -t +} + +v2_query_all () { + $_V2CTL api --server=$_APISERVER StatsService.QueryStats '' \ + | awk '{ + if (match($1, /name:/)){ f=1; gsub(/"$/, "", $2); split($2, p, ">>>"); print p[2]":"p[4] } + else if (match($1, /value:/)){ f=0; print $2} + else if (match($0, /^>$/) && f == 1) print "0" + else {} + }' \ + | sed '$!N;s/\n/ /; s/link//' \ + | numfmt --field=2 --suffix=B --to=iec \ + | sort \ + | column -t +} diff --git a/src/vmess-config.sh b/src/vmess-config.sh index a1e81cd..e72faac 100644 --- a/src/vmess-config.sh +++ b/src/vmess-config.sh @@ -55,7 +55,7 @@ cp -f $v2ray_server_config_file $v2ray_server_config cp -f $v2ray_client_config_file $v2ray_client_config # change port, uuid, alterId -sed -i "9s/2333/$v2ray_port/; 14s/$old_id/$v2ray_id/; 16s/233/$alterId/" $v2ray_server_config +sed -i "s/__VMPORT__/$v2ray_port/; s/__VMUSERID__/$v2ray_id/; s/__VMALTID__/$alterId/" $v2ray_server_config # change dynamic port if [[ $v2ray_transport -ge 18 ]]; then @@ -66,11 +66,11 @@ fi # change domain and path, or header type case $v2ray_transport in 5) - sed -i "24s/233blog.com/$domain/" $v2ray_server_config + sed -i "s/__H2DOMAIN__/$domain/" $v2ray_server_config if [[ $is_path ]]; then - sed -i "26s/233blog/$path/" $v2ray_server_config + sed -i "s/__H2PATH__/$path/" $v2ray_server_config else - sed -i "26s/233blog//" $v2ray_server_config + sed -i "s/__H2PATH__//" $v2ray_server_config fi ;; 7 | 13 | 22 | 28) @@ -95,17 +95,16 @@ case $v2ray_transport in ;; esac -## change client config file +# change client config file [[ -z $ip ]] && get_ip +sed -i "s/__VMADDR__/$ip/; s/__VMPORT__/$v2ray_port/; s/__VMUSERID__/$v2ray_id/; s/__VMALTID__/$alterId/" $v2ray_client_config if [[ $v2ray_transport == [45] ]]; then - sed -i "s/233blog.com/$domain/; 13s/2333/443/; 16s/$old_id/$v2ray_id/; 17s/233/$alterId/" $v2ray_client_config + sed -i "s/__H2DOMAIN__/$domain/" $v2ray_client_config if [[ $is_path ]]; then - sed -i "31s/233blog/$path/" $v2ray_client_config + sed -i "s/__H2PATH__/$path/" $v2ray_client_config else - sed -i "31s/233blog//" $v2ray_client_config + sed -i "s/__H2PATH__//" $v2ray_client_config fi -else - sed -i "s/233blog.com/$ip/; 13s/2333/$v2ray_port/; 16s/$old_id/$v2ray_id/; 17s/233/$alterId/" $v2ray_client_config fi # zip -q -r -j --password "233blog.com" /etc/v2ray/233blog_v2ray.zip $v2ray_client_config diff --git a/v2ray.sh b/v2ray.sh index e9beb50..03d275a 100644 --- a/v2ray.sh +++ b/v2ray.sh @@ -33,6 +33,7 @@ if [[ -f /usr/bin/yum ]]; then fi backup="/etc/v2ray/233blog_v2ray_backup.conf" +ssraybackup="/etc/v2ray/233blog_ssray_backup.conf" if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup && -d /etc/v2ray/233boy/v2ray ]]; then @@ -57,6 +58,8 @@ if [[ $path_status ]]; then is_path=true fi +[[ -f $ssraybackup ]] && source $ssraybackup + uuid=$(cat /proc/sys/kernel/random/uuid) old_id="e55c8d17-2cf3-b21a-bcf1-eeacb011ed79" v2ray_server_config="/etc/v2ray/config.json" @@ -89,6 +92,12 @@ else caddy_run_status="$red未在运行$none" fi +ssray_transports=( + "HTTP (Websocket)" + "HTTPS (Websocket TLS)" + "QUIC (udp)" +) + _load transport.sh ciphers=( aes-128-cfb @@ -143,6 +152,13 @@ create_vmess_URL_config() { EOF fi } +view_v2ray_traffic() { + _load v2ray-traffic.sh + echo + echo + v2_query_all + echo +} view_v2ray_config_info() { _load v2ray-info.sh @@ -620,8 +636,6 @@ ssray_config() { echo -e " $red大佬...你没有配置 Shadowsocks - V2ray - Plugin $none...不过现在想要配置的话也是可以的 ^_^" echo echo - echo -e " $yellow 唉唉 现在不管有没有配置过都要重新配置的,脚本还没完善好这部分,想改就接着重新配置吧~$none..." - echo while :; do echo -e "是否配置 ${yellow}Shadowsocks - V2ray Plugin ${none} [${magenta}Y/N$none]" @@ -638,6 +652,7 @@ ssray_config() { echo ssray=true ssray_port_config + ssray_proto_config break elif [[ "$install_ssray" == [Nn] ]]; then break @@ -646,6 +661,11 @@ ssray_config() { fi done + + _download_ssray_file + ssray_apply_config + ssray_save_config + _load ss-info.sh } ssray_port_config() { @@ -666,9 +686,6 @@ ssray_port_config() { error ;; [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) - if [[ $v2ray_transport == [45] ]]; then - local tls=ture - fi if [[ $tls && $ssrayport == "80" ]] || [[ $tls && $ssrayport == "443" ]]; then echo echo -e "由于你已选择了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议." @@ -700,17 +717,10 @@ ssray_port_config() { esac done - - ssray_proto_config } ssray_proto_config() { - ssray_transports=( - "HTTP (Websocket)" - "HTTPS (Websocket TLS)" - "QUIC (udp)" - ) echo while :; do echo -e "请选择 "$yellow"V2Ray-Plugin"$none" 传输协议 [${magenta}1-${#transport[*]}$none]" @@ -781,6 +791,10 @@ ssray_proto_config() { echo -e "$yellow 噫!好像已经有证书了! 皮皮虾咋们走! $none" else echo -e "$yellow 开始安装acme.sh $none" + if ! command -v socat; then + echo -e "$red 需要安装socat $none" + exit 1 + fi curl https://get.acme.sh | bash echo -e "$yellow 开始申请 $ssray_domain 的证书,如果有正在使用80端口的程序先让它们退下~... $none" @@ -800,19 +814,87 @@ ssray_proto_config() { } change_ssray_config() { + + _load download-ssray.sh + if [[ $ssray ]]; then - echo + + + while :; do + echo + echo -e "$yellow 1. $none修改 Shadowsocks - V2ray插件 端口" + echo + echo -e "$yellow 2. $none修改 Shadowsocks - V2ray插件 协议" + echo + echo -e "$yellow 3. $none升级 Shadowsocks - V2ray插件" + echo + echo -e "$yellow 4. $none关闭 Shadowsocks - V2ray" + echo + read -p "$(echo -e "请选择 [${magenta}1-3$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + local oldssrayport=$ssrayport + ssray_port_config + ssray_save_config + ssray_apply_config + del_port $oldssrayport + open_port $ssrayport + _load ss-info.sh + break + ;; + 2) + ssray_proto_config + ssray_save_config + ssray_apply_config + _load ss-info.sh + break + ;; + 3) + _update_ssray_version + ssray_save_config + break + ;; + 4) + del_port $ssrayport + _uninstall_ssray + ssray= + install_ssray=n + rm -f $ssraybackup + break + ;; + *) + error + ;; + esac + fi + + done + else ssray_config - _load download-ssray.sh - _download_ssray_file - _install_ssray_service - open_port $ssrayport - do_service restart ssray - _load ss-info.sh fi } +ssray_save_config() { + cat > $ssraybackup << EOF +install_ssray=${install_ssray} +ssray_ver="$ssray_latest_ver" +ssray=${ssray} +ssray_transport=${ssray_transport} +ssrayport=${ssrayport} +ssray_domain="${ssray_domain}" +ssrayopt="${ssrayopt}" +EOF +} + +ssray_apply_config() { + _install_ssray_service + open_port $ssrayport + do_service restart ssray +} change_v2ray_config() { local _menu=( @@ -2609,6 +2691,12 @@ update() { update_v2ray() { _load download-v2ray.sh _update_v2ray_version + + if [[ $ssray ]]; then + _load download-ssray.sh + _update_ssray_version + ssray_save_config + fi } update_v2ray.sh() { if [[ $_test ]]; then @@ -2802,6 +2890,8 @@ _help() { ${green}v2ray update $none更新 V2Ray + ${green}v2ray traffic $none查看 V2Ray 流量 + ${green}v2ray update.sh $none更新 V2Ray 管理脚本 ${green}v2ray uninstall $none卸载 V2Ray @@ -2847,6 +2937,8 @@ menu() { echo echo -e "$yellow 11. $none其他" echo + echo -e "$yellow 12. $none查看 V2ray 流量统计" + echo echo -e "温馨提示...如果你不想执行选项...按$yellow Ctrl + C $none即可退出" echo read -p "$(echo -e "请选择菜单 [${magenta}1-9$none]:")" choose @@ -2900,6 +2992,10 @@ menu() { other break ;; + 12) + view_v2ray_traffic + break + ;; *) error ;; @@ -3030,6 +3126,9 @@ v | version) bbr) other ;; +traffic) + view_v2ray_traffic + ;; help | *) _help ;;