Skip to content

Instantly share code, notes, and snippets.

@pd12bb
Last active April 5, 2022 07:00
Show Gist options
  • Select an option

  • Save pd12bb/28220396dd1757cd7513b686896c67f6 to your computer and use it in GitHub Desktop.

Select an option

Save pd12bb/28220396dd1757cd7513b686896c67f6 to your computer and use it in GitHub Desktop.
sub2clash.sh
#!/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