Skip to content

Instantly share code, notes, and snippets.

@zjx20
Created April 1, 2026 08:40
Show Gist options
  • Select an option

  • Save zjx20/7f86b74750f4441c747b9df501cfe22a to your computer and use it in GitHub Desktop.

Select an option

Save zjx20/7f86b74750f4441c747b9df501cfe22a to your computer and use it in GitHub Desktop.
Converting v2ray json config (client side) into V2RayN style subscription links
#!/bin/bash
# brew install jq
# brew install qrencode
config_file=v2rayx*.json
rss_file=rss.txt
cat $config_file | \
jq -r '
def user: .settings.vnext[0].users[0];
def vnext: .settings.vnext[0];
def header_host:
(.streamSettings.wsSettings.headers // {}) as $h |
($h | to_entries | map(select(.key|ascii_downcase == "host")) | .[0]?.value // "");
def net:
.streamSettings.network // "tcp";
def type:
if net == "tcp" then
(.streamSettings.tcpSettings.header.type // "none")
elif net == "kcp" then
(.streamSettings.kcpSettings.header.type // "none")
elif net == "quic" then
(.streamSettings.quicSettings.security // "none")
else
"none"
end;
def host:
if net == "ws" then
header_host
elif net == "http" then
((.streamSettings.tcpSettings.header.request.headers.Host // []) | join(","))
elif net == "h2" then
(.streamSettings.httpSettings.host[0] // "")
else
""
end;
def path:
if net == "ws" then
(.streamSettings.wsSettings.path // "")
elif net == "h2" then
(.streamSettings.httpSettings.path // "")
elif net == "quic" then
(.streamSettings.quicSettings.key // "")
elif net == "kcp" then
(.streamSettings.kcpSettings.seed // "")
elif net == "grpc" then
(.streamSettings.grpcSettings.serviceName // "")
else
""
end;
def tls:
if .streamSettings.security == "tls" then "tls" else "" end;
def sni:
if .streamSettings.security == "tls" then
(.streamSettings.tlsSettings.serverName // "")
else
""
end;
def alpn:
if .streamSettings.security == "tls" then
((.streamSettings.tlsSettings.alpn // []) | join(","))
else
""
end;
def fp:
(.streamSettings.tlsSettings.fingerprint // "");
.outbounds
| map(select(.protocol == "vmess"))
| .[]
| {
v: "2",
ps: (.tag // ""),
add: (vnext.address // ""),
port: ((vnext.port // "") | tostring),
id: (user.id // ""),
aid: ((user.alterId // 0) | tostring),
scy: (user.security // "auto"),
net: net,
type: type,
host: host,
path: path,
tls: tls,
sni: sni,
alpn: alpn,
fp: fp
}
| "vmess://"
+ (@json | @base64)
' | \
base64 > "$rss_file"
# put $rss_file to somewhere, then your qr code for the subscribe link is
rss_url="https://yourserver/rss.txt"
qrencode -t ANSI "$(echo -n "sub://$(echo -n "$rss_url" | base64)")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment