diff --git a/services/geolocation.js b/services/geolocation.js index 6201f96..c356609 100644 --- a/services/geolocation.js +++ b/services/geolocation.js @@ -32,8 +32,9 @@ const getClientIP = (req) => { } let cleanIP = realIP.replace(/^::ffff:/, "").trim(); - if (cleanIP.includes(".") && !cleanIP.includes(":")) { - cleanIP = cleanIP.replace(/:\d+$/, ""); + const ipv4PortMatch = cleanIP.match(/^(\d+\.\d+\.\d+\.\d+):\d+$/); + if (ipv4PortMatch) { + cleanIP = ipv4PortMatch[1]; } return cleanIP; diff --git a/services/identification.js b/services/identification.js index 18dfc0a..b430516 100644 --- a/services/identification.js +++ b/services/identification.js @@ -206,7 +206,8 @@ const getId = async (req) => { recognition.data.modelInfo = { model: modelUsed, country: country || 'Unknown', - locationSource: locationSource + locationSource: locationSource, + detectedIP: detectedIP }; const metadata = {