Browse Source

update ip check logic

kmahyyg 4 years ago
parent
commit
62512d3d5e
2 changed files with 8 additions and 2 deletions
  1. 1 1
      Dockerfile
  2. 7 1
      start_ztncui.sh

+ 1 - 1
Dockerfile

@@ -46,7 +46,7 @@ RUN mkdir -p binaries && \
 # START RUNNER
 FROM debian:sid-slim AS runner
 RUN apt update -y && \
-    apt install curl gnupg2 ca-certificates unzip supervisor net-tools --no-install-recommends -y && \
+    apt install curl gnupg2 ca-certificates unzip supervisor net-tools procps --no-install-recommends -y && \
     curl -sL -o ztone.sh https://install.zerotier.com && \
     bash ztone.sh && \
     rm -f ztone.sh && \

+ 7 - 1
start_ztncui.sh

@@ -3,7 +3,13 @@
 if [ -z $MYADDR ]; then
     echo "Set Your IP Address to continue."
     echo "If you don't do that, I will automatically detect."
-    MYADDR=$(curl ip.sb)
+    MYEXTADDR=$(curl --connect-timeout 5 ip.sb)
+    if [ -z $MYEXTADDR ]; then
+        MYINTADDR=$(ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
+        MYADDR=${MYINTADDR}
+    else
+        MYADDR=${MYEXTADDR}
+    fi
     echo "YOUR IP: ${MYADDR}"
 fi