Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Oct 12, 2023
1 parent 0bdce44 commit 598182c
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# NodeJS
/app/node_modules
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
image: f3l1x/gitpod:v1
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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}
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<h1 align=center>Dockette / Proxychain</h1>

<p align=center>
🎁 Dockerized proxychain forward proxy based on [proxy-chain](https://github.com/apify/proxy-chain/tree/master) library.
</p>

<p align=center>
🕹 <a href="https://f3l1x.io">f3l1x.io</a> | 💻 <a href="https://github.com/f3l1x">f3l1x</a> | 🐦 <a href="https://twitter.com/xf3l1x">@xf3l1x</a>
</p>

<p align=center>
<a href="https://hub.docker.com/r/dockette/nexus/"><img src="https://badgen.net/docker/pulls/dockette/nexus"></a>
<a href="https://bit.ly/ctteg"><img src="https://badgen.net/badge/support/gitter/cyan"></a>
<a href="https://github.com/sponsors/f3l1x"><img src="https://badgen.net/badge/sponsor/donations/F96854"></a>
</p>

-----

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

<a href="https://github.com/f3l1x">
<img width="80" height="80" src="https://avatars2.githubusercontent.com/u/538058?v=3&s=80">
</a>

-----

Consider to [support](https://github.com/sponsors/f3l1x) **f3l1x**. Also thank you for using this package.
28 changes: 28 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"proxy-chain": "2.3.0"
}
}
46 changes: 46 additions & 0 deletions app/server.js
Original file line number Diff line number Diff line change
@@ -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);
});
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -Eeo pipefail

node /srv/server.js

0 comments on commit 598182c

Please sign in to comment.