Skip to content

Commit 9d5cead

Browse files
authored
3proxy updated up to 0.9.3 (#1)
1 parent bad8266 commit 9d5cead

11 files changed

+207
-78
lines changed

.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.editorconfig
2+
.git
3+
.github
4+
.idea
5+
.vscode
6+
temp
7+
tmp
8+
LICENSE

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @link <https://help.github.com/en/articles/about-code-owners>
2+
3+
* @tarampampam

.github/dependabot.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Docs: <https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/customizing-dependency-updates>
2+
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
reviewers:
10+
- "tarampampam"
11+
assignees:
12+
- "tarampampam"
13+
14+
- package-ecosystem: "docker"
15+
directory: "/"
16+
schedule:
17+
interval: "weekly"
18+
reviewers:
19+
- "tarampampam"
20+
assignees:
21+
- "tarampampam"

.github/labeler.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
docs:
2+
- '**/*.md'
3+
- '**/*.MD'
4+
5+
.github:
6+
- '.github/**/*'
7+
8+
CI:
9+
- '.github/workflows/**/*'
10+
- '.github/actions/**/*'
11+
12+
docker:
13+
- 'Dockerfile'
14+
- 'docker/**/*'
15+
- '.dockerignore'
16+
- 'docker-entrypoint.sh'
17+
- '3proxy.cfg'
18+
19+
dev:
20+
- '.gitignore'
21+
- '.editorconfig'

.github/workflows/labeler.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: labeler
2+
3+
on: [pull_request_target]
4+
5+
jobs:
6+
triage:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- uses: actions/labeler@v3 # Action page: <https://github.com/actions/labeler>
10+
with:
11+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
12+
sync-labels: true

.github/workflows/release.yml

+18-13
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,27 @@ jobs:
1212
- name: Check out code
1313
uses: actions/checkout@v2
1414

15-
- name: Generate image tag value
16-
run: echo "::set-env name=IMAGE_TAG::${GITHUB_REF##*/[vV]}" # `/refs/tags/v1.2.3` -> `1.2.3`
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v1 # Action page: <https://github.com/docker/setup-buildx-action>
17+
id: buildx
1718

18-
- name: Make docker login
19+
- name: Docker login in default registry
1920
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_LOGIN }}" --password-stdin &> /dev/null
2021

22+
- name: Docker login in ghcr.io # Auth docs: <https://git.io/JLDaw>
23+
run: echo "${{ secrets.GHCR_PASSWORD }}" | docker login ghcr.io -u tarampampam --password-stdin
24+
25+
- name: Generate image tag value
26+
id: tag
27+
run: echo "::set-output name=value::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`" # `/refs/tags/v1.2.3` -> `1.2.3`
28+
2129
- name: Build image
2230
run: |
23-
docker build \
24-
--build-arg "BUILD_DATE=`date -u +'%Y-%m-%dT%H:%M:%SZ'`" \
25-
--tag "tarampampam/3proxy:${IMAGE_TAG}" \
31+
docker buildx build \
32+
--platform ${{ steps.buildx.outputs.platforms }} \
33+
--tag "tarampampam/3proxy:${{ steps.tag.outputs.value }} \
2634
--tag "tarampampam/3proxy:latest" \
27-
-f ./Dockerfile .
28-
29-
- name: Push version image
30-
run: docker push "tarampampam/3proxy:${IMAGE_TAG}"
31-
32-
- name: Push latest image
33-
run: docker push "tarampampam/3proxy:latest"
35+
--tag "ghcr.io/tarampampam/3proxy:${{ steps.tag.outputs.value }}" \
36+
--tag "ghcr.io/tarampampam/3proxy:latest" \
37+
--push \
38+
.

.github/workflows/tests.yml

+54-29
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,64 @@ on:
1111
- cron: '0 0 * * 0' # once in a week, docs: <https://git.io/JvxXE#onschedule>
1212

