File size: 3,465 Bytes
b2dc7b4
 
 
d73e2a9
 
 
b2dc7b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d73e2a9
b2dc7b4
 
 
 
 
 
 
 
 
d73e2a9
b2dc7b4
 
 
 
d73e2a9
b2dc7b4
 
 
 
 
d73e2a9
 
b2dc7b4
 
7a2053d
 
 
b2dc7b4
7a2053d
b2dc7b4
 
 
d73e2a9
7a2053d
 
 
 
b2dc7b4
d73e2a9
 
7a2053d
b2dc7b4
7a2053d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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}`);
});;