Skip to content

Commit

Permalink
Format origin IP as IPv4 where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Apr 2, 2024
1 parent fc213a6 commit edc90bb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/endpoints/anything.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export async function anythingEndpoint(req: http.IncomingMessage, res: http.Serv

const contentType = req.headers['content-type'];

const origin = req.socket.remoteAddress?.replace(/^::ffff:/, '') // Drop IPv6 wrapper of IPv4 addresses

let result: {} = {
args: getUrlArgs(url),
data: asJsonSafeString(input, contentType),
Expand All @@ -93,7 +95,7 @@ export async function anythingEndpoint(req: http.IncomingMessage, res: http.Serv
).sort((a, b) => a < b ? -1 : a > b ? 1 : 0)),
json: jsonValue,
method: req.method,
origin: req.socket.remoteAddress,
origin: origin,
url: url.toString()
};

Expand Down

0 comments on commit edc90bb

Please sign in to comment.