Coder Social home page Coder Social logo

racket-net-ip's Introduction

net-ip

CI/CD

Utilities for working with IP addresses in Racket.

Documentation

The documentation is hosted on docs.racket-lang.org.

License

net-ip is licensed under the 3-Clause BSD license.

racket-net-ip's People

Contributors

aymanosman avatar bogdanp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

racket-net-ip's Issues

Proposal: add a network-last-address function

I was pleasantly surprised to find this library when I needed it, so thanks!

I found myself needing to calculate IP ranges from cidr blocks.
I came up with the following:

#lang racket

;; LIBRARY

(require net/ip)

(define (network-last-address net)
  (number->ipv4-address
   (+ (sub1 (network-size net))
      (ip-address->number (network-address net)))))

;; APPLICATION

(define (ip-range net)
  (values (ip-address->string (network-address net))
          (ip-address->string (network-last-address net))))

(ip-range (make-network "10.0.0.0/16"))

Which got me wondering if it makes sense to expose a network-last-address function in this library.

minor documentation bugs

bytes->ipv6-address claims to require 4 bytes as input, which seems to be a little short for an ipv6 address.

Both bytes->ipv*-address functions claim that an execption is raised if the bytes are not in big-endian order. While the result might not match the expectation of the caller, an exception cannot be raised if the input bytes are not in big-endian order. How about

Unpack a byte array in big endian order into an IPv* address. 
Must be exactly * bytes long, otherwise an exn:fail:contract? is raised.

replacing * with the correct number, of course :-)

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.