Giter Club home page Giter Club logo

iana's Introduction

What

IANA Ruby module Gem Version Code Climate

Look up TCP/IP port numbers, protocols, top-level domains, et al.

Get data from the Internet Assigned Numbers Authority (IANA) and make it available to your programs.

Install

gem install iana-data

In your Gemfile

gem 'iana-data'

Usage

require 'iana'

IANA::TLD.valid?("com")
=> true
IANA::TLD.valid?(".com")
=> true
IANA::TLD.valid?("isthisforreal")
=> false

prot = IANA::Protocol[25]
=> #<IANA::Protocol:0x00563e8bdd18a8 @protocol=25, @name="LEAF-1", @description="Leaf-1", @references=["Barry_Boehm"]>
prot.number
=> 25

port = IANA::Port[25]
=> [#<IANA::Port:0x00556cba04b600 @port=25, @keyword="smtp", @protocol="tcp", @description="Simple Mail Transfer">, #<IANA::Port:0x00556cba04b1a0 @port=25, @keyword="smtp", @protocol="udp", @description="Simple Mail Transfer">]
port.map(&:protocol)
=> ["tcp", "udp"]

IANA::Port.select port: 25, protocol: "udp"
=> {25=>[#<IANA::Port:0x00556cba1f3d90 @port=25, @keyword="smtp", @protocol="udp", @description="Simple Mail Transfer">]}

IANA::Port::DCCP[25]
=> []
IANA::Port::DCCP[8282]
=> [#<IANA::Port:0x00556cb9bc7840 @port=8282, @keyword="", @protocol="dccp", @description="Reserved">]

IANA::Port::UDP[443]
=> [#<IANA::Port:0x00556cba1a43a8 @port=443, @keyword="https", @protocol="udp", @description="http protocol over TLS/SSL">]

You still need to download some data files manually, while the IANA module is rewritten to make use of open-uri everywhere.

The IANA Ruby module loads the data into conveniently searchable data structures. The flat files the IANA Ruby module consume as data are hosted at iana.org. You will need to fetch them so you can process the content locally. I grab these files with with curl (but you can use wget or whatever if you don't use curl):

curl -L -O http://www.iana.org/assignments/ethernet-numbers

Examples

When you run the example programs, do it like so:

ruby examples/ports.rb port-numbers

Use these example programs to see how you might use and otherwise integrate IANA data functionality into your own programs.

Contribute

The source is availble at https://github.com/ringe/iana

Fork, patch and send a pull request.

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.