feat: Multiple accounts (#29)

This commit is contained in:
Paramtamtam 2022-12-08 20:20:33 +04:00 committed by GitHub
parent 7be7f47fe4
commit 770665806e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 14 deletions

View File

@ -79,7 +79,7 @@ jobs: # Docs: <https://git.io/JvxXE>
auth: [yes, no] auth: [yes, no]
needs: [build-image] needs: [build-image]
steps: steps:
- name: Download builded docker image - name: Download built docker image
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: docker-image name: docker-image
@ -95,7 +95,7 @@ jobs: # Docs: <https://git.io/JvxXE>
- name: Start server with auth setup - name: Start server with auth setup
if: matrix.auth == 'yes' 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 - name: Pause
run: sleep 3 run: sleep 3
@ -128,6 +128,16 @@ jobs: # Docs: <https://git.io/JvxXE>
--max-time 3 \ --max-time 3 \
https://www.cloudflare.com/robots.txt 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) - name: Try to use SOCKS proxy (with auth)
if: matrix.auth == 'yes' if: matrix.auth == 'yes'
run: | run: |

View File

@ -13,7 +13,8 @@
"max_connections": "${MAX_CONNECTIONS:-1024}", "max_connections": "${MAX_CONNECTIONS:-1024}",
"auth": { "auth": {
"login": "${PROXY_LOGIN:-}", "login": "${PROXY_LOGIN:-}",
"password": "${PROXY_PASSWORD:-}" "password": "${PROXY_PASSWORD:-}",
"extra_accounts": ${EXTRA_ACCOUNTS:-{}}
}, },
"ports": { "ports": {
"proxy": "${PROXY_PORT:-3128}", "proxy": "${PROXY_PORT:-3128}",

View File

@ -22,9 +22,9 @@ logformat "-\""+_G{""time_unix"":%t, ""proxy"":{""type:"":""%N"", ""port"":%p},
maxconn {{ max_connections }} maxconn {{ max_connections }}
{{^auth.login=}}{{^auth.password=}} {{^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 auth strong
allow {{ auth.login }} allow {{ auth.login }}{{#auth.extra_accounts.*}},{{ * }}{{/auth.extra_accounts.*}}
{{/auth.password=}}{{/auth.login=}} {{/auth.password=}}{{/auth.login=}}
proxy -a -p{{ ports.proxy }} proxy -a -p{{ ports.proxy }}

View File

@ -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]. 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 ## v1.7.0
### Added ### Added

View File

@ -35,9 +35,10 @@ All supported image tags [can be found here][link_docker_tags].
## Supported environment variables ## Supported environment variables
| Variable name | Description | Example | | Variable name | Description | Example |
|----------------------|-----------------------------------------------------------|------------------------| |----------------------|-----------------------------------------------------------|-----------------------------------|
| `PROXY_LOGIN` | Authorization login (empty by default) | `username` | | `PROXY_LOGIN` | Authorization login (empty by default) | `username` |
| `PROXY_PASSWORD` | Authorization password (empty by default) | `password` | | `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` | | `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` | | `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` | | `MAX_CONNECTIONS` | Maximal connections count (`1024` by default) | `2056` |