bepass-worker
๐ Table of Contents
- ๐ Table of Contents
- ๐ Overview
- โ๏ธ Features
- ๐ Project Structure
- ๐ Deploying a Worker
- Usage Limits
- ๐บ Roadmap
- ๐ค Contributing
- ๐ License
๐ Overview
This repository contains a new worker.js that aims for better solutions in terms of performance and features regarding common worker issues such as supporting IPv6, the UDP protocol, and more stable communication with Cloudflare IPs (loopback connections).
As you know, Cloudflare workers are currently unable to connect to hosts that have Cloudflare IPs (this is considered a loopback).This worker uses relay nodes to work around that limitation.
The worker also implements a simple DNS proxy by forwarding DNS queries to a custom DNS server specified in the dnsHost variable.
โ๏ธ Features
- Supports IPv6
- Supports UDP
- More reliable loopback connections to Cloudflare IPs
- Overall improved performance and stability
- DNS
๐ Project Structure
โโโ src
โ โโโ dns.js // DNS message encoding/parsing
โ โโโ worker.ts // Main worker code
โโโ dist
โ โโโ worker.js // Compiled worker script
๐ Deploying a Worker
One-Click Deploy
You can deploy this worker to your Cloudflare account automatically with one click using the button below.
Manual Deployment
To manually deploy the worker:
- Sign up at the Cloudflare signup page
- From the main navbar, choose Workers & Pages
- Click the Create Application button
- Click the Create Worker button
- Copy the worker.js file contents from this repository
- Fill in a name for your worker and click the Deploy button
- Click the Quick Edit button
- Paste your clipboard contents and replace the worker's default code
- Click the Save and Deploy button
- Write down the newly created worker address, it should be something like [name].[username].workers.dev
- Change your Bepass configuration to https://[name].[username].workers.dev/dns-query
Add your own relay
1. Follow the relay set-up instructions to run your own relay server.
2. Edit the worker.js
file and add your server IP or domain to the proxyIPs
array.
In the worker.js
file, locate the following code:
// src/worker.ts var proxyIPs = ["relay1.bepass.org", "relay2.bepass.org"]; var proxyPort = 6666; var proxyIP = proxyIPs[Math.floor(Math.random() * proxyIPs.length)];
Add the IP address or domain of your relay server. For example:
// src/worker.ts var proxyIPs = ["relay1.bepass.org", "relay2.bepass.org", "relay.example.com", "123.45.67.89"]; // Add your server IP/domain here var proxyPort = 6666; var proxyIP = proxyIPs[Math.floor(Math.random() * proxyIPs.length)];
Usage Limits
Cloudflare's free workers are limited to 100,000 requests per day. This is sufficient for personal use by one user or a small family.
For most personal usage, the free worker should be adequate. But if you experience rate limiting, you may need to deploy workers on multiple accounts.
๐ฆ Installation
- Clone the bepass-worker repository:
git clone https://github.com/uoosef/bepass-worker
- Change to the project directory:
cd bepass-worker
- Install the dependencies:
npm install
๐ฎ Using bepass-worker
npm run build && node dist/worker.js
๐งช Running Tests
npm test
๐บ Roadmap
Task 1: Implement worker's range detection
Task 2: Better loopback support
Task 3: DNS Resolving
Task 4: ...
๐ค Contributing
Contributions are always welcome! Please follow these steps:
- Fork the project repository. This creates a copy of the project on your account that you can modify without affecting the original project.
- Clone the forked repository to your local machine using a Git client like Git or GitHub Desktop.
- Create a new branch with a descriptive name (e.g.,
new-feature-branch
orbugfix-issue-123
).
git checkout -b new-feature-branch
- Make changes to the project's codebase.
- Commit your changes to your local branch with a clear commit message that explains the changes you've made.
git commit -m 'Implemented new feature.'
- Push your changes to your forked repository on GitHub using the following command
git push origin new-feature-branch
- Create a new pull request to the original project repository. In the pull request, describe the changes you've made and why they're necessary. The project maintainers will review your changes and provide feedback or merge them into the main branch.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.