proxy / index.js
NexusV1's picture
Update index.js
7a2053d verified
Raw
History Blame Contribute Delete
3.47 kB
const http = require('http');
const net = require('net');
const url = require('url');
const PORT = 7860;
const server = http.createServer((req, res) => {
if (req.method === 'GET' && req.url === '/') {
// Serve status page
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Reiker Proxy Status</title>
<style>
body {
background-color: #0e0e2e;
color: #fff;
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
}
h1 {
color: #a259ff;
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
.card {
background: #1f1f3d;
border-radius: 10px;
padding: 30px;
box-shadow: 0 0 20px rgba(162, 89, 255, 0.2);
max-width: 400px;
width: 90%;
text-align: center;
}
.status {
margin: 15px 0;
font-size: 1.2rem;
}
.status span {
font-weight: bold;
color: #a259ff;
}
.footer {
margin-top: 20px;
font-size: 0.9rem;
color: #aaa;
}
a {
color: #a259ff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="card">
<h1>Reiker Proxies</h1>
<div class="status">๐ŸŸข <span>Status:</span> Online</div>
<div class="status">๐Ÿ”Œ <span>Port:</span> ${PORT}</div>
<div class="status">๐Ÿ“ถ <span>Ping:</span> 1ms</div>
<div class="status">๐Ÿง  <span>Mode:</span> HTTP/HTTPS Proxy</div>
<div class="footer">Contact on Telegram: <a href="https://t.me/ReikerX" target="_blank">@ReikerX</a></div>
</div>
</body>
</html>
`);
return;
}
// Normal proxy behavior
const parsed = url.parse(req.url);
const options = {
hostname: parsed.hostname,
port: parsed.port || 80,
path: parsed.path,
method: req.method,
headers: req.headers
};
const proxyReq = http.request(options, (proxyRes) => {
res.writeHead(proxyRes.statusCode, proxyRes.headers);
proxyRes.pipe(res);
});
req.pipe(proxyReq);
proxyReq.on('error', (err) => {
res.writeHead(500);
res.end('Error: ' + err.message);
});
});
// HTTPS CONNECT tunneling
server.on('connect', (req, clientSocket, head) => {
const [host, port] = req.url.split(':');
const serverSocket = net.connect(port || 443, host, () => {
clientSocket.write('HTTP/1.1 200 Connection Established\r\n\r\n');
if (head && head.length) serverSocket.write(head);
serverSocket.pipe(clientSocket);
clientSocket.pipe(serverSocket);
});
serverSocket.on('error', (err) => {
console.error('โŒ HTTPS tunnel error:', err.message);
clientSocket.write('HTTP/1.1 500 Connection Error\r\n\r\n');
clientSocket.end();
});
});
server.listen(PORT, '0.0.0.0', () => {
console.log(`โœ… Reiker Proxy running on port ${PORT}`);
});;