From 344d13a4c48e8d2c3d5c3ba206a5e5471c04ecf4 Mon Sep 17 00:00:00 2001 From: 3Kmfi6HP <58669916+3Kmfi6HP@users.noreply.github.com> Date: Sat, 23 Mar 2024 20:25:36 +0700 Subject: [PATCH] Add endpoint for retrieving best IP configuration --- _worker.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/_worker.js b/_worker.js index d4c136d8f..9c0d7fea7 100644 --- a/_worker.js +++ b/_worker.js @@ -70,6 +70,16 @@ export default { } }); }; + case `/bestip/${userID_Path}`: { + const bestSubConfig = await fetch(`https://sub.xf.free.hr/auto?host=${request.headers.get('Host')}&uuid=${userID}`); + // Construct and return response object + return new Response(bestSubConfig, { + status: 200, + headers: { + "Content-Type": "text/plain;charset=utf-8", + } + }); + }; default: // return new Response('Not found', { status: 404 }); // For any other path, reverse proxy to 'ramdom website' and return the original response, caching it in the process @@ -712,7 +722,7 @@ ${vlessSec} ---------------------------------------------------------------`; }).join('\n'); const sublink = `https://${hostName}/sub/${userIDArray[0]}?format=clash` - const subbestip = `https://sub.xf.free.hr/auto?host=${hostName}&uuid=${userIDArray[0]}`; + const subbestip = `https://${hostName}/bestip/${userIDArray[0]}`; const clash_link = `https://api.v1.mk/sub?target=clash&url=${encodeURIComponent(sublink)}&insert=false&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`; // Prepare header string const header = `