diff --git a/ingestors/node/src/modules/express.js b/ingestors/node/src/modules/express.js index 131d442e..88833241 100644 --- a/ingestors/node/src/modules/express.js +++ b/ingestors/node/src/modules/express.js @@ -21,7 +21,7 @@ function initialize({ key, host, pool }) { const data = JSON.stringify({ request: { url: { - host: _req.hostname, + host: _req.socket.remoteAddress, path: _req.route.path, parameters: Object.entries(_req.query).map(([k, v]) => ({ name: k, value: v })), }, @@ -30,7 +30,7 @@ function initialize({ key, host, pool }) { method: _req.method, }, response: { - url: `${_req.socket.remoteAddress}:${_req.socket.remotePort}`, + url: `${_req.socket.localAddress}:${_req.socket.localPort}`, status: _res.statusCode, headers: Object.entries(_res.getHeaders()).map(([k, v]) => ({ name: k, value: v })), body: responseBody, @@ -40,9 +40,8 @@ function initialize({ key, host, pool }) { incoming: true, source: _req.socket.remoteAddress, sourcePort: _req.socket.remotePort, - // TODO : Add destination - destination: "server.hostname", - destinationPort: "server.port", + destination: _res.socket.localAddress, + destinationPort: _res.socket.localPort, } }) diff --git a/ingestors/node/src/modules/fastify.js b/ingestors/node/src/modules/fastify.js index 2614c9e7..12e7135e 100644 --- a/ingestors/node/src/modules/fastify.js +++ b/ingestors/node/src/modules/fastify.js @@ -22,16 +22,16 @@ function initialize({ key, host, pool }) { { request: { url: { - host: request.hostname, + host: request.raw.socket.remoteAddress, path: request.routerPath, parameters: Object.entries(request.query).map(([k, v]) => ({ name: k, value: v })), }, headers: Object.entries(request.headers).map(([k, v]) => ({ name: k, value: v })), - body: request.body || "No Body", + body: request.body || "", method: request.method, }, response: { - url: `${response.raw.socket.remoteAddress}:${response.raw.socket.remotePort}`, + url: `${response.raw.socket.localAddress}:${response.raw.socket.localPort}`, status: response.statusCode, headers: Object.entries(response.headers).map(([k, v]) => ({ name: k, value: v })), body: response.body, @@ -41,9 +41,8 @@ function initialize({ key, host, pool }) { incoming: true, source: request.raw.socket.remoteAddress, sourcePort: request.raw.socket.remotePort, - // TODO : Add destination - destination: "server.hostname", - destinationPort: "server.port", + destination: response.raw.socket.localAddress, + destinationPort: response.raw.socket.localPort, } } ) diff --git a/ingestors/node/src/modules/koa.js b/ingestors/node/src/modules/koa.js index 78d84d42..f367828c 100644 --- a/ingestors/node/src/modules/koa.js +++ b/ingestors/node/src/modules/koa.js @@ -23,16 +23,16 @@ function initialize({ key, host, pool }) { { request: { url: { - host: ctx.request.hostname, + host: ctx.response.socket.remoteAddress, path: ctx.path, parameters: Object.entries(ctx.query).map(([k, v]) => ({ name: k, value: v })), }, headers: Object.entries(ctx.request.headers).map(([k, v]) => ({ name: k, value: v })), - body: ctx.request.body || "No Body", + body: ctx.request.body || "", method: ctx.request.method, }, response: { - url: `${ctx.response.socket.remoteAddress}:${ctx.response.socket.remotePort}`, + url: `${ctx.response.socket.localAddress}:${ctx.response.socket.localPort}`, status: ctx.response.statusCode, headers: Object.entries(ctx.response.headers).map(([k, v]) => ({ name: k, value: v })), body: ctx.body, @@ -42,9 +42,8 @@ function initialize({ key, host, pool }) { incoming: true, source: ctx.request.socket.remoteAddress, sourcePort: ctx.request.socket.remotePort, - // TODO : Add destination - destination: "server.hostname", - destinationPort: "server.port", + destination: ctx.request.socket.localAddress, + destinationPort: ctx.request.socket.localPort, } } )