summaryrefslogtreecommitdiff
path: root/vless2json.sh
diff options
context:
space:
mode:
authortouka <touka@nopwd.lol>2024-07-05 12:37:29 +0000
committertouka <touka@nopwd.lol>2024-07-05 12:37:29 +0000
commite6a378e3d441d9ffcd57428c4456313116d9d89c (patch)
treec6eadfb7eb52198b4e4ede99c7baa8d72dd7e3df /vless2json.sh
Basic toolsHEADmain
Diffstat (limited to 'vless2json.sh')
-rw-r--r--vless2json.sh113
1 files changed, 113 insertions, 0 deletions
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\"
+ }
+ ]
+}
+"