Skip to content

Commit

Permalink
feat: Multiple accounts (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam committed Dec 8, 2022
1 parent 7be7f47 commit 7706658
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/tests.yml
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
3 changes: 2 additions & 1 deletion 3proxy.cfg.json
Expand Up @@ -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}",
Expand Down
4 changes: 2 additions & 2 deletions 3proxy.cfg.mustach
Expand Up @@ -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 }}
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions README.md
Expand Up @@ -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?

Expand Down

0 comments on commit 7706658

Please sign in to comment.