reject-connection.js 419 Bytes
const MODULE_NAME = 'KOMODO-SDK-PUSH-TRX.SERVER.REJECT-CONNECTION';

const logger = require('tektrans-logger');

module.exports = (req, socket) => {
    logger.warn(`${MODULE_NAME} 1AF7E0FA: Rejecting unauthorized client`, {
        remoteAddress: req.socket.remoteAddress,
        token: req.headers.apikey || req.headers.token,
    });

    socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
    socket.destroy();
};