From 16132c434c516c468b2ec05cdc5e999fbd7a760c Mon Sep 17 00:00:00 2001 From: echicken <echicken@bbs.electronicchicken.com> Date: Fri, 24 Feb 2023 07:16:27 +0000 Subject: [PATCH] Comments for the future --- xtrn/wttr.in/locator.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xtrn/wttr.in/locator.js b/xtrn/wttr.in/locator.js index 1de3c6088c..6dccc11915 100644 --- a/xtrn/wttr.in/locator.js +++ b/xtrn/wttr.in/locator.js @@ -1,13 +1,15 @@ -/* - * Just IP address lookup for now - * wttr.in does the geoip for us (albeit inaccurately) - * To do: do something with user.location / zipcode as an alternative? - */ +// To do: use user.location / zipcode if available? function getAddress() { const addrRe = /(^0\.0\.0\.0$)|(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/; - if (client.ip_address.search(addrRe) < 0) return client.ip_address; + if (client.ip_address.search(addrRe) < 0) return client.ip_address; // Not a private/local address + /* + * User has a private address and may be coming from websocketservice.js. + * Check if their IP address was written to a temp file for us. + * + * There's a very slim chance of false positives here, but whatever. + */ const f = new File(system.temp_path + 'sbbs-ws-' + client.socket.remote_port + '.ip'); if (!f.exists) return; if (!f.open('r')) return; -- GitLab