Skip to content

Commit

Permalink
Update: add build in bestip subscribe link
Browse files Browse the repository at this point in the history
  • Loading branch information
3Kmfi6HP committed Nov 27, 2023
1 parent 40a4608 commit 341cb6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Logs
logs
*.log

.wrangler
# Dependency directories
node_modules/

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ Note: `UUID` is the uuid you want to set. pages.dev and worker.dev all of them m
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.

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)

## multiple port support (Optional)

<!-- let portArray_http = [80, 8080, 8880, 2052, 2086, 2095];
Expand Down
14 changes: 8 additions & 6 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ export default {
* @returns {Promise<Response>}
*/
async fetch(request, env, ctx) {
uuid_validator(request);
// uuid_validator(request);
try {
userID = env.UUID || userID;
proxyIP = env.PROXYIP || proxyIP;
dohURL = env.DNS_RESOLVER_URL || dohURL;
// nodeId = env.NODE_ID || nodeId;
// apiToken = env.API_TOKEN || apiToken;
// apiHost = env.API_HOST || apiHost;
let userID_Path = userID;
if (userID.includes(',')) {
userID_Path = userID.split(',')[0];
Expand Down Expand Up @@ -62,12 +59,10 @@ export default {
const url = new URL(request.url);
const searchParams = url.searchParams;
let vlessConfig = createVLESSSub(userID, request.headers.get('Host'));

// If 'format' query param equals to 'clash', convert config to base64
if (searchParams.get('format') === 'clash') {
vlessConfig = btoa(vlessConfig);
}

// Construct and return response object
return new Response(vlessConfig, {
status: 200,
Expand All @@ -76,6 +71,13 @@ export default {
}
});
}
case `/bestip/${userID_Path}`: {
const bestiplink = `https://sub.xf.free.hr/auto?host=${request.headers.get('Host')}&uuid=${userID_Path}`
const reqHeaders = new Headers(request.headers);
const bestipresponse = await fetch(bestiplink, { redirect: 'manual', headers: reqHeaders, });
// Construct and return response object
return bestipresponse
}
default:
// return new Response('Not found', { status: 404 });
// For any other path, reverse proxy to 'www.fmprc.gov.cn' and return the original response, caching it in the process
Expand Down

0 comments on commit 341cb6a

Please sign in to comment.