Last active
April 5, 2022 07:00
-
-
Save pd12bb/28220396dd1757cd7513b686896c67f6 to your computer and use it in GitHub Desktop.
sub2clash.sh
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 | |
| urlencode() { | |
| # urlencode <string> | |
| old_lang=$LANG | |
| LANG=C | |
| old_lc_collate=$LC_COLLATE | |
| LC_COLLATE=C | |
| local length="${#1}" | |
| for (( i = 0; i < length; i++ )); do | |
| local c="${1:i:1}" | |
| case $c in | |
| [a-zA-Z0-9.~_-]) printf "$c" ;; | |
| *) printf '%%%02X' "'$c" ;; | |
| esac | |
| done | |
| LANG=$old_lang | |
| LC_COLLATE=$old_lc_collate | |
| } | |
| endPoint='https://api.sublink.dev/sub?' | |
| target='clash' | |
| url=$(cat "$1" | base64 -d -w 0) | |
| curl "${endPoint}target=${target}&url=$(urlencode "${url}"| sed -e 's/%0A/%7C/g')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment