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]
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: <https://git.io/JvxXE>
- 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: <https://git.io/JvxXE>
--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: |

View File

@ -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}",

View File

@ -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 }}

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].
## 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

View File

@ -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?