From 770665806e43c509e3351bbe588b8866748a7fd0 Mon Sep 17 00:00:00 2001 From: Paramtamtam <7326800+tarampampam@users.noreply.github.com> Date: Thu, 8 Dec 2022 20:20:33 +0400 Subject: [PATCH] feat: Multiple accounts (#29) --- .github/workflows/tests.yml | 14 ++++++++++++-- 3proxy.cfg.json | 3 ++- 3proxy.cfg.mustach | 4 ++-- CHANGELOG.md | 8 ++++++++ README.md | 19 ++++++++++--------- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c5fa1b6..defb7d2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -79,7 +79,7 @@ jobs: # Docs: auth: [yes, no] needs: [build-image] steps: - - name: Download builded docker image + - name: Download built docker image uses: actions/download-artifact@v3 with: name: docker-image @@ -95,7 +95,7 @@ jobs: # Docs: - name: Start server with auth setup if: matrix.auth == 'yes' - run: docker run --rm -d -p "3128:3128/tcp" -p "1080:1080/tcp" -e "PROXY_LOGIN=evil" -e "PROXY_PASSWORD=live" 3proxy:local + run: docker run --rm -d -p "3128:3128/tcp" -p "1080:1080/tcp" -e "PROXY_LOGIN=evil" -e "PROXY_PASSWORD=live" -e 'EXTRA_ACCOUNTS={"foo":"bar"}' 3proxy:local - name: Pause run: sleep 3 @@ -128,6 +128,16 @@ jobs: # Docs: --max-time 3 \ https://www.cloudflare.com/robots.txt + - name: Try to use HTTP proxy (with auth, extra user) + if: matrix.auth == 'yes' + run: | + curl -v --fail \ + --proxy http://127.0.0.1:3128 \ + --proxy-user foo:bar \ + --connect-timeout 3 \ + --max-time 3 \ + https://www.cloudflare.com/robots.txt + - name: Try to use SOCKS proxy (with auth) if: matrix.auth == 'yes' run: | diff --git a/3proxy.cfg.json b/3proxy.cfg.json index db2212a..321ce9f 100644 --- a/3proxy.cfg.json +++ b/3proxy.cfg.json @@ -13,7 +13,8 @@ "max_connections": "${MAX_CONNECTIONS:-1024}", "auth": { "login": "${PROXY_LOGIN:-}", - "password": "${PROXY_PASSWORD:-}" + "password": "${PROXY_PASSWORD:-}", + "extra_accounts": ${EXTRA_ACCOUNTS:-{}} }, "ports": { "proxy": "${PROXY_PORT:-3128}", diff --git a/3proxy.cfg.mustach b/3proxy.cfg.mustach index 5ab95ed..e24618e 100644 --- a/3proxy.cfg.mustach +++ b/3proxy.cfg.mustach @@ -22,9 +22,9 @@ logformat "-\""+_G{""time_unix"":%t, ""proxy"":{""type:"":""%N"", ""port"":%p}, maxconn {{ max_connections }} {{^auth.login=}}{{^auth.password=}} -users {{ auth.login }}:CL:{{ auth.password }} +users {{ auth.login }}:CL:{{ auth.password }}{{#auth.extra_accounts.*}} {{ * }}:CL:{{ . }}{{/auth.extra_accounts.*}} auth strong -allow {{ auth.login }} +allow {{ auth.login }}{{#auth.extra_accounts.*}},{{ * }}{{/auth.extra_accounts.*}} {{/auth.password=}}{{/auth.login=}} proxy -a -p{{ ports.proxy }} diff --git a/CHANGELOG.md b/CHANGELOG.md index f30f476..8c084c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver]. +## v1.8.0 + +### Added + +- `EXTRA_ACCOUNTS` environment variable is supported now [#28] + +[#28]:https://github.com/tarampampam/3proxy-docker/issues/28 + ## v1.7.0 ### Added diff --git a/README.md b/README.md index acb2ac8..8b16968 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,16 @@ All supported image tags [can be found here][link_docker_tags]. ## Supported environment variables -| Variable name | Description | Example | -|----------------------|-----------------------------------------------------------|------------------------| -| `PROXY_LOGIN` | Authorization login (empty by default) | `username` | -| `PROXY_PASSWORD` | Authorization password (empty by default) | `password` | -| `PRIMARY_RESOLVER` | Primary nameserver (dns resolver; `1.0.0.1` by default) | `8.8.8.8:5353/tcp` | -| `SECONDARY_RESOLVER` | Secondary nameserver (dns resolver; `8.8.4.4` by default) | `2001:4860:4860::8844` | -| `MAX_CONNECTIONS` | Maximal connections count (`1024` by default) | `2056` | -| `PROXY_PORT` | HTTP proxy port number (`3128` by default) | `8080` | -| `SOCKS_PORT` | SOCKS proxy port number (`1080` by default) | `8888` | +| Variable name | Description | Example | +|----------------------|-----------------------------------------------------------|-----------------------------------| +| `PROXY_LOGIN` | Authorization login (empty by default) | `username` | +| `PROXY_PASSWORD` | Authorization password (empty by default) | `password` | +| `EXTRA_ACCOUNTS` | Additional proxy users | `{"evil":"live", "guest":"pass"}` | +| `PRIMARY_RESOLVER` | Primary nameserver (dns resolver; `1.0.0.1` by default) | `8.8.8.8:5353/tcp` | +| `SECONDARY_RESOLVER` | Secondary nameserver (dns resolver; `8.8.4.4` by default) | `2001:4860:4860::8844` | +| `MAX_CONNECTIONS` | Maximal connections count (`1024` by default) | `2056` | +| `PROXY_PORT` | HTTP proxy port number (`3128` by default) | `8080` | +| `SOCKS_PORT` | SOCKS proxy port number (`1080` by default) | `8888` | ## How can I use this?