Giter Site home page Giter Site logo

node-ipware's Introduction

Hi there - πŸ‘‹ Avidcoder here. Serving clients in πŸ‡¨πŸ‡¦ πŸ‡ΊπŸ‡Έ

  • FullerStack - A unified mono-repo setup for seamless full-stack development with Angular and NestJS.

  • AvidCaster - A library enabling real-time handwriting annotations directly on live video streams.

  • Chat Overlay - A library designed to display live chat from YouTube and Twitch directly on live video streams.

  • PlayItForward - A comprehensive repository bundle for launching an ERC-20 token, complete with a dedicated website and smart contract infrastructure.

  • Python Slugify - A Python slugify application that handles unicode.

  • Python IpWare - A python package for server applications to retrieve client's IP address

And many more open source packages for your use.

For support, reach out to us at ✨ [email protected] ✨

node-ipware's People

Contributors

allthecodes avatar tmikov avatar un33k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-ipware's Issues

Sample code produces invalid result

As per the title, the sample code on the readme page produces the following:
{ clientIp: '::ffff:127.0.0.1', clientIpRoutable: true }

node 7.9.0
macOS 10.12.4

Any ideas?

Coding style refactoring?

Hello!

Thank you for this great module!

However, the code looks out of the Node.js universe, it looks very unnatural and hard to comprehend. Please consider refactoring it according to some good coding standards, like these for example: https://github.com/felixge/node-style-guide.

Thank you for your hard work!
Cheers!

Add option to prefer last valid IP in comma-delimited header value, not first

It appears the code currently recognises that a request header like X-Forwarded-For may have a comma-delimited list of IP addresses and will return the left-most valid routable IP address from the list.

However, as these headers are subject to spoofing, often it is only the right-most IP address in the list that can be trusted (because the proxy responsible for adding the right-most value is the only trusted proxy).

Perhaps introduce a config setting or optional argument that would cause a list to be processed right-to-left instead.

Global vars

The following leaks were detected: alt_key_lower, ipv4_pattern, alt_key_upper, key_lower, key_upper

Instead of a normal ip, a strange

I could do without your package just by referring to the req variable and truncate the address with the slice (7) command. At you here such problem in a package:
var getIP = require('ipware')().get_ip; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); res.end('Hello\n'); fs.appendFileSync('ip', getIP(req).clientIp+'\n'); });
But then I saw this in the file:
127.0.0.1 ::ffff:77.160.120.90
That's getting in the way ::ffff:

ip with port

I tried to use the library and found a strange issue. My request has an x-forwarded-for header with a valid ip but it has a port specified (x-forwarded-for: "99.247.8.214:65263")
I keep getting 127.0.0.1 instead of this ip and I'm thinking it's because the is_valid_ip method is returning false.
Anyone run into this?

TIA

Andrew

Only one type of IP

The server where I'm running node doesn't have support for IPv6; ergo the result address is always prefixed by ::ffff:.
Is there a way to get only the IPv4 address ?

Thank you.

ip-ware always return 127.0.0.1 with some nginx configs

I've found that the current config have some issues with nginx servers acting as reverse proxy. You may want to consider this change in the configuration of the IPWARE_HTTP_HEADER_PRECEDENCE_ORDER as default, which solves nginx use case and possibly others.

"IPWARE_HTTP_HEADER_PRECEDENCE_ORDER": [
"HTTP_X_FORWARDED_FOR",
"HTTP_CLIENT_IP",
"HTTP_X_REAL_IP",
"HTTP_X_FORWARDED",
"HTTP_X_CLUSTER_CLIENT_IP",
"HTTP_FORWARDED_FOR",
"HTTP_FORWARDED",
"HTTP_VIA",
"X_FORWARDED_FOR",
"REMOTE_ADDR",
"HTTP-X-FORWARDED-FOR",
"HTTP-CLIENT-IP",
"HTTP-X-REAL-IP",
"HTTP-X-FORWARDED",
"HTTP-X-CLUSTER-CLIENT-IP",
"HTTP-FORWARDED-FOR",
"HTTP-FORWARDED",
"HTTP-VIA",
"X-CLIENT-IP",
"X-REAL-IP",
"X-FORWARDED",
"X-CLUSTER-CLIENT-IP",
"X-FORWARDED-FOR",
"REMOTE-ADDR"
]

Hope it helps,
Pablo

Occasionally throws

Unhandled error: TypeError: Cannot call method 'toLowerCase' of undefined
   at Object._me.is_private_ip (/var/www/com03-crosscountry-api/node_modules/ipware/index.js:55:21)
   at Object._me.get_ip (/var/www/com03-crosscountry-api/node_modules/ipware/index.js:147:22)
   at ServerResponse.<anonymous> (/var/www/com03-crosscountry-api/route/entry-handler.js:17:28)
   at ServerResponse.emit (events.js:117:20)
   at ServerResponse.OutgoingMessage._finish (http.js:1021:8)
   at ServerResponse.OutgoingMessage.end (http.js:1004:10)
   at Stream.onend (stream.js:79:10)
   at Stream.emit (events.js:117:20)
   at Server.<anonymous> (/var/www/com03-crosscountry-api/server.js:12:5)
   at Server.emit (events.js:98:17)
   at HTTPParser.parser.onIncoming (http.js:2113:12)
   at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:122:23)
   at Socket.socket.ondata (http.js:1971:22)
   at TCP.onread (net.js:528:27)

500 Error - Cannot read property toLowerCase of undefined

I am getting some random errors that I cannot find the reason why. Any idea? Thanks!

Sending 500 ("Server Error") response: TypeError: Cannot read property 'toLowerCase' of undefined at Object._me.is_private_ip (/node_modules/ipware/index.js:55:20) at Object._me.get_ip (/node_modules/ipware/index.js:147:22) at Object.module.exports.parse (/api/services/HitService.js:14:30) at Object.bound (/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21) at Object.module.exports.view (/api/controllers/HitController.js:20:34) at bound (/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21) at routeTargetFnWrapper (/node_modules/sails/lib/router/bind.js:179:5) at callbacks (/node_modules/sails/node_modules/express/lib/router/index.js:164:37) at param (/node_modules/sails/node_modules/express/lib/router/index.js:138:11) at param (/node_modules/sails/node_modules/express/lib/router/index.js:135:11) at pass (/node_modules/sails/node_modules/express/lib/router/index.js:145:5) at nextRoute (/node_modules/sails/node_modules/express/lib/router/index.js:100:7) at callbacks (/node_modules/sails/node_modules/express/lib/router/index.js:167:11) at /node_modules/sails/lib/router/bind.js:187:7 at alwaysAllow (/node_modules/sails/lib/hooks/policies/index.js:207:11) at routeTargetFnWrapper (/node_modules/sails/lib/router/bind.js:179:5) [TypeError: Cannot read property 'toLowerCase' of undefined]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.