diff --git a/Dockerfile b/Dockerfile index 9217ac3..a9f64d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM alpine:3.17.0 -RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing shadowsocks-libev curl +RUN apk add --no-cache curl libqrencode +RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing shadowsocks-libev RUN mkdir -pv /usr/share/shadowsocks-libev/plugins RUN tag="$(curl -sSo /dev/null -w '%{redirect_url}' \ https://github.com/shadowsocks/v2ray-plugin/releases/latest | \ @@ -9,6 +10,7 @@ RUN tag="$(curl -sSo /dev/null -w '%{redirect_url}' \ RUN chmod +x /usr/share/shadowsocks-libev/plugins/v2ray-plugin ENV SERVER_HOST="${SERVER_HOST:-0.0.0.0}" +ENV SERVER_IP="${SERVER_IP:-0.0.0.0}" ENV SERVER_PORT="${SERVER_PORT:-8388}" ENV PASSWORD="${PASSWORD:-secure_password}" ENV METHOD="${METHOD:-chacha20-ietf-poly1305}" diff --git a/README.md b/README.md index cecb0a8..74ddab5 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,30 @@ ## Build -Tag is `-` - ```shell -docker build . -t ss-libev-v2ray:3.3.5-r1-1.3.2 +docker build . -t nxhs/shadowsocks-libev-v2ray:latest -t nxhs/shadowsocks-libev-v2ray:3.3.5r1-1.3.2 ``` +Tag is `-`. + ## Run ```shell docker run \ --detach \ - --name ss-v2ray \ + --name shadowsocks \ + --env SERVER_IP=your_server_ip_address \ --env PASSWORD=secure_password \ --publish 8388:8388 \ --publish 8388:8388/udp \ --restart always \ - nxhs/ss-libev-v2ray:3.3.5-r1-1.3.2 + nxhs/shadowsocks-libev-v2ray:latest +``` + +To view client connection URI and QR-code run: + +```shell +docker logs shadowsocks ``` See [client.json](client.json) for client config example. Don't forget install v2ray-plugin on client too. diff --git a/entrypoint.sh b/entrypoint.sh index cc98fd7..0b579d6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,13 +7,22 @@ if [ "$1" = "/usr/bin/ss-server" ]; then PASSWORD="$(cat "$PASSWORD_FILE")" fi - if [[ -f "/var/run/secrets/$PASSWORD_SECRET" ]]; then + if [ -f "/var/run/secrets/$PASSWORD_SECRET" ]; then PASSWORD=$(cat "/var/run/secrets/$PASSWORD_SECRET") fi - ARGS="-s $SERVER_HOST -p $SERVER_PORT -k ${PASSWORD:-$(hostname)} \ --m $METHOD -t $TIMEOUT -u $DNS --fast-open --reuse-port --plugin $PLUGIN \ ---plugin-opts $PLUGIN_OPTS $ARGS" + ARGS="-s $SERVER_HOST -p $SERVER_PORT -k $PASSWORD \ + -m $METHOD -t $TIMEOUT -u $DNS --fast-open --reuse-port \ + --plugin $PLUGIN --plugin-opts $PLUGIN_OPTS $ARGS" + + conn_uri="$(printf 'ss://%s@%s:%s?plugin=%s#%s' \ + "$(printf '%s:%s' "$METHOD" "$PASSWORD" | base64 -w 0 | tr -d =)" \ + "$SERVER_IP" "$SERVER_PORT" "${PLUGIN##*/}" "$(hostname -f)")" + + printf '\nCONNECTION URI:\n\n%s\n\n' "$conn_uri" + echo "$conn_uri" | qrencode -t ANSIUTF8 + printf '\n\n' fi -exec $@ $ARGS +# shellcheck disable=SC2086 +exec "$@" $ARGS