27 lines
541 B
JavaScript
27 lines
541 B
JavaScript
'use strict';
|
|
|
|
const net = require('node:net');
|
|
|
|
const PORT = Number(process.env.PORT || 19090);
|
|
const HOST = process.env.HOST || '0.0.0.0';
|
|
|
|
if (Number.isNaN(PORT)) {
|
|
throw new Error('PORT must be a number');
|
|
}
|
|
|
|
const server = net.createServer((socket) => {
|
|
socket.setKeepAlive(true, 15000);
|
|
|
|
socket.on('data', (buf) => {
|
|
const msg = buf.toString('utf8').trim();
|
|
if (msg === 'ping') {
|
|
socket.write('pong\n');
|
|
}
|
|
});
|
|
});
|
|
|
|
server.listen(PORT, HOST, () => {
|
|
console.log(`[probe] listening on ${HOST}:${PORT}`);
|
|
});
|
|
|