Skip to content

Commit

Permalink
add allow custom multiple proxyIP and socks5
Browse files Browse the repository at this point in the history
  • Loading branch information
3Kmfi6HP committed Oct 19, 2024
1 parent b7e105a commit 883b65c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 26 deletions.
55 changes: 32 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ ask question and cloudflare ips: [https://t.me/edtunnel](https://t.me/edtunnel)

2. Clone this repository deploy in cloudflare pages.

3. Add `nodejs_compat` at setting Compatibility flags
<!-- 3. Add `nodejs_compat` at setting Compatibility flags -->

![note](image/image.png)
<!-- ![note](image/image.png) -->

## Deploy in worker.dev

Expand All @@ -44,11 +44,11 @@ ask question and cloudflare ips: [https://t.me/edtunnel](https://t.me/edtunnel)

[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/6Kmfi6HP/EDtunnel)

3. Noneed add `nodejs_compat` at setting Compatibility flags
<!-- 3. Noneed add `nodejs_compat` at setting Compatibility flags -->

## How to use non 443 port as proxyIP

1. got to `https://proxyip.edtunnel.best/` paste your `ProxyIP:proxyport` and click `Check` button.
1. copy `ProxyIP:proxyport` to `https://proxyip.edtunnel.best/` and click `Check` button.
2. if `Proxy IP` is `true`, you can use this `ProxyIP:proxyport` as `ProxyIP`
3. if `Proxy IP` is `false`, you can see `Origin` is `443` this means the port can be accessed website.
4. edit worker `PROXYIP` variable example `211.230.110.231:50008`
Expand All @@ -62,25 +62,25 @@ Note: the proxyIP with port may not vaild some cloudflare site that use http onl

## Support Environment Variables

| Variable | Required | Example | Description |
| -------------- | -------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| `UUID` | No | `12345678-1234-1234-1234-123456789012` | Unique identifier |
| `PROXYIP` | No | `1.1.1.1` or `cdn.xn--b6gac.eu.org` or with port `1.1.1.1:9443` or `[2a01:4f8:c2c:123f:64:5:6810:c55a]:443` | Redirct cloudflare ips to ProxyIP |
| `SOCKS5` | No | `1.1.1.1:1080` or `user:pass@host:port` | SOCKS5 proxy cloudflare ips |
| `SOCKS5_RELAY` | No | `true` or `false` | Enable SOCKS5 relaying all traffic |
| Variable | Required | Example | Description |
| -------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| `UUID` | No | `12345678-1234-1234-1234-123456789012` | Unique identifier |
| `PROXYIP` | No | `1.1.1.1` or `cdn.xn--b6gac.eu.org` or with port `1.1.1.1:9443` or `[2a01:4f8:c2c:123f:64:5:6810:c55a]:443` or use multiple proxyIPs `1.1.1.1:80,2.2.2.2:443,example.com:443` | Redirect cloudflare ips to ProxyIP |
| `SOCKS5` | No | `1.1.1.1:1080` or `user:pass@host:port` | SOCKS5 proxy cloudflare ips |
| `SOCKS5_RELAY` | No | `true` or `false` | Enable SOCKS5 relaying all traffic |

### Enviroment variable setting workers
### Enviroment variable setting workers.dev

![workes](image/image-1.png)
![workers](image/image-1.png)

### Enviroment variable setting pages
### Enviroment variable setting pages.dev

![pages](image/image-2.png)

## How to use trojan
<!-- ## How to use trojan
1. the `UUID` enviroment variable is `trojan` password
2. v2ray path is `/trojan`
2. v2ray path is `/trojan` -->

## Lazy to deploy

Expand Down Expand Up @@ -117,19 +117,19 @@ Note: `UUID` is the uuid you want to set. pages.dev and worker.dev all of them m

2. visit `https://edtunnel.pages.dev/sub/uuid your set` to get the subscribe content with `uuid your set` path.

note: `uuid your set` is the uuid you set in UUID enviroment or `wrangler.toml`, `_worker.js` file.
Note: `uuid_your_set` is the uuid you set in UUID enviroment or `wrangler.toml`, `_worker.js` file.
when you set multiple uuid, you can use `https://edtunnel.pages.dev/sub/uuid1` to get the subscribe content with `uuid1` path.(only support first uuid in multiple uuid set)

3. visit `https://edtunnel.pages.dev/sub/uuid your set/?format=clash` to get the subscribe content with `uuid your set` path and `clash` format. content will return with base64 encode.
3. visit `https://edtunnel.pages.dev/sub/uuid_your_set/?format=clash` to get the subscribe content with `uuid_your_set` path and `clash` format. content will return with base64 encode.

note: `uuid your set` is the uuid you set in UUID enviroment or `wrangler.toml`, `_worker.js` file.
Note: `uuid_your_set` is the uuid you set in UUID enviroment or `wrangler.toml`, `_worker.js` file.
when you set multiple uuid, you can will use `https://edtunnel.pages.dev/sub/uuid1/?format=clash` to get the subscribe content with `uuid1` path and `clash` format.(only support first uuid in multiple uuid set)

## subscribe Cloudflare bestip(pure ip) link

1. visit `https://edtunnel.pages.dev/bestip/uuid your set` to get subscribe info.
1. visit `https://edtunnel.pages.dev/bestip/uuid_your_set` to get subscribe info.

2. cpoy subscribe url link `https://edtunnel.pages.dev/bestip/uuid your set` to any clients(clash/v2rayN/v2rayNG) you want to use.
2. cpoy subscribe url link `https://edtunnel.pages.dev/bestip/uuid_your_set` to any clients(clash/v2rayN/v2rayNG) you want to use.

3. done. if have any questions please join [@edtunnel](https://t.me/edtunnel)

Expand All @@ -156,14 +156,23 @@ if you deploy in cloudflare pages, https port is not supported. Simply add multi

2. When deploy in worker.dev, you can set proxyIP in `_worker.js` file. variable name is `proxyIP`.

note: `proxyIP` is the ip or domain you want to set. this means that the proxyIP is used to route traffic through a proxy rather than directly to a website that is using Cloudflare's (CDN). if you don't set this variable, connection to the Cloudflare IP will be cancelled (or blocked)...
3. You can now set multiple proxy IPs by separating them with commas. For example:
```
PROXYIP = "1.1.1.1:443,2.2.2.2:8443,example.com:443"
```
The system will randomly select one of these proxy addresses for each request, providing basic load balancing.

resons: Outbound TCP sockets to Cloudflare IP ranges are temporarily blocked, please refer to the [tcp-sockets documentation](https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/#considerations)
Note: `proxyIP` is the ip or domain you want to set. This means that the proxyIP is used to route traffic through a proxy rather than directly to a website that is using Cloudflare's (CDN). If you don't set this variable, connection to the Cloudflare IP will be cancelled (or blocked).

Reasons: Outbound TCP sockets to Cloudflare IP ranges are temporarily blocked, please refer to the [tcp-sockets documentation](https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/#considerations)

## Usage

frist, open your pages.dev domain `https://edtunnel.pages.dev/` in your browser, then you can see the following page:
The path `/uuid your seetting` to get the clash config and vless:// link.
The path `/uuid_your_set` to get the clash config and vless:// link.
you will see the following page:

![alt text](/image/image-3.png)

## Star History

Expand Down
Binary file added image/image-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export default {
socks5Address = SOCKS5 || socks5Address;
socks5Relay = SOCKS5_RELAY || socks5Relay;
if (PROXYIP) {
[proxyIP, proxyPort = '443'] = PROXYIP.split(':');
// Split PROXYIP into an array of proxy addresses
const proxyAddresses = PROXYIP.split(',').map(addr => addr.trim());
// Randomly select one proxy address
const selectedProxy = proxyAddresses[Math.floor(Math.random() * proxyAddresses.length)];
[proxyIP, proxyPort = '443'] = selectedProxy.split(':');
} else {
proxyPort = proxyIP.includes(':') ? proxyIP.split(':')[1] : '443';
proxyIP = proxyIP.split(':')[0];
Expand All @@ -55,7 +59,11 @@ export default {
console.log('ProxyPort:', proxyPort);
if (socks5Address) {
try {
parsedSocks5Address = socks5AddressParser(socks5Address);
// Split SOCKS5 into an array of addresses
const socks5Addresses = socks5Address.split(',').map(addr => addr.trim());
// Randomly select one SOCKS5 address
const selectedSocks5 = socks5Addresses[Math.floor(Math.random() * socks5Addresses.length)];
parsedSocks5Address = socks5AddressParser(selectedSocks5);
enableSocks = true;
} catch (err) {
console.log(err.toString());
Expand Down Expand Up @@ -313,7 +321,7 @@ async function handleTCPOutBound(remoteSocket, addressType, addressRemote, portR
if (enableSocks) {
tcpSocket = await connectAndWrite(addressRemote, portRemote, true);
} else {
tcpSocket = await connectAndWrite(proxyIP || addressRemote, proxyPort || portRemote);
tcpSocket = await connectAndWrite(proxyIP || addressRemote, proxyPort || portRemote, false);
}
// no matter retry success or not, close websocket
tcpSocket.closed.catch(error => {
Expand Down

0 comments on commit 883b65c

Please sign in to comment.