Skip to content
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

RFC1918 IPs shouldn't be discarded by default #8

Closed
hrefhref opened this issue Dec 24, 2018 · 1 comment
Closed

RFC1918 IPs shouldn't be discarded by default #8

hrefhref opened this issue Dec 24, 2018 · 1 comment

Comments

@hrefhref
Copy link

Hi,
I started using this plug in applications that are only deployed in a VPN/LAN. However, it discards all the clients IPs as they are RFC1918 IPs (mostly 10/8, some 192.168/16).

It would be nice to allow an option to not discard some of theses reserved networks. Maybe even sub-ranges if that makes more sense (e.g. our VPN is 10.42/16).

@ajvondrak
Copy link
Owner

See, I was paranoid about this exact issue while hard-coding the private networks in

# https://en.wikipedia.org/wiki/Loopback
# https://en.wikipedia.org/wiki/Private_network
@reserved ~w[
127.0.0.0/8
::1/128
fc00::/7
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
]
I think I was just copying what Rails was doing: https://github.com/rails/rails/blob/94b5cd3a20edadd6f6b8cf0bdf1a4d4919df86cb/actionpack/lib/action_dispatch/middleware/remote_ip.rb#L31-L42

What do you think about maybe lifting @reserved out into another keyword option, where the default is the currently-hard-coded list? Then you could init the plug with reserved: [...]. I guess for your use case a whitelist might make more sense, though. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants