Skip to content

Commit

Permalink
Update worker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Surfboardv2ray authored Sep 26, 2024
1 parent 0a71b11 commit 95da978
Showing 1 changed file with 83 additions and 1 deletion.
84 changes: 83 additions & 1 deletion worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Developed by Surfboardv2ray, https://github.com/Surfboardv2ray/Trojan-worker
// Version 1.1
// Version 1.2
// Tips: Change your subLinks accordingly. Note that only ws+tls+443 configs will work.
// Your subscription link will be: 'https://{your_worker_address}.workers.dev/sub/{your_clean_ip}'


const subLinks = [
'https://raw.githubusercontent.com/Surfboardv2ray/Proxy-sorter/main/ws_tls/proxies/wstls',
'https://raw.githubusercontent.com/itsyebekhe/HiN-VPN/main/subscription/normal/trojan',
Expand All @@ -18,6 +19,87 @@ export default {
let realhostname = pathSegments[0] || '';
let realpathname = pathSegments[1] || '';

// Handle the base URL ("/")
if (url.pathname === '/') {
// Return the HTML content
return new Response(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Trojan-worker</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff;
color: #333;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
.container {
text-align: center;
padding: 20px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
a {
color: #007BFF;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
p {
margin: 20px 0;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007BFF;
color: #ffffff;
cursor: pointer;
margin-top: 20px;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Developed by Surfboardv2ray</h1>
<p><a href="https://github.com/Surfboardv2ray/Trojan-worker" target="_blank">https://github.com/Surfboardv2ray/Trojan-worker</a></p>
<p>Your Subscription link will be:</p>
<p id="subscription-link"><strong>https://{worker-address}/sub/{clean-ip}</strong></p>
<button id="get-clean-ip">Get Clean IP</button>
</div>
<script>
document.getElementById('get-clean-ip').onclick = async function() {
const response = await fetch('https://raw.githubusercontent.com/ircfspace/cf2dns/refs/heads/master/list/ipv4.json');
const data = await response.json();
const randomIndex = Math.floor(Math.random() * data.length);
const cleanIP = data[randomIndex].ip;
const workerAddress = window.location.hostname;
const subscriptionLink = \`https://\${workerAddress}/sub/\${cleanIP}\`;
document.getElementById('subscription-link').innerHTML = \`<a href="\${subscriptionLink}" target="_blank">\${subscriptionLink}</a>\`;
}
</script>
</body>
</html>
`, {
headers: { 'Content-Type': 'text/html' },
});
}

// Create sets to store unique paths for each protocol
let trojanPaths = new Set();
let vlessPaths = new Set();
Expand Down

0 comments on commit 95da978

Please sign in to comment.