Add identity headers to requests
This commit is contained in:
parent
af643a86fb
commit
203629639f
8
index.js
8
index.js
|
@ -15,6 +15,7 @@ const markdown = require('markdown-it')();
|
|||
const ejs = require('ejs');
|
||||
const { connect } = require('http2');
|
||||
const serveIndex = require('serve-index');
|
||||
const hostname = process.env.HOST_OVERRIDE || os.hostname();
|
||||
|
||||
const app = express();
|
||||
expressWs(app);
|
||||
|
@ -26,6 +27,12 @@ app.use(express.urlencoded({ extended: true }));
|
|||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
|
||||
// Add ident headers
|
||||
app.use((req, res, next) => {
|
||||
res.header("Node-UUID", curUUID);
|
||||
res.header("Node-Hostname", hostname);
|
||||
next();
|
||||
});
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
const markdownFilePath = path.join(__dirname, 'md', 'DOCS.md');
|
||||
|
@ -70,7 +77,6 @@ app.ws('/iem', (ws, req) => {
|
|||
console.log(req.headers)
|
||||
const clientIp = process.env.REALIP ? req.headers[process.env.REALIP.toLowerCase()] || req.ip : req.ip;
|
||||
console.log(`connection from ${clientIp}`);
|
||||
const hostname = process.env.HOST_OVERRIDE || os.hostname();
|
||||
if (!req.headers['user-agent']) {
|
||||
ws.send(JSON.stringify({
|
||||
"type": "internal-response",
|
||||
|
|
Loading…
Reference in a new issue