1313
jobs: # Docs: <https://git.io/JvxXE>
14-
docker-image:
15-
name: Build and use docker image
16-
runs-on: ubuntu-latest
14+
build-image:
15+
name: Build docker image
16+
runs-on: ubuntu-20.04
1717
steps:
1818
- name: Check out code
1919
uses: actions/checkout@v2
2020

2121
- name: Build docker image
22-
run: docker build -f ./Dockerfile --tag image:local .
22+
run: docker build -f ./Dockerfile --tag 3proxy:local .
2323

24-
- name: Run docker image with default settings
25-
run: |
26-
docker run --rm -d \
27-
-p "3128:3128/tcp" \
28-
-p "1080:1080/tcp" \
29-
image:local
24+
- name: Scan image
25+
uses: anchore/scan-action@v2 # action page: <https://github.com/anchore/scan-action>
26+
with:
27+
image: 3proxy:local
28+
fail-build: true
29+
severity-cutoff: low # negligible, low, medium, high or critical
30+
31+
- name: Save docker image
32+
run: docker save 3proxy:local > ./docker-image.tar
33+
34+
- name: Upload artifact
35+
uses: actions/upload-artifact@v2
36+
with:
37+
name: docker-image
38+
path: ./docker-image.tar
39+
40+
try-to-use:
41+
name: Build and use docker image (auth ${{ matrix.auth }})
42+
runs-on: ubuntu-20.04
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
auth: [yes, no]
47+
needs: [build-image]
48+
steps:
49+
- name: Download builded docker image
50+
uses: actions/download-artifact@v2
51+
with:
52+
name: docker-image
53+
path: .artifact
54+
55+
- name: Prepare image to run
56+
working-directory: .artifact
57+
run: docker load < docker-image.tar
58+
59+
- name: Start server without auth setup
60+
if: matrix.auth != 'yes'
61+
run: docker run --rm -d -p "3128:3128/tcp" -p "1080:1080/tcp" 3proxy:local
62+
63+
- name: Start server with auth setup
64+
if: matrix.auth == 'yes'
65+
run: docker run --rm -d -p "3128:3128/tcp" -p "1080:1080/tcp" -e "PROXY_LOGIN=evil" -e "PROXY_PASSWORD=live" 3proxy:local
3066

3167
- name: Pause
32-
run: sleep 2
68+
run: sleep 3
3369

3470
- name: Try to use HTTP proxy
71+
if: matrix.auth != 'yes'
3572
run: |
3673
curl -v --fail \
3774
--proxy http://127.0.0.1:3128 \
@@ -40,29 +77,16 @@ jobs: # Docs: <https://git.io/JvxXE>
4077
https://github.com/robots.txt
4178
4279
- name: Try to use SOCKS proxy
80+
if: matrix.auth != 'yes'
4381
run: |
4482
curl -v --fail \
4583
--proxy socks5://127.0.0.1:1080 \
4684
--connect-timeout 3 \
4785
--max-time 3 \
4886
https://github.com/robots.txt
4987
50-
- name: Stop container
51-
run: docker stop $(docker ps -a --filter ancestor=image:local -q)
52-
53-
- name: Run docker image with auth settings
54-
run: |
55-
docker run --rm -d \
56-
-p "3128:3128/tcp" \
57-
-p "1080:1080/tcp" \
58-
-e "PROXY_LOGIN=evil" \
59-
-e "PROXY_PASSWORD=live" \
60-
image:local
61-
62-
- name: Pause
63-
run: sleep 2
64-
65-
- name: Try to use HTTP proxy
88+
- name: Try to use HTTP proxy (with auth)
89+
if: matrix.auth == 'yes'
6690
run: |
6791
curl -v --fail \
6892
--proxy http://127.0.0.1:3128 \
@@ -71,7 +95,8 @@ jobs: # Docs: <https://git.io/JvxXE>
7195
--max-time 3 \
7296
https://github.com/robots.txt
7397
74-
- name: Try to use SOCKS proxy
98+
- name: Try to use SOCKS proxy (with auth)
99+
if: matrix.auth == 'yes'
75100
run: |
76101
curl -v --fail \
77102
--proxy socks5://127.0.0.1:1080 \
@@ -81,4 +106,4 @@ jobs: # Docs: <https://git.io/JvxXE>
81106
https://github.com/robots.txt
82107
83108
- name: Stop container
84-
run: docker stop $(docker ps -a --filter ancestor=image:local -q)
109+
run: docker stop $(docker ps -a --filter ancestor=3proxy:local -q)

3proxy.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/3proxy
1+
#!/bin/3proxy
22
config /etc/3proxy/3proxy.cfg
33

44
# you may use system to execute some external command if proxy starts

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file.
44

55
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].
66

7+
## v1.2.0
8+
9+
### Changed
10+
11+
- 3proxy updated from `0.8.13` up to `0.9.3`
12+
713
## v1.1.0
814

915
### Removed

Dockerfile

+62-34
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,87 @@
11
# Image page: <https://hub.docker.com/_/alpine>
2-
FROM alpine:latest as builder
2+
FROM gcc:9.3 as builder
33

4-
# e.g.: `docker build --build-arg "VERSION=0.8.13" .`
5-
ARG VERSION="0.8.13"
4+
# e.g.: `docker build --build-arg "VERSION=0.9.3" .`
5+
ARG VERSION="0.9.3"
66

7+
# Fetch 3proxy sources
78
RUN set -x \
8-
&& apk add --no-cache \
9-
linux-headers \
10-
build-base \
11-
git \
12-
&& git clone --branch ${VERSION} https://github.com/z3APA3A/3proxy.git /tmp/3proxy \
13-
&& cd /tmp/3proxy \
14-
&& echo '#define ANONYMOUS 1' >> /tmp/3proxy/src/3proxy.h \
9+
&& git clone --branch "${VERSION}" https://github.com/z3APA3A/3proxy.git /tmp/3proxy
10+
11+
WORKDIR /tmp/3proxy
12+
13+
# Patch sources
14+
RUN set -x \
15+
&& echo '#define ANONYMOUS 1' >> ./src/3proxy.h \
16+
# proxy.c source: <https://github.com/z3APA3A/3proxy/blob/0.9.3/src/proxy.c>
1517
&& sed -i 's~\(<\/head>\)~<style>html,body{background-color:#222526;color:#fff;font-family:sans-serif;\
1618
text-align:center;display:flex;flex-direction:column;justify-content:center}h1,h2{margin-bottom:0;font-size:2.5em}\
1719
h2::before{content:'"'"'Proxy error'"'"';display:block;font-size:0.4em;color:#bbb;font-weight:100}\
18-
h3,p{color:#bbb}</style>\1~' /tmp/3proxy/src/proxy.c \
19-
&& cat ./src/proxy.c | grep '</head>' \
20-
&& make -f Makefile.Linux
20+
h3,p{color:#bbb}</style>\1~' ./src/proxy.c \
21+
&& cat ./src/proxy.c | grep '</head>'
2122

22-
FROM alpine:latest
23+
# And compile
24+
RUN set -x \
25+
&& echo "" >> ./Makefile.Linux \
26+
&& echo "PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin SSLPlugin" >> ./Makefile.Linux \
27+
&& echo "LIBS = -l:libcrypto.a -l:libssl.a -ldl" >> ./Makefile.Linux \
28+
&& make -f Makefile.Linux \
29+
&& strip ./bin/3proxy \
30+
&& strip ./bin/StringsPlugin.ld.so \
31+
&& strip ./bin/TrafficPlugin.ld.so \
32+
&& strip ./bin/PCREPlugin.ld.so \
33+
&& strip ./bin/TransparentPlugin.ld.so \
34+
&& strip ./bin/SSLPlugin.ld.so
2335

24-
# e.g.: `docker build --build-arg "BUILD_DATE=`date -u +'%Y-%m-%dT%H:%M:%SZ'`" .`
25-
ARG BUILD_DATE
36+
# Prepare filesystem for 3proxy running
37+
FROM busybox:1.32-glibc as buffer
2638

27-
LABEL \
28-
org.label-schema.name="3proxy" \
29-
org.label-schema.description="Tiny free proxy server" \
30-
org.label-schema.url="https://github.com/tarampampam/3proxy-docker" \
31-
org.label-schema.vcs-url="https://github.com/tarampampam/3proxy-docker" \
32-
org.label-schema.docker.cmd="docker run --rm -d -p \"3128:3128/tcp\" -p \"1080:1080/tcp\" this_image" \
33-
org.label-schema.vendor="tarampampam" \
34-
org.label-schema.build-date="$BUILD_DATE" \
35-
org.label-schema.license="WTFPL" \
36-
org.label-schema.schema-version="1.0"
37-
38-
COPY 3proxy.cfg /etc/3proxy/3proxy.cfg
39-
COPY docker-entrypoint.sh /docker-entrypoint.sh
40-
COPY --from=builder /tmp/3proxy/src/3proxy /usr/bin/3proxy
39+
# Copy binaries
40+
COPY --from=builder /lib/x86_64-linux-gnu/libdl.so.* /lib/
41+
COPY --from=builder /tmp/3proxy/bin/3proxy /bin/
42+
COPY --from=builder /tmp/3proxy/bin/*.ld.so /usr/local/3proxy/libexec/
4143

44+
# Create unprivileged user
4245
RUN set -x \
43-
# Unprivileged user creation <https://stackoverflow.com/a/55757473/12429735RUN>
4446
&& adduser \
4547
--disabled-password \
4648
--gecos "" \
4749
--home /nonexistent \
4850
--shell /sbin/nologin \
4951
--no-create-home \
5052
--uid 10001 \
51-
3proxy \
52-
&& chown 3proxy:3proxy -R /etc/3proxy
53+
3proxy
54+
55+
# Prepare files and directories
56+
RUN set -x \
57+
&& chown -R 10001:10001 /usr/local/3proxy \
58+
&& chmod -R 550 /usr/local/3proxy \
59+
&& chmod -R 555 /usr/local/3proxy/libexec \
60+
&& chown -R root /usr/local/3proxy/libexec \
61+
&& mkdir /etc/3proxy \
62+
&& chown -R 10001:10001 /etc/3proxy
63+
64+
# Copy our config and entrypoint script
65+
COPY 3proxy.cfg /etc/3proxy/3proxy.cfg
66+
COPY docker-entrypoint.sh /docker-entrypoint.sh
67+
68+
# Split all buffered layers into one
69+
FROM scratch
70+
71+
LABEL \
72+
org.opencontainers.image.title="3proxy" \
73+
org.opencontainers.image.description="Tiny free proxy server" \
74+
org.opencontainers.image.url="https://github.com/tarampampam/3proxy-docker" \
75+
org.opencontainers.image.source="https://github.com/tarampampam/3proxy-docker" \
76+
org.opencontainers.image.vendor="Tarampampam" \
77+
org.opencontainers.image.licenses="WTFPL"
78+
79+
# Import from builder
80+
COPY --from=buffer / /
5381

5482
# Use an unprivileged user
5583
USER 3proxy:3proxy
5684

5785
ENTRYPOINT ["/docker-entrypoint.sh"]
5886

59-
CMD ["/usr/bin/3proxy", "/etc/3proxy/3proxy.cfg"]
87+
CMD ["/bin/3proxy", "/etc/3proxy/3proxy.cfg"]

docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sh
1+
#!/bin/sh
22
set -e
33

44
PROXY_LOGIN=${PROXY_LOGIN:-} # string

0 commit comments

Comments
 (0)