Coder Social home page Coder Social logo

jmoney / cidr-encoder Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 36 KB

CLI for time efficiently encoding cidr blocks to find if an IP exists in a range

Home Page: https://www.jmoney.dev/cidr-encoder

License: Apache License 2.0

Go 98.30% Shell 1.70%
github-site homebrew-formula license-management mkdocs

cidr-encoder's Introduction

Cidr Encoder

Converts a list of CIDRs to an encoded file for time efficient lookups on is a given IP address in any of the CIDR blocks. Each CIDR block is on its own line in the input file. The output file is a binary file that can be read by the cidr-encoder program for searching. The lookup time is O(1) for any IP address. However, to achieve this the output file can easily be several GBs if there are a wide range of CIDR blocks across the IPv4 addresses space.

The calculation for how big a file would take is effectively the largest IP - the smallest IP. As the algorithm uses file offsets to determine if an IP is in a list of CIDR blocks, the largest IP is the largest offset in the file. We use the smallest IP to normalize everything to first offset of a file. This is done to reduce the size of the file so the difference between the two is the size of the file.

Usage

$ cidr-encoder -h
Usage of cidr-encoder:
  -calc
        Calculate the size of the encoded file. Reads from STDIN.
  -encode
        Encode the CIDRs. Reads from STDIN.
  -name string
        The file base name to use as the ACL file name(e.g test.acl name is test).
  -search string
        Search for a IP in the CIDRs.

-calc, encode, and search are all mutually exclusive but the priority in the event that all are specified are calc then encode then search.

cidr-encoder's People

Contributors

jmoney avatar

Watchers

 avatar

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.