Browse Source

Node16: Merge upstream (#6)

* fix constant seed issue before generate password

* fix #6: remove gosu due to strict perm check and use fixed debian version

* fix #6: add custom docker image hosted by github

* Update Dockerfile (#7)

* Change pkg to nodejs 16.x to successfully build packed ZTNCUI

* Switch back to correct nodejs 14.x installation script

* docs(README.md): update nodejs environment note

Related to PR #7

* chore(node_lts.sh): backup nodejs v14 env install script

Related to #7

* update nodejs installation script

* update to node 16

* update golang builder to bullseye

* update readme

* add explanation about public IP detection

* readme.md: fix typo

Co-authored-by: Patrick Young <16604643+kmahyyg@users.noreply.github.com>
Co-authored-by: pjv <pjv@users.noreply.github.com>
key-networks 3 years ago
parent
commit
906bf4db95
3 changed files with 32 additions and 10 deletions
  1. 9 8
      Dockerfile
  2. 21 1
      README.md
  3. 2 1
      argon2g/main.go

+ 9 - 8
Dockerfile

@@ -1,5 +1,5 @@
-FROM debian:sid-slim AS builder
-ENV NODEJS_MAJOR=14
+FROM debian:bullseye-slim AS builder
+ENV NODEJS_MAJOR=16
 
 
 ARG DEBIAN_FRONTEND=noninteractive
 ARG DEBIAN_FRONTEND=noninteractive
 LABEL MAINTAINER="Key Networks https://key-networks.com"
 LABEL MAINTAINER="Key Networks https://key-networks.com"
@@ -10,10 +10,10 @@ ADD VERSION .
 WORKDIR /build
 WORKDIR /build
 RUN apt update -y && \
 RUN apt update -y && \
     apt install curl gnupg2 ca-certificates zip unzip build-essential git --no-install-recommends -y && \
     apt install curl gnupg2 ca-certificates zip unzip build-essential git --no-install-recommends -y && \
-    curl -sL -o node_lts.sh https://deb.nodesource.com/setup_lts.x && \
-    bash node_lts.sh && \
+    curl -sL -o node_inst.sh https://deb.nodesource.com/setup_${NODEJS_MAJOR}.x && \
+    bash node_inst.sh && \
     apt install -y nodejs --no-install-recommends && \
     apt install -y nodejs --no-install-recommends && \
-    rm -f node_lts.sh && \
+    rm -f node_inst.sh && \
     git clone https://github.com/key-networks/ztncui && \
     git clone https://github.com/key-networks/ztncui && \
     npm install -g node-gyp pkg && \
     npm install -g node-gyp pkg && \
     cd ztncui/src && \
     cd ztncui/src && \
@@ -22,10 +22,11 @@ RUN apt update -y && \
     zip -r /build/artifact.zip ztncui node_modules/argon2/build/Release
     zip -r /build/artifact.zip ztncui node_modules/argon2/build/Release
 
 
 # BUILD GO UTILS
 # BUILD GO UTILS
-FROM golang:buster AS argong
+FROM golang:bullseye AS argong
 WORKDIR /buildsrc
 WORKDIR /buildsrc
 COPY argon2g /buildsrc/argon2g
 COPY argon2g /buildsrc/argon2g
 COPY fileserv /buildsrc/fileserv
 COPY fileserv /buildsrc/fileserv
+ENV CGO_ENABLED=0
 RUN mkdir -p binaries && \
 RUN mkdir -p binaries && \
     cd argon2g && \
     cd argon2g && \
     go mod download && \
     go mod download && \
@@ -46,7 +47,7 @@ RUN mkdir -p binaries && \
 
 
 
 
 # START RUNNER
 # START RUNNER
-FROM debian:sid-slim AS runner
+FROM debian:bullseye-slim AS runner
 RUN apt update -y && \
 RUN apt update -y && \
     apt install curl gnupg2 ca-certificates unzip supervisor net-tools procps --no-install-recommends -y && \
     apt install curl gnupg2 ca-certificates unzip supervisor net-tools procps --no-install-recommends -y && \
     groupadd -g 2222 zerotier-one && \
     groupadd -g 2222 zerotier-one && \
@@ -72,7 +73,7 @@ COPY start_zt1.sh /start_zt1.sh
 COPY start_ztncui.sh /start_ztncui.sh
 COPY start_ztncui.sh /start_ztncui.sh
 COPY supervisord.conf /etc/supervisord.conf
 COPY supervisord.conf /etc/supervisord.conf
 
 
-RUN chmod 4755 /bin/gosu && \
+RUN chmod 0755 /bin/gosu && \
     chmod 0755 /usr/local/bin/minica && \
     chmod 0755 /usr/local/bin/minica && \
     chmod 0755 /usr/local/bin/argon2g && \
     chmod 0755 /usr/local/bin/argon2g && \
     chmod 0755 /usr/local/bin/gfileserv && \
     chmod 0755 /usr/local/bin/gfileserv && \

+ 21 - 1
README.md

@@ -13,6 +13,17 @@ Thanks to @kmahyyg for https://github.com/kmahyyg/ztncui-aio from which this bui
 ## Further information
 ## Further information
 Refer to https://github.com/key-networks/ztncui-containerized for the original documentation.
 Refer to https://github.com/key-networks/ztncui-containerized for the original documentation.
 
 
+## Build yourself
+
+```bash
+$ git clone https://github.com/key-networks/ztncui-aio
+$ docker build . -t keynetworks/ztncui:latest
+```
+
+Change `NODEJS_MAJOR` variable in Dockerfile to use different nodejs version.
+
+Never use `node_lts.x` as your installation script of nodejs whose version might changed without further notice due to time shift.
+
 ## Usage
 ## Usage
 
 
 ```bash
 ```bash
@@ -26,6 +37,8 @@ $ docker run -d -p3443:3443 -p3180:3180 \
     keynetworks/ztncui
     keynetworks/ztncui
 ```
 ```
 
 
+If their one is not updated, try `docker pull ghcr.io/kmahyyg/ztncui-aio:latest` ! (YES, We Love GitHub!)
+
 ## Supported Configuration via persistent storage
 ## Supported Configuration via persistent storage
 
 
 For ZTNCUI: https://github.com/key-networks/ztncui
 For ZTNCUI: https://github.com/key-networks/ztncui
@@ -36,7 +49,7 @@ For ZTNCUI: https://github.com/key-networks/ztncui
 |  no  | HTTPS_HOST | Only Listen on HTTPS_HOST:HTTPS_PORT | NO DEFAULT |
 |  no  | HTTPS_HOST | Only Listen on HTTPS_HOST:HTTPS_PORT | NO DEFAULT |
 | no | HTTPS_PORT | HTTPS_PORT | 3443 |
 | no | HTTPS_PORT | HTTPS_PORT | 3443 |
 | no | HTTP_PORT | HTTP_PORT | 3000 |
 | no | HTTP_PORT | HTTP_PORT | 3000 |
-| no | HTTP_ALL_INTERFACES | Listen on all interfaces | NO DEFAULT |
+| no | HTTP_ALL_INTERFACES | Listen on all interfaces, useful for reverse proxy, HTTP only | NO DEFAULT |
 
 
 This image additional specific:
 This image additional specific:
 
 
@@ -49,3 +62,10 @@ This image additional specific:
 Also, this image exposed an http server at port 3180, you could save file in `/mydata/ztncui/myfs/` to serve it. (You could use this to build your own root server and distribute planet file)
 Also, this image exposed an http server at port 3180, you could save file in `/mydata/ztncui/myfs/` to serve it. (You could use this to build your own root server and distribute planet file)
 
 
 **WARNING: IF YOU DO NOT SET PASSWORD, YOU HAVE TO USE `docker exec -it <CONTAINER NAME> bash`, and then `cat /var/log/docker-ztncui.log` to get your random password. This is gatekeeper.**
 **WARNING: IF YOU DO NOT SET PASSWORD, YOU HAVE TO USE `docker exec -it <CONTAINER NAME> bash`, and then `cat /var/log/docker-ztncui.log` to get your random password. This is gatekeeper.**
+
+## Chinese users only
+
+This script use https:///ip.sb for public IP detection purpose, which is blocked in some area of China Mainland. Under this circumstance, the program will try to detect public IP using `ifconfig` tool and might lead to unwanted result, to prevent this, make sure you set `MYADDR` environment variable when docker container is up.
+
+The upstream repo (https://github.com/kmahyyg/ztncui-aio) only accept Issues and PRs in English. Other languages will be closed directly without any further notice. If you come from some non-English countries, use Google Translate, and state that at the beginning of the text body.
+

+ 2 - 1
argon2g/main.go

@@ -7,6 +7,7 @@ import (
 	"io/ioutil"
 	"io/ioutil"
 	"log"
 	"log"
 	"math/rand"
 	"math/rand"
+	"time"
 	"os"
 	"os"
 
 
 	"golang.org/x/crypto/argon2"
 	"golang.org/x/crypto/argon2"
@@ -25,6 +26,7 @@ type PasswdDef struct {
 const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
 const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
 
 
 func RandStringBytes(n int) string {
 func RandStringBytes(n int) string {
+	rand.Seed(time.Now().UnixNano())
 	b := make([]byte, n)
 	b := make([]byte, n)
 	for i := range b {
 	for i := range b {
 		b[i] = letterBytes[rand.Intn(len(letterBytes))] // It's not safe for password purpose, but i'm lazy.
 		b[i] = letterBytes[rand.Intn(len(letterBytes))] // It's not safe for password purpose, but i'm lazy.
@@ -40,7 +42,6 @@ func main() {
 	} 
 	} 
 	log.Println("Current Password: " + password)
 	log.Println("Current Password: " + password)
 	
 	
-
 	var ag2_memory uint32 = 4096
 	var ag2_memory uint32 = 4096
 	var ag2_iter uint32 = 3
 	var ag2_iter uint32 = 3
 	var ag2_para uint8 = 1
 	var ag2_para uint8 = 1