diff options
author | touka <touka@nopwd.lol> | 2024-07-05 12:37:29 +0000 |
---|---|---|
committer | touka <touka@nopwd.lol> | 2024-07-05 12:37:29 +0000 |
commit | e6a378e3d441d9ffcd57428c4456313116d9d89c (patch) | |
tree | c6eadfb7eb52198b4e4ede99c7baa8d72dd7e3df |
-rw-r--r-- | proxy.sh | 51 | ||||
-rw-r--r-- | vless2json.sh | 113 |
2 files changed, 164 insertions, 0 deletions
diff --git a/proxy.sh b/proxy.sh new file mode 100644 index 0000000..2469fc0 --- /dev/null +++ b/proxy.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env dash +# update sub and change proxy +# author: touka@nopwd.lol + +# ============================ +# FIRST READ THE SCRIPT!! +echo "FIRST READ THE SCRIPT!!" +exit +# ============================ + +set -e + +# -- change it to your needs -- +V2RAY_CONFIG=$HOME/.config/v2ray +V2RAY_SUB="https://your-v2ray-sub-link" +OFFSET=3 # line number of first vless link in the decoded links. +# ----------------------------- + +if [ "$#" -eq 0 ]; then +printf "Usage: + $0 [OPTION?] +Options: + n Update subscription + c [number] Change link(to number default first) +" +exit +fi + +cd $V2RAY_CONFIG + +case "$1" in + n) + curl -s -L -o proxies-encode.txt $V2RAY_SUB + base64 -d proxies-encode.txt > proxies.txt + echo "$0: updated subscription" + ;; + c) + linkn=0 + if [ ! -z $2 ]; then + linkn=$2 + fi + awk 'NR==$linkn+$OFFSET' proxies.txt > proxy$linkn.txt + echo "$0: selected proxy $linkn" + vless2json.sh proxy$linkn.txt > config.json + echo "$0: created config.json" + ;; + *) + echo "$0: wrong option" + ;; +esac + diff --git a/vless2json.sh b/vless2json.sh new file mode 100644 index 0000000..88f85a1 --- /dev/null +++ b/vless2json.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env dash +# vless to v2ray config converter +# author: touka@nopwd.lol +# version: 0.2 + +# ============================ +# FIRST READ THE SCRIPT!! +echo "FIRST READ THE SCRIPT!!" +exit +# ============================ + +# -- change it to your needs -- + +port=2081 +protocol='http' + +# ----------------------------- + +set -e + +if [ "$#" -ne 1 ]; then + echo "Usage: + dash $0 vless.txt > config.json +" + exit +fi + +user=$(trurl -g '{user}' -f $1 ) +address=$(trurl -g '{host}' -f $1) +out_port=$(trurl -g '{port}' -f $1) +path=$(trurl -g '{query:path}' -f $1) +security=$(trurl -g '{query:security}' -f $1) +encryption=$(trurl -g '{query:encryption}' -f $1) +host=$(trurl -g '{query:host}' -f $1) +fp=$(trurl -g '{query:fp}' -f $1) +type=$(trurl -g '{query:type}' -f $1) +name=$(trurl -g '{fragment}' -f $1) + +if [ -z "$encryption" ]; then + encryption="none" +fi + +echo " +{ + \"log\": { + \"loglevel\": \"warning\" + }, + \"inbounds\" : [ + { + \"listen\" : \"127.0.0.1\", + \"port\" : $port, + \"protocol\" : \"$protocol\", + \"settings\" : { + \"auth\" : \"noauth\", + \"udp\" : true + }, + \"sniffing\" : { + \"destOverride\" : [ + \"http\", + \"tls\", + \"quic\", + \"fakedns\" + ], + \"enabled\" : false, + \"routeOnly\" : true + }, + \"tag\" : \"http\" + } + ], + \"outbounds\" : [ + { + \"protocol\" : \"vless\", + \"settings\" : { + \"vnext\" : [ + { + \"address\" : \"$address\", + \"port\" : $out_port, + \"users\" : [ + { + \"encryption\" : \"$encryption\", + \"id\" : \"$user\" + } + ] + } + ] + }, + \"streamSettings\" : { + \"network\" : \"$type\", + \"security\" : \"$security\", + \"tlsSettings\": { + \"fingerprint\": \"$fp\", + \"servername\": \"$host\" + }, + \"wsSettings\" : { + \"headers\" : { + \"Host\" : \"$host\" + }, + \"path\" : \"$path\" + } + }, + \"tag\" : \"proxy\" + }, + { + \"protocol\" : \"freedom\", + \"tag\" : \"direct\" + }, + { + \"protocol\" : \"blackhole\", + \"tag\" : \"block\" + } + ] +} +" |