https://github.com/globocom/iprange
IPRange - Redis as a storage for IP range
https://github.com/globocom/iprange
Last synced: 10 months ago
JSON representation
IPRange - Redis as a storage for IP range
- Host: GitHub
- URL: https://github.com/globocom/iprange
- Owner: globocom
- License: mit
- Created: 2014-03-19T21:39:15.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2020-05-11T20:45:06.000Z (about 6 years ago)
- Last Synced: 2025-10-09T13:46:32.992Z (10 months ago)
- Language: Lua
- Size: 17.6 KB
- Stars: 14
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# IPRange
Store IP Ranges in Redis as sorted sets for fast retrieval
## Installation
Add this line to your application's Gemfile:
gem 'iprange'
And then execute:
$ bundle
Or install it yourself as:
$ gem install iprange
## Usage
> redis_config = {host: "127.0.0.1"}
> range = IPRange::Range.new(redis_config)
> range.add("192.168.0.1/24", some: "data", more: "metadata")
> range.find("192.168.0.20")
=> {:range=>"192.168.0.1/24", "some"=>"data", "more"=>"metadata"}
## Notice
This gem relies on [a Redis fork that implements interval sets](https://github.com/hoxworth/redis/tree/2.6-intervals), as described in this [blog post](http://blog.togo.io/how-to/adding-interval-sets-to-redis/).
If your intervals do not, you can try the tag v0.0.1, which uses sorted sets instead of inverval sets.
## Contributing
1. Fork it ( http://github.com/globocom/iprange/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request