Last active
May 31, 2024 23:24
-
-
Save zjx20/25dff5a670ca55d8aba223f508691dfb to your computer and use it in GitHub Desktop.
Convert v2ray config.json (client side) to a subscription content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# brew install jq | |
# brew install qrencode | |
config_file=v2rayx*.json | |
rss_file=rss.txt | |
cat $config_file | \ | |
jq --raw-output ' | |
def cred: | |
"\(.settings.vnext[0].users[0].security):\(.settings.vnext[0].users[0].id)@\(.settings.vnext[0].address):\(.settings.vnext[0].port)" | |
; | |
def network: | |
if .streamSettings.network == "ws" then | |
"path=\(.streamSettings.wsSettings.path)&obfs=websocket&obfsParam=\(.streamSettings.tlsSettings.serverName)" | |
else | |
"obfs=none" | |
end | |
; | |
def tls: | |
if .streamSettings.security == "tls" then | |
"tls=1&peer=\(.streamSettings.tlsSettings.serverName)" | |
else | |
"tls=0" | |
end | |
; | |
def mux: | |
if .mux?.enabled? then "mux=1" else "mux=0" end | |
; | |
def alterid: | |
"\(.settings.vnext[0].users[0].alterId)" | |
; | |
.outbounds | map(select(.protocol == "vmess")) | .[] | | |
cred as $cred | | |
network as $network | | |
tls as $tls | | |
mux as $mux | | |
alterid as $alterid | | |
{ cred: $cred, remarks: .tag, network: $network, tls: $tls, mux: $mux, alterid: $alterid } | | |
.cred = @base64 "\(.cred)" | .remarks = @uri "\(.remarks)" | | |
"vmess://\(.cred)?remarks=\(.remarks)&\(.network)&\(.tls)&\(.mux)&alterId=\(.alterid)"' | \ | |
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 "sub://$(echo "$rss_url" | base64)") |
@mulezic Sorry, I can't help you if you are not familiar with this IT stuff (e.g. shell scripts, base64 encoding, etc.). Maybe you can say more about what you're trying to do, and maybe it can be solved in a different way.
I created my own V2ray proxy servers using some scripts I found on YouTube.
I have been doing this for some using scripts that generate my V2ray server
account in a QR Code format where I just have to scan the code into my
V2ray client or the Vmess/Vless URL format where I just copy and import
into a V2ray client. Now, the challenge I have is that the recent script I
found only gives the option to save your created server account in JSON
format. With JSON format, I'm limited to VPN clients I can import my
servers in since most of them do not support JSON format. So, I thought
there was a way I could convert a JSON file to a common Vmess, Vless URL
format. I don't know if I'm making sense.
…On Tue, Feb 6, 2024 at 5:08 PM zjx20 ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
@mulezic <https://github.com/mulezic> Sorry, I can't help you if you are
not familiar with this IT stuff (e.g. shell scripts, base64 encoding,
etc.). Maybe you can say more about what you're trying to do, and maybe it
can be solved in a different way.
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/zjx20/25dff5a670ca55d8aba223f508691dfb#gistcomment-4879768>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A7TWRUUT3BTZ652Z3EOEN23YSJBNTBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTAMRZHEZTONBYU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you were mentioned.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
@mulezic OK, I understand. You can tell me what server software or script you are using, what client you are planning to use, and also a sample json config (without sensitive information). I can help you determine the feasibility of the situation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@zjx20
I would also love to know how to convert a JSON file to a URL, but the English of "base64 decode output file" is just way too much for me, I'm not an IT guy.