From e6a378e3d441d9ffcd57428c4456313116d9d89c Mon Sep 17 00:00:00 2001
From: touka <touka@nopwd.lol>
Date: Fri, 5 Jul 2024 12:37:29 +0000
Subject: Basic tools

---
 vless2json.sh | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)
 create mode 100644 vless2json.sh

(limited to 'vless2json.sh')

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\"
+    }
+  ]
+}
+"
-- 
cgit v1.2.3