Spaces:
Sleeping
Sleeping
Download server.js from asboffical/ASB_Webproxy: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/asboffical/ASB_Webproxy/resolve/main/server.js
- Command line
-
hf download hf://spaces/asboffical/ASB_Webproxy/server.js
-
curl -L -o server.js https://huggingface.co/spaces/asboffical/ASB_Webproxy/resolve/main/server.js
1.46 kB
| import { createServer } from 'node:http'; | |
| import express from 'express'; | |
| import { fileURLToPath } from 'node:url'; | |
| import { dirname, join } from 'node:path'; | |
| import { createBareServer } from '@tomphttp/bare-server-node'; | |
| import { uvPath } from '@titaniumnetwork-dev/ultraviolet'; | |
| import { baremuxPath } from '@mercuryworkshop/bare-mux/node'; | |
| const __dirname = dirname(fileURLToPath(import.meta.url)); | |
| const bareServer = createBareServer('/bare/'); | |
| const app = express(); | |
| app.use(express.static(join(__dirname, 'public'))); | |
| app.use('/uv/', express.static(uvPath)); | |
| app.use('/baremux/', express.static(join(__dirname, 'node_modules', '@mercuryworkshop', 'bare-mux', 'dist'))); | |
| app.use('/bareclient/', express.static(join(__dirname, 'node_modules', '@tomphttp', 'bare-client', 'dist'))); | |
| app.use((req, res) => { | |
| res.status(404).sendFile(join(__dirname, 'public', 'index.html')); | |
| }); | |
| const server = createServer(); | |
| server.on('request', (req, res) => { | |
| if (bareServer.shouldRoute(req)) { | |
| bareServer.routeRequest(req, res); | |
| } else { | |
| app(req, res); | |
| } | |
| }); | |
| server.on('upgrade', (req, socket, head) => { | |
| if (bareServer.shouldRoute(req)) { | |
| bareServer.routeUpgrade(req, socket, head); | |
| } else { | |
| socket.end(); | |
| } | |
| }); | |
| const PORT = process.env.PORT || 8080; | |
| server.listen(PORT, () => { | |
| console.log(`Shadow Proxy is running at http://localhost:${PORT}`); | |
| }); | |