From 3f2eea2b69cf7dd056e7320fdff33638200e8ebb Mon Sep 17 00:00:00 2001 From: BOYPT Date: Sat, 23 Feb 2019 19:07:38 +0800 Subject: [PATCH] use keyword for sed --- config/client/h2.json | 12 ++++++------ config/client/http.json | 8 ++++---- config/client/kcp.json | 8 ++++---- config/client/quic.json | 8 ++++---- config/client/tcp.json | 8 ++++---- config/client/ws.json | 8 ++++---- config/client/ws_tls.json | 8 ++++---- config/server/dynamic/http.json | 6 +++--- config/server/dynamic/kcp.json | 6 +++--- config/server/dynamic/quic.json | 6 +++--- config/server/dynamic/tcp.json | 6 +++--- config/server/dynamic/ws.json | 6 +++--- config/server/h2.json | 6 +++--- config/server/http.json | 6 +++--- config/server/kcp.json | 6 +++--- config/server/quic.json | 6 +++--- config/server/tcp.json | 6 +++--- config/server/ws.json | 6 +++--- src/vmess-config.sh | 17 ++++++++--------- 19 files changed, 71 insertions(+), 72 deletions(-) diff --git a/config/client/h2.json b/config/client/h2.json index 156944b..bdcf9d7 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..d1aaf4e 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..a1279a6 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..29c4fbc 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..ef10735 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..c13c970 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..f1a81aa 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 35cb038..a971719 100644 --- a/config/server/dynamic/http.json +++ b/config/server/dynamic/http.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ], "detour": { diff --git a/config/server/dynamic/kcp.json b/config/server/dynamic/kcp.json index ddf9bd7..f67cab2 100644 --- a/config/server/dynamic/kcp.json +++ b/config/server/dynamic/kcp.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ], "detour": { diff --git a/config/server/dynamic/quic.json b/config/server/dynamic/quic.json index b65a6c6..11a4e7d 100644 --- a/config/server/dynamic/quic.json +++ b/config/server/dynamic/quic.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ], "detour": { diff --git a/config/server/dynamic/tcp.json b/config/server/dynamic/tcp.json index 7662492..c28a249 100644 --- a/config/server/dynamic/tcp.json +++ b/config/server/dynamic/tcp.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ], "detour": { diff --git a/config/server/dynamic/ws.json b/config/server/dynamic/ws.json index d57d632..299110a 100644 --- a/config/server/dynamic/ws.json +++ b/config/server/dynamic/ws.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ], "detour": { diff --git a/config/server/h2.json b/config/server/h2.json index e49b59f..9920894 100644 --- a/config/server/h2.json +++ b/config/server/h2.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ] }, diff --git a/config/server/http.json b/config/server/http.json index fe7dcd6..9d90b20 100644 --- a/config/server/http.json +++ b/config/server/http.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ] }, diff --git a/config/server/kcp.json b/config/server/kcp.json index bbdc8dd..07a55fe 100644 --- a/config/server/kcp.json +++ b/config/server/kcp.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ] }, diff --git a/config/server/quic.json b/config/server/quic.json index b15be9a..022ccfa 100644 --- a/config/server/quic.json +++ b/config/server/quic.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ] }, diff --git a/config/server/tcp.json b/config/server/tcp.json index 2b70122..dc76dc6 100644 --- a/config/server/tcp.json +++ b/config/server/tcp.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ] }, diff --git a/config/server/ws.json b/config/server/ws.json index 2a5f302..2d3ee11 100644 --- a/config/server/ws.json +++ b/config/server/ws.json @@ -41,14 +41,14 @@ }, { "tag": "vmess-in", - "port": 2333, + "port": ##VMPORT##, "protocol": "vmess", "settings": { "clients": [ { - "id": "e55c8d17-2cf3-b21a-bcf1-eeacb011ed79", + "id": "##VMUSERID##", "level": 1, - "alterId": 233 + "alterId": ##VMALTID## } ] }, diff --git a/src/vmess-config.sh b/src/vmess-config.sh index a1e81cd..7143780 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) @@ -97,15 +97,14 @@ esac ## 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