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).
It aims to fix bugs from the previous version and improve its functionality with the help of relay nodes.
- 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
Relay nodes are servers maintained by volunteer users. These nodes help the worker support features that are not officially supported by Cloudflare workers.
Here is a representation of what happens to your request from the client to the destination:
sequenceDiagram
Client ->> Worker.js: Please forward my traffic to <ip>:<port> on <net> network
Worker.js-->> Worker.js: Is <net> udp or <ip> in range of cf IPs?
Worker.js-->> Relay: Yes it is.
Relay->> Destination: Forward traffic.
Worker.js-->> Destination: No it's not.
Destination->> Client: Here you go! <Response>
It's simple! Just buy a VPS from a provider that offers a lot of traffic, then install Golang and run:
tmux
git clone https://github.com/uoosef/cf-bepass.git
cd cf-bepass
go run *.go -b 0.0.0.0 -p 6666
Then press ctrl+b and then d. Then edit the worker.js:
/**
* Welcome to Cloudflare Workers! This is your first worker.
*
* - Run "npm run dev" in your terminal to start a development server
* - Open a browser tab at http://localhost:8787/ to see your worker in action
* - Run "npm run deploy" to publish your worker
*
* Learn more at https://developers.cloudflare.com/workers/
*/
// @ts-ignore
import { connect } from 'cloudflare:sockets';
const proxyIPs = ['<Your IP goes here>'];
const proxyPort = 6666;
let proxyIP = proxyIPs[Math.floor(Math.random() * proxyIPs.length)];
Then test that your worker works as intended.
It's simple! Just follow these 3 easy steps:
-
Buy a VPS from a provider that offers a lot of traffic, like Hetzner GMBH. Then install Golang and run:
sudo su cd /opt git clone https://github.com/uoosef/cf-bepass.git cd cf-bepass CGO_ENABLED=0 go build -ldflags '-s -w' -trimpath *.go
-
Make a systemd service for Bepass in /etc/systemd/system/cfb.service:
nano /etc/systemd/system/cfb.service
And paste the following code:
[Unit] Description=CF Bepass Service [Service] ExecStart=/opt/cf-bepass/relay [Install] WantedBy=multi-user.target
Then reload systemd to read this unit file with:
systemctl daemon-reload
Start the service with:
systemctl start cfb.service
And enable it during startup with:
systemctl enable cfb.service
You can check the status of the service with:
systemctl status cfb.service
-
Submit a new issue with the Volunteer Node Maintainer title and share your server IP address and how long your server will last! (Minimum requirement: at least 3 months)
- Implement Relay
- Implement worker's range detection
- Better loopback support
- Full IPv6 support
- Full UDP support
MIT Public License