Spaces:
Running
Running
File size: 1,163 Bytes
b59d98b 0526d9d b59d98b 18e92b1 b59d98b 18e92b1 b59d98b |
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 |
const fastify = require('fastify')({ logger: true });
let MANAGEMENT_SERVER_PORT = 1689;
let SERVER_HOST = '0.0.0.0';
console.log(`************ Management Server v 0.002 ************`);
fastify.get('/', async (request, reply) => {
const localUrl = request.headers['host'];
let htmlContent = `
<html>
<head><title>Proxy Server</title></head>
<body>
<button onclick="redirect()">Goto: ${localUrl}</button>
<script>
function redirect() {
window.location.replace('http://${localUrl}/omnitool');
}
</script>
<div id="logs" style="white-space: pre-wrap;"></div>
</body>
</html>
`;
reply.type('text/html').send(htmlContent);
});
const start = async () => {
try {
await fastify.listen({ port: MANAGEMENT_SERVER_PORT, host: SERVER_HOST });
console.log(`Server is listening on port ${MANAGEMENT_SERVER_PORT}`);
} catch (err) {
console.error(`Error starting server: ${err}`);
process.exit(1);
}
};
start();
|