diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d2248ee --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# EditorConfig is awesome: http://EditorConfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = tab +tab_width = 4 +max_line_length = 160 + +[{*.json,*.yaml,*.yml,*.md,*.js}] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..6e2994c --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,35 @@ +name: Docker + +on: + push: + branches: [master] + +jobs: + docker: + runs-on: ubuntu-latest + + name: Docker (dockette/proxychain:latest) + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: dockette/proxychain:latest + platforms: linux/amd64,linux/arm64 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a5692e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# NodeJS +/app/node_modules diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..a12685a --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1 @@ +image: f3l1x/gitpod:v1 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c659911 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:20 as builder + +COPY /app/package*.json /srv +RUN npm install -C /srv + +FROM node:20 + +COPY /app /srv +COPY --from=builder /srv/node_modules /srv/node_modules + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod 755 /entrypoint.sh + +CMD ["/entrypoint.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3536124 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Dockette + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9794e05 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +DOCKER_IMAGE=dockette/proxychain + +.PHONY: build +build: + docker build -t ${DOCKER_IMAGE} . + +.PHONY: run +run: + docker run -it --rm -p 8080:8080 ${DOCKER_IMAGE} diff --git a/README.md b/README.md new file mode 100644 index 0000000..0d4e438 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +

Dockette / Proxychain

+ +

+ 🎁 Dockerized proxychain forward proxy based on [proxy-chain](https://github.com/apify/proxy-chain/tree/master) library. +

+ +

+🕹 f3l1x.io | 💻 f3l1x | 🐦 @xf3l1x +

+ +

+ + + +

+ +----- + +## Usage + +``` +docker run \ + -it \ + --rm \ + -p 8000:8000 \ + -e PROXY_PROXYLIST=1.2.3.4:8000 \ + dockette/proxychain +``` + +## Documentation + +- `PROXY_PORT` - default(8000) - Server listed on +- `PROXY_VERBOSE` - default(false) - More verbose mode +- `PROXY_AUTH_USER` - default (null) - Basic auth +- `PROXY_AUTH_PASSWORD` - default(null) - Basic auth +- `PROXY_PROXYLIST` - default([]) - List of forward proxies + +## Development + +See [how to contribute](https://contributte.org/contributing.html) to this package. + +This package is currently maintaining by these authors. + + + + + +----- + +Consider to [support](https://github.com/sponsors/f3l1x) **f3l1x**. Also thank you for using this package. diff --git a/app/package-lock.json b/app/package-lock.json new file mode 100644 index 0000000..a37bdd6 --- /dev/null +++ b/app/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "test", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "proxy-chain": "^2.3.0" + } + }, + "node_modules/proxy-chain": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/proxy-chain/-/proxy-chain-2.3.0.tgz", + "integrity": "sha512-S1m0Ao0IGoXfy14dKXAaJCUkCBCnleYzElzoATj42Iq4d8EYqOZq4jS4G/D94AzrU6QaPOzzoEDjbm7VJQGq9g==", + "dependencies": { + "tslib": "^2.3.1" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } +} diff --git a/app/package.json b/app/package.json new file mode 100644 index 0000000..6199378 --- /dev/null +++ b/app/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "proxy-chain": "2.3.0" + } +} diff --git a/app/server.js b/app/server.js new file mode 100644 index 0000000..9066d8f --- /dev/null +++ b/app/server.js @@ -0,0 +1,46 @@ +const ProxyChain = require("proxy-chain"); + +const CONFIG = { + PORT: process.env.PROXY_PORT || 8000, + VERBOSE: process.env.PROXY_VERBOSE || false, + AUTH_USER: process.env.PROXY_AUTH_USER || null, + AUTH_PASSWORD: process.env.PROXY_AUTH_PASSWORD || null, + PROXYLIST: Array.from((new String(process.env.PROXY_PROXYLIST || '')).split(/,|\||\n/)).filter(p => p), +}; + +if (CONFIG.PROXYLIST.length <= 0) { + console.error(`No PROXYLIST given. Example ENV.PROXYLIST=http://1.2.3.4:8080|http://5.6.7.8:8080`); + process.exit(255); +} + +const server = new ProxyChain.Server({ + port: CONFIG.PORT, + verbose: CONFIG.VERBOSE, + prepareRequestFunction: ({ username, password }) => { + const prepare = { + upstreamProxyUrl: CONFIG.PROXYLIST[Math.floor(Math.random() * CONFIG.PROXYLIST.length)], + }; + + if (CONFIG.AUTH_USER && CONFIG.AUTH_PASSWORD) { + prepare.requestAuthentication = username !== "bob" || password !== "TopSecret"; + } + + return prepare; + }, +}); + +server.listen(() => { + console.log(`Proxy server is listening on port ${server.port}.`); + console.log(`List of proxies:`); + console.dir(CONFIG.PROXYLIST); +}); + +server.on("connectionClosed", ({ connectionId, stats }) => { + console.log(`Connection ${connectionId} closed`); + console.dir(stats); +}); + +server.on("requestFailed", ({ request, error }) => { + console.log(`Request ${request.url} failed`); + console.error(error); +}); diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..7d48f0a --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -Eeo pipefail + +node /srv/server.js