Skip to content

Commit

Permalink
Update _worker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
cmliu authored Mar 6, 2024
1 parent 70d8884 commit 813947e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,10 @@ function socks5AddressParser(address) {
}

function revertFakeInfo(content, userID, hostName, isBase64) {
if (isBase64) {
content = atob(content)
}
if (isBase64) content = atob(content);//Base64解码
content = content.replace(new RegExp(fakeUserID, 'g'), userID).replace(new RegExp(fakeHostName, 'g'), hostName);
if (isBase64) {
content = btoa(content)
}
if (isBase64) content = btoa(content);//Base64编码

return content;
}

Expand Down Expand Up @@ -872,14 +869,12 @@ async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
---------------------------------------------------------------
################################################################
`;
} else if (sub) {
} else {
if (typeof fetch != 'function') {
return 'Error: fetch is not available in this environment.';
}
// 如果是使用默认域名,则改成一个workers的域名,订阅器会加上代理
if (hostName.includes(".workers.dev") || hostName.includes(".pages.dev")) {
fakeHostName = "EXAMPLE.workers.dev";
}
// 如果是使用默认域名,则改成一个workers的域名,订阅器会加上代理
if (hostName.includes(".workers.dev") || hostName.includes(".pages.dev")) fakeHostName = "EXAMPLE.workers.dev";
let content = "";
let url = "";
let isBase64 = false;
Expand All @@ -892,12 +887,15 @@ async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
isBase64 = true;
}
try {
const response = await fetch(url);
const response = await fetch(url ,{
headers: {
'User-Agent': 'CF-Workers-edgetunnel/cmliu'
}});
content = await response.text();
return revertFakeInfo(content, userID, hostName, isBase64);
} catch (error) {
console.error('Error fetching content:', error);
return `Error fetching content: ${error.message}`;
}
}
}
}

0 comments on commit 813947e

Please sign in to comment.