Skip to content

(feature) Add local server address and port to node ingestor #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions ingestors/node/src/modules/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })),
},
Expand All @@ -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,
Expand All @@ -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,
}
})

Expand Down
11 changes: 5 additions & 6 deletions ingestors/node/src/modules/fastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}
}
)
Expand Down
11 changes: 5 additions & 6 deletions ingestors/node/src/modules/koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}
}
)
Expand Down