-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub Actions for GHCR.io image publishing and SOCKS5 outgoing proxy support #4
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
13e1b3a
6120e9b
52ecb05
a6708c6
5b4f0db
f1e23f5
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,62 @@ | ||||||||||||||||||||
| name: Docker Image CI | ||||||||||||||||||||
|
|
||||||||||||||||||||
| on: | ||||||||||||||||||||
| push: | ||||||||||||||||||||
| branches: | ||||||||||||||||||||
| - edge | ||||||||||||||||||||
| tags: | ||||||||||||||||||||
| - 'v*.*.*' | ||||||||||||||||||||
| pull_request: | ||||||||||||||||||||
| branches: | ||||||||||||||||||||
| - edge | ||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||
|
|
||||||||||||||||||||
| env: | ||||||||||||||||||||
| REGISTRY: ghcr.io | ||||||||||||||||||||
| IMAGE_NAME: ${{ github.repository }} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| jobs: | ||||||||||||||||||||
| build-and-push: | ||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||
| permissions: | ||||||||||||||||||||
| contents: read | ||||||||||||||||||||
| packages: write | ||||||||||||||||||||
|
|
||||||||||||||||||||
| steps: | ||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Set up Docker Buildx | ||||||||||||||||||||
| uses: docker/setup-buildx-action@v3 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Log in to Container Registry | ||||||||||||||||||||
| if: github.event_name != 'pull_request' | ||||||||||||||||||||
| uses: docker/login-action@v3 | ||||||||||||||||||||
| with: | ||||||||||||||||||||
| registry: ${{ env.REGISTRY }} | ||||||||||||||||||||
| username: ${{ github.actor }} | ||||||||||||||||||||
| password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Extract metadata (tags, labels) for Docker | ||||||||||||||||||||
| id: meta | ||||||||||||||||||||
| uses: docker/metadata-action@v5 | ||||||||||||||||||||
| with: | ||||||||||||||||||||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||||||||||||||||||||
| tags: | | ||||||||||||||||||||
| type=ref,event=branch | ||||||||||||||||||||
| type=ref,event=pr | ||||||||||||||||||||
| type=semver,pattern={{version}} | ||||||||||||||||||||
| type=semver,pattern={{major}}.{{minor}} | ||||||||||||||||||||
| type=semver,pattern={{major}} | ||||||||||||||||||||
| type=sha,prefix={{branch}}- | ||||||||||||||||||||
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/edge' }} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Build and push Docker image | ||||||||||||||||||||
| uses: docker/build-push-action@v5 | ||||||||||||||||||||
| with: | ||||||||||||||||||||
| context: . | ||||||||||||||||||||
| push: ${{ github.event_name != 'pull_request' }} | ||||||||||||||||||||
| tags: ${{ steps.meta.outputs.tags }} | ||||||||||||||||||||
| labels: ${{ steps.meta.outputs.labels }} | ||||||||||||||||||||
| cache-from: type=gha | ||||||||||||||||||||
| cache-to: type=gha,mode=max | ||||||||||||||||||||
|
||||||||||||||||||||
| cache-to: type=gha,mode=max | |
| cache-to: type=gha,mode=max | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,58 @@ | ||||||||||||||||
| # Async MTProto Proxy # | ||||||||||||||||
|
|
||||||||||||||||
| [](https://github.com/xrh0905/mtprotoproxy/pkgs/container/mtprotoproxy) | ||||||||||||||||
|
|
||||||||||||||||
| Fast and simple to setup MTProto proxy written in Python. | ||||||||||||||||
|
|
||||||||||||||||
| ## Starting Up ## | ||||||||||||||||
|
|
||||||||||||||||
| ### Using Pre-built Docker Image (Recommended) ### | ||||||||||||||||
|
|
||||||||||||||||
| 1. Pull the latest image: `docker pull ghcr.io/xrh0905/mtprotoproxy:latest` | ||||||||||||||||
| 2. *(optional, recommended)* create a *config.py* file, set **PORT**, **USERS** and **AD_TAG** | ||||||||||||||||
| 3. Run the container: | ||||||||||||||||
| ```bash | ||||||||||||||||
| docker run -d --name mtprotoproxy \ | ||||||||||||||||
| --network host \ | ||||||||||||||||
| -v $(pwd)/config.py:/home/tgproxy/config.py \ | ||||||||||||||||
| ghcr.io/xrh0905/mtprotoproxy:latest | ||||||||||||||||
| ``` | ||||||||||||||||
| 4. *(optional, get a link to share the proxy)* `docker logs mtprotoproxy` | ||||||||||||||||
|
|
||||||||||||||||
| ### Building from Source ### | ||||||||||||||||
|
|
||||||||||||||||
| 1. `git clone -b stable https://github.com/alexbers/mtprotoproxy.git; cd mtprotoproxy` | ||||||||||||||||
| 1. `git clone -b edge https://github.com/xrh0905/mtprotoproxy.git; cd mtprotoproxy` | ||||||||||||||||
| 2. *(optional, recommended)* edit *config.py*, set **PORT**, **USERS** and **AD_TAG** | ||||||||||||||||
| 3. `docker build -t mtprotoproxy .` | ||||||||||||||||
| 4. `docker-compose up -d` (or just `python3 mtprotoproxy.py` if you don't like Docker) | ||||||||||||||||
| 5. *(optional, get a link to share the proxy)* `docker-compose logs` | ||||||||||||||||
|
|
||||||||||||||||
|  | ||||||||||||||||
|
|
||||||||||||||||
| ## Using with Docker Compose ## | ||||||||||||||||
|
|
||||||||||||||||
| You can use the pre-built image with docker-compose by updating your `docker-compose.yml`: | ||||||||||||||||
|
|
||||||||||||||||
| ```yaml | ||||||||||||||||
| version: '3.8' | ||||||||||||||||
| services: | ||||||||||||||||
| mtprotoproxy: | ||||||||||||||||
| image: ghcr.io/xrh0905/mtprotoproxy:latest | ||||||||||||||||
| restart: unless-stopped | ||||||||||||||||
| network_mode: "host" | ||||||||||||||||
| environment: | ||||||||||||||||
| # Replace these values with your own configuration | ||||||||||||||||
| - TG_KEY=00000000000000000000000000000001 | ||||||||||||||||
| - SECURE_ONLY=true | ||||||||||||||||
| - TLS_ONLY=true | ||||||||||||||||
| - TLS_DOMAIN=www.drive.google.com | ||||||||||||||||
| - AD_TAG=3c09c680b76ee91a4c25ad51f742267d | ||||||||||||||||
| volumes: | ||||||||||||||||
| - ./config.py:/home/tgproxy/config.py | ||||||||||||||||
|
||||||||||||||||
| - ./config.py:/home/tgproxy/config.py | |
| - ./config.py:/home/tgproxy/config.py |
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.
Spelling error: "automaticaly" should be "automatically".
| - several times, clients will be automaticaly balanced between instances | |
| - several times, clients will be automatically balanced between instances |
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.
[nitpick] The documentation shows example credentials (TG_KEY, SOCKS5_USER, SOCKS5_PASS) but doesn't emphasize strongly enough that these are placeholder values that MUST be changed. While there is a comment on line 44 about replacing values, sensitive credentials like SOCKS5_USER and SOCKS5_PASS in the SOCKS5 example (lines 128-129) lack this warning.
Consider adding a similar comment in the SOCKS5 Docker Compose example to make it clear these are placeholder values:
environment:
# Replace these values with your own configuration
- TG_KEY=00000000000000000000000000000001
- SECURE_ONLY=true
- TLS_ONLY=true
- TLS_DOMAIN=www.drive.google.com
# SOCKS5 proxy configuration - replace with your actual SOCKS5 proxy details
- SOCKS5_HOST=your.socks5.server.com| # SOCKS5 proxy configuration | |
| - SOCKS5_HOST=your.socks5.server.com | |
| - SOCKS5_PORT=1080 | |
| # SOCKS5 proxy configuration - replace with your actual SOCKS5 proxy details | |
| - SOCKS5_HOST=your.socks5.server.com | |
| - SOCKS5_PORT=1080 | |
| # Replace these placeholder credentials with your actual SOCKS5 username and password |
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 volumes section is indented with 8 spaces instead of 4 spaces, which is inconsistent with the rest of the YAML structure and violates YAML best practices. All keys at the same level should have the same indentation.
Change:
volumes:
- ./config.py:/home/tgproxy/config.pyTo:
volumes:
- ./config.py:/home/tgproxy/config.py| - ./config.py:/home/tgproxy/config.py | |
| - ./config.py:/home/tgproxy/config.py |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,3 +32,10 @@ def str_to_bool(value): | |||||||||||||||
|
|
||||||||||||||||
| # Tag for advertising, obtainable from @MTProxybot | ||||||||||||||||
| AD_TAG = os.environ.get("AD_TAG", "3c09c680b76ee91a4c25ad51f742267d") | ||||||||||||||||
|
|
||||||||||||||||
| # SOCKS5 proxy for outgoing connections (optional) | ||||||||||||||||
| # Uncomment and configure if you need to route traffic through a SOCKS5 proxy | ||||||||||||||||
| SOCKS5_HOST = os.environ.get("SOCKS5_HOST", None) | ||||||||||||||||
| SOCKS5_PORT = int(os.environ.get("SOCKS5_PORT", 0)) if os.environ.get("SOCKS5_PORT", "").isdigit() else None | ||||||||||||||||
|
||||||||||||||||
| SOCKS5_PORT = int(os.environ.get("SOCKS5_PORT", 0)) if os.environ.get("SOCKS5_PORT", "").isdigit() else None | |
| SOCKS5_PORT = ( | |
| int(os.environ.get("SOCKS5_PORT", 0)) | |
| if os.environ.get("SOCKS5_PORT", "").isdigit() | |
| and 1 <= int(os.environ.get("SOCKS5_PORT", 0)) <= 65535 | |
| else None | |
| ) |
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 tagging strategy includes
type=sha,prefix={{branch}}-which will attempt to use{{branch}}as a literal prefix. The docker/metadata-action doesn't support{{branch}}as a template variable in the prefix. This will result in tags like{{branch}}-abc1234instead ofedge-abc1234.Consider using one of these approaches:
type=sha,prefix=edge-(but this only works for the edge branch)type=shawithout a prefix for simpler SHA-based tags