diff --git a/.Dockerfile b/.Dockerfile index 044feb0..7b66405 100644 --- a/.Dockerfile +++ b/.Dockerfile @@ -1,40 +1,38 @@ -FROM --platform=$BUILDPLATFORM alpine as build-env +# Build Stage +FROM --platform=$BUILDPLATFORM alpine AS build-env + COPY ./dist /dist RUN apk add --no-cache ca-certificates ARG TARGETPLATFORM RUN case $TARGETPLATFORM in \ - 'linux/386') \ - export FOLDER='default_linux_386'; \ - ;; \ - 'linux/amd64') \ - export FOLDER='default_linux_amd64_v1'; \ - ;; \ - 'linux/arm/v6') \ - export FOLDER='default_linux_arm_6'; \ - ;; \ - 'linux/arm/v7') \ - export FOLDER='default_linux_arm_7'; \ - ;; \ - 'linux/arm64') \ - export FOLDER='default_linux_arm64'; \ - ;; \ - 'linux/riscv64') \ - export FOLDER='default_linux_riscv64'; \ - ;; \ - *) echo >&2 "error: unsupported architecture '$TARGETPLATFORM'"; exit 1 ;; \ -esac \ - && mv /dist/$FOLDER /app ; \ - rm /dist -rf + 'linux/386') \ + export FOLDER='default_linux_386'; \ + ;; \ + 'linux/amd64') \ + export FOLDER='default_linux_amd64_v1'; \ + ;; \ + 'linux/arm/v6') \ + export FOLDER='default_linux_arm_6'; \ + ;; \ + 'linux/arm/v7') \ + export FOLDER='default_linux_arm_7'; \ + ;; \ + 'linux/arm64') \ + export FOLDER='default_linux_arm64'; \ + ;; \ + 'linux/riscv64') \ + export FOLDER='default_linux_riscv64'; \ + ;; \ + *) echo >&2 "error: unsupported architecture '$TARGETPLATFORM'"; exit 1 ;; \ + esac \ + && mv /dist/$FOLDER /app +# Final Stage FROM scratch - +COPY --from=build-env /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=build-env /app /app WORKDIR /app -COPY --from=build-env \ - /etc/ssl/certs/ca-certificates.crt \ - /etc/ssl/certs/ca-certificates.crt -COPY --from=build-env --chown=1000:1000 /app /app - USER 1000 ENTRYPOINT ["./glider"] diff --git a/Dockerfile b/Dockerfile index 0f2ee9c..b6e84b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,14 @@ # Build Stage FROM golang:1.18-alpine AS build-env - ADD . /src - RUN apk --no-cache add git \ && cd /src && go build -v -ldflags "-s -w" # Final Stage FROM alpine - COPY --from=build-env /src/glider /app/ - -RUN apk -U upgrade --no-cache \ - && apk --no-cache add bind-tools ca-certificates shadow tzdata \ - && groupadd -g 1000 glider \ - && useradd -r -u 1000 -g glider glider \ - && apk --no-cache del shadow \ - && chown -R glider:glider /app - WORKDIR /app -USER glider - +RUN apk -U upgrade --no-cache \ + && apk --no-cache add ca-certificates +USER 1000 ENTRYPOINT ["./glider"] diff --git a/README.md b/README.md index 9ae4361..7f6016d 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ we can set up local listeners as proxy servers, and forward requests to internet - Binary: [https://github.com/nadoo/glider/releases](https://github.com/nadoo/glider/releases) - Docker: `docker pull nadoo/glider` - ArchLinux: `sudo pacman -S glider` +- Source: `go install github.com/nadoo/glider@latest` ## Usage @@ -92,6 +93,7 @@ glider -config CONFIG_PATH ``` ```bash glider -verbose -listen :8443 -forward SCHEME://HOST:PORT +# docker run --rm -it nadoo/glider -verbose -listen :8443 ``` #### Help diff --git a/go.sum b/go.sum index 3f3cfba..23658bd 100644 --- a/go.sum +++ b/go.sum @@ -49,7 +49,6 @@ github.com/jsimonetti/rtnetlink v0.0.0-20201009170750-9c6f07d100c1/go.mod h1:hqo github.com/jsimonetti/rtnetlink v0.0.0-20201110080708-d2c240429e6c/go.mod h1:huN4d1phzjhlOsNIjFsw2SVRbwIHj3fJDMEU2SDPTmg= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/klauspost/cpuid v1.2.4/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s= github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4= github.com/klauspost/cpuid/v2 v2.0.6/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE= @@ -137,8 +136,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 h1:6mzvA99KwZxbOrxww4EvWVQUnN1+xEu9tafK5ZxkYeA= -golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220421235706-1d1ef9303861 h1:yssD99+7tqHWO5Gwh81phT+67hg+KttniBr6UnEXOY8= golang.org/x/net v0.0.0-20220421235706-1d1ef9303861/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -167,8 +164,6 @@ golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= diff --git a/proxy/socks5/server.go b/proxy/socks5/server.go index f5cb3c0..41465a0 100644 --- a/proxy/socks5/server.go +++ b/proxy/socks5/server.go @@ -163,7 +163,7 @@ func (s *Socks5) serveSession(session *Session) { case msg := <-session.msgCh: _, err = dstPC.WriteTo(msg.msg, msg.dst) if err != nil { - log.F("[socks5u] writeTo %s error: %v", nil, err) + log.F("[socks5u] writeTo %s error: %v", msg.dst, err) } pool.PutBuffer(msg.msg) msg.msg = nil