Skip to content

Instantly share code, notes, and snippets.

@sh1n0b1
Last active February 23, 2019 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sh1n0b1/badbd593c1e195f8ef99d35dae899d33 to your computer and use it in GitHub Desktop.
Save sh1n0b1/badbd593c1e195f8ef99d35dae899d33 to your computer and use it in GitHub Desktop.
Parse Shaodowsocks Config and encoded it to an Outline Shadowsocks URI
# Ensure jq 1.5 or greater is installed on your linux system
# ex. apt-get install jq or https://stackoverflow.com/questions/36462955/upgrading-jq-to-1-5-on-ubuntu?answertab=votes#tab-top
#
# If you have a single port/password config like the following:
# {
# "server":"my_server_ip",
# "server_port":8388,
# "local_address": "127.0.0.1",
# "local_port":1080,
# "password":"mypassword",
# "timeout":300,
# "method":"aes-256-cfb",
# "fast_open": false
# }
# Replace the JSON path below with the path to your shadowsocks config file
ENCODED=$(jq -j --arg IP $(curl -s ifconfig.me) '.method +":"+.password+"@"+$IP+":"+(.server_port|tostring)' /etc/shadowsocks_config.json | base64 -w 0) && echo -ne "\033[0;31mss://$ENCODED#$(hostname)\033[0m\n"
# If you have multiple port/password config setup like the following:
# {
# "server":"0.0.0.0",
# "port_password": {
# "12345": "abcdepassword...",
# "23456": "zyxwvpassword..."
# },
# "local_address":"127.0.0.1",
# "local_port":1234,
# "timeout":300,
# "method":"chacha20-ietf-poly1305",
# "fast_open":false
# }
# Use the following command instead. Replace the REPLACE_WITH_PORT_NUMBER with the port number below (ex. 12345 and 23456 from above):
ENCODED=$(jq -j --arg IP $(curl -s ifconfig.me) '.method + ":" +.port_password."REPLACE_WITH_PORT_NUMBER"+"@"+$IP+":REPLACE_WITH_PORT_NUMBER"' /etc/shadowsocks.json | base64 -w 0) && echo -ne "\033[0;31mss://$ENCODED#$(hostname)\033[0m\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment