-
Notifications
You must be signed in to change notification settings - Fork 0
Merge upstream PRs #184 and #308: Docker config via environment variables and connection pool disable #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6d359e2
cc2276f
c347f9e
550582a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| __pycache__/ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| *.so | ||
| *.egg | ||
| *.egg-info/ | ||
| dist/ | ||
| build/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,34 @@ | ||
| import os | ||
|
|
||
|
|
||
| def str_to_bool(value): | ||
| """Convert string to boolean.""" | ||
| if isinstance(value, bool): | ||
| return value | ||
| if isinstance(value, str): | ||
| return value.lower() in ("true", "1", "yes", "on") | ||
| return bool(value) | ||
|
|
||
|
|
||
| PORT = 443 | ||
|
|
||
| # name -> secret (32 hex chars) | ||
| USERS = { | ||
| "tg": "00000000000000000000000000000001", | ||
| # "tg2": "0123456789abcdef0123456789abcdef", | ||
| "tg": os.environ.get("TG_KEY", "00000000000000000000000000000001"), | ||
| # "tg2": "0123456789abcdef0123456789abcdef", | ||
| } | ||
|
|
||
| MODES = { | ||
| # Classic mode, easy to detect | ||
| "classic": False, | ||
|
|
||
| # Makes the proxy harder to detect | ||
| # Can be incompatible with very old clients | ||
| "secure": False, | ||
| # Makes the proxy harder to detect | ||
| # Can be incompatible with very old clients | ||
| SECURE_ONLY = str_to_bool(os.environ.get("SECURE_ONLY", "True")) | ||
|
|
||
| # Makes the proxy even more hard to detect | ||
| # Can be incompatible with old clients | ||
| "tls": True | ||
| } | ||
| # Makes the proxy even more hard to detect | ||
| # Compatible only with the recent clients | ||
| TLS_ONLY = str_to_bool(os.environ.get("TLS_ONLY", "True")) | ||
|
Comment on lines
+23
to
+27
|
||
|
|
||
| # The domain for TLS mode, bad clients are proxied there | ||
| # The domain for TLS, bad clients are proxied there | ||
| # Use random existing domain, proxy checks it on start | ||
| # TLS_DOMAIN = "www.google.com" | ||
| TLS_DOMAIN = os.environ.get("TLS_DOMAIN", "www.google.com") | ||
|
|
||
| # Tag for advertising, obtainable from @MTProxybot | ||
| # AD_TAG = "3c09c680b76ee91a4c25ad51f742267d" | ||
| AD_TAG = os.environ.get("AD_TAG", "3c09c680b76ee91a4c25ad51f742267d") | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,16 @@ | ||||||||||||||
| version: '2.0' | ||||||||||||||
| services: | ||||||||||||||
| mtprotoproxy: | ||||||||||||||
| build: . | ||||||||||||||
| image: mtprotoproxy | ||||||||||||||
| restart: unless-stopped | ||||||||||||||
| network_mode: "host" | ||||||||||||||
| environment: | ||||||||||||||
| - TG_KEY=00000000000000000000000000000001 | ||||||||||||||
| - SECURE_ONLY=true | ||||||||||||||
| - TLS_ONLY=true | ||||||||||||||
| - TLS_DOMAIN=www.drive.google.com | ||||||||||||||
|
||||||||||||||
| - TLS_DOMAIN=www.drive.google.com | |
| - TLS_DOMAIN=www.cloudflare.com |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docker-compose.yml mounts ./config.py as a volume (line 15), which will override any environment variable configuration. This means the environment variables defined in lines 8-12 won't have any effect since the mounted config.py file will take precedence.
Either:
- Remove the config.py volume mount to allow environment variables to work, OR
- Remove the environment variable examples since they won't work with the current setup
The current configuration creates a confusing situation where users might set environment variables but they'll be ignored.
| environment: | |
| - TG_KEY=00000000000000000000000000000001 | |
| - SECURE_ONLY=true | |
| - TLS_ONLY=true | |
| - TLS_DOMAIN=www.drive.google.com | |
| - AD_TAG=3c09c680b76ee91a4c25ad51f742267d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Step 2 recommends editing config.py to set PORT, USERS, and AD_TAG, but with the new environment variable approach introduced in this PR, users could also configure these via environment variables (TG_KEY, AD_TAG, etc.). The README should be updated to mention both configuration methods:
This would help users understand their configuration options.