├── .gitignore ├── Dockerfile ├── Dockerfile.architecture ├── LICENSE ├── README.md ├── ddnsto-dl.sh └── ddnsto-monitor.sh /.gitignore: -------------------------------------------------------------------------------- 1 | ddnsto 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for DDNSTO based alpine 2 | # Copyright (C) 2020 - 2020 Janson 3 | # Reference URL: 4 | # https://www.ddnsto.com/ 5 | 6 | FROM alpine:latest 7 | LABEL maintainer="Janson " 8 | 9 | COPY ddnsto-dl.sh /root/ddnsto-dl.sh 10 | COPY ddnsto-monitor.sh /usr/bin/ddnsto-monitor.sh 11 | #COPY ddnsto /usr/bin/ddnsto 12 | RUN set -ex \ 13 | && chmod +x /root/ddnsto-dl.sh \ 14 | && /root/ddnsto-dl.sh 15 | 16 | RUN chmod +x /usr/bin/ddnsto-monitor.sh /usr/bin/ddnsto 17 | 18 | ENV TZ=Asia/Shanghai 19 | ENV TOKEN= 20 | ENV DEVICE_IDX=0 21 | ENV LOG_LEVEL=2 22 | ENV DDNSTO_CONFIG=/ddnsto-config 23 | 24 | CMD [ "/usr/bin/ddnsto-monitor.sh"] 25 | -------------------------------------------------------------------------------- /Dockerfile.architecture: -------------------------------------------------------------------------------- 1 | # Dockerfile for DDNSTO based alpine 2 | # Copyright (C) 2020 - 2020 Janson 3 | # Reference URL: 4 | # https://www.ddnsto.com/ 5 | 6 | FROM --platform=${TARGETPLATFORM} alpine:latest 7 | LABEL maintainer="Janson " 8 | 9 | ARG TARGETPLATFORM 10 | COPY ddnsto-dl.sh /root/ddnsto-dl.sh 11 | COPY ddnsto-monitor.sh /usr/bin/ddnsto-monitor.sh 12 | RUN set -ex \ 13 | && chmod +x /root/ddnsto-dl.sh \ 14 | && /root/ddnsto-dl.sh "${TARGETPLATFORM}" 15 | RUN chmod +x /usr/bin/ddnsto-monitor.sh 16 | ENV TZ=Asia/Shanghai 17 | ENV TOKEN= 18 | ENV DEVICE_IDX=0 19 | ENV LOG_LEVEL=2 20 | 21 | CMD [ "/usr/bin/ddnsto-monitor.sh"] 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 易有云团队 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker_ddnsto 2 | 3 | DDNSTO 帮助你快速外网穿透访问你的局域网设备,无需公网 IP 4 | 5 | ## build test 6 | 7 | docker build -t linkease/ddnsto . 8 | 9 | ## Usage 10 | 11 | TOKEN: 你从 [官网](https://www.ddnsto.com) 拿到的 token 12 | 13 | DEVICE_IDX: 默认 0,如果设备 ID 重复则为 1-100 之间,Docker 有时候生成一模一样的设备 ID,导致无法连接服务器 14 | 15 | /your/config-path/ddnsto-config 是你的配置文件,保证重启之后,设备 ID 不变。每个 Docker 都应该设置不同的配置文件路径 16 | 17 | ``` 18 | docker run -d \ 19 | --name= \ 20 | -e TOKEN=<填入你的token> \ 21 | -e DEVICE_IDX=<默认0,如果设备ID重复则为1-100之间> \ 22 | -v /etc/localtime:/etc/localtime:ro \ 23 | -v /your/config-path/ddnsto-config:/ddnsto-config \ 24 | -e PUID= \ 25 | -e PGID= \ 26 | linkease/ddnsto 27 | ``` 28 | 29 | 比如我实际运行的例子: 30 | ``` 31 | docker run -d \ 32 | --name=ddnstotest \ 33 | -e TOKEN=xxxxxxxx-xxxx-xx28-bdf4-246e98afxxxx \ 34 | -e DEVICE_IDX=0 \ 35 | -v /etc/localtime:/etc/localtime:ro \ 36 | -v /projects/test/ddnsto-config:/ddnsto-config \ 37 | linkease/ddnsto 38 | ``` 39 | 40 | ## 镜像地址 41 | 42 | https://hub.docker.com/r/linkease/ddnsto/ 43 | 44 | -------------------------------------------------------------------------------- /ddnsto-dl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PLATFORM=$1 4 | if [ -z "$PLATFORM" ]; then 5 | DDNSTO_FILE="x64" 6 | else 7 | case "$PLATFORM" in 8 | linux/386) 9 | DDNSTO_FILE="" 10 | ;; 11 | linux/amd64) 12 | DDNSTO_FILE="x64" 13 | ;; 14 | linux/arm/v6) 15 | DDNSTO_FILE="arm" 16 | ;; 17 | linux/arm/v7) 18 | DDNSTO_FILE="arm" 19 | ;; 20 | linux/arm64|linux/arm64/v8) 21 | DDNSTO_FILE="aarch64" 22 | ;; 23 | linux/ppc64le) 24 | DDNSTO_FILE="" 25 | ;; 26 | linux/s390x) 27 | DDNSTO_FILE="" 28 | ;; 29 | *) 30 | DDNSTO_FILE="" 31 | ;; 32 | esac 33 | fi 34 | [ -z "${DDNSTO_FILE}" ] && echo "Error: Not supported OS Architecture" && exit 1 35 | 36 | echo "Downloading binary file: ${DDNSTO_FILE}" 37 | wget --no-check-certificate -O /usr/bin/ddnsto https://fw.koolcenter.com/binary/ddnsto/linux/${DDNSTO_FILE}/ddnsto >/dev/null 2>&1 38 | if [ $? -ne 0 ]; then 39 | echo "Error: Failed to download binary file: ${DDNSTO_FILE}" && exit 1 40 | fi 41 | echo "Download binary file: ${DDNSTO_FILE} completed" 42 | 43 | chmod +x /usr/bin/ddnsto 44 | 45 | -------------------------------------------------------------------------------- /ddnsto-monitor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "${TOKEN}" ]; then 4 | echo "the token is empty, get token from https://www.ddnsto.com/ " 5 | exit 2 6 | fi 7 | 8 | ln -s /ddnsto-config/.ddnsto_boot.cfg /usr/bin/.ddnsto_boot.cfg || true 9 | 10 | echo "ddnsto version device_id is is:" 11 | /usr/bin/ddnsto -u ${TOKEN} -w 12 | 13 | while true ; do 14 | if ! pidof "ddnsto" > /dev/null ; then 15 | echo "ddnsto try running" 16 | /usr/bin/ddnsto -u ${TOKEN} -x ${DEVICE_IDX} -l ${LOG_LEVEL} 17 | RET=$? 18 | echo "EXIT CODE: ${RET}" 19 | if [ "${RET}" == "100" ]; then 20 | echo "token error, please set a correct token from https://www.ddnsto.com/ " 21 | exit 100 22 | fi 23 | fi 24 | sleep 20 25 | done 26 | 27 | --------------------------------------------------------------------------------