Code Monkey home page Code Monkey logo

inet-address's Introduction

inet-address

Build StatusDependencies StatusClojars ProjectTagClojure version

Clojure wrapper for Java InetAddress (also: Inet4Address, Inet6Address, & NetworkInterface)

About

Work with InetAddress objects in pure Clojure using Clojure programming idioms.

Documentation

Usage

Require the bits of inet-address you will need:

(require '[clojure.test :refer :all]
         '[inet.address :as inet]
         '[inet.address.six :as inet6]
         '[inet.interface :as netface]))

Then make the calls as needed, e.g.:

=> (inet/by-address "testhost" [1 2 3 4])
#object[java.net.Inet4Address 0x7d5e0016 "testhost/1.2.3.4"]
=> (inet6/by-address
     "testhost"
     [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
     0)
#object[java.net.Inet6Address 0x19487de9 "testhost/1:203:405:607:809:a0b:c0d:e0f%0"]
(inet/reachable? (inet/localhost) 100) ; timeout after 100 milliseconds
true

Or, for network interfaces:

=> (netface/network-interfaces)
[#object[java.net.NetworkInterface 0x2e79299 "name:veth06a443d (veth06a443d)"]
 #object[java.net.NetworkInterface 0x66fe36f4 "name:docker0 (docker0)"]
 #object[java.net.NetworkInterface 0x2eda7437 "name:wlp3s0 (wlp3s0)"]
 #object[java.net.NetworkInterface 0x4916292d "name:lo (lo)"]]
=> (netface/by-name "docker0")
#object[java.net.NetworkInterface 0x69fdab5e "name:docker0 (docker0)"]
=> (netface/up? (netface/by-name "docker0"))
true
=> (netface/hardware-address (netface/by-name "docker0"))
["02" "42" "b4" "b7" "0b" "5f"]
=> (netface/inet-addresses (netface/by-name "docker0"))
[#object[java.net.Inet6Address 0x36fad3e9 "/fe80:0:0:0:42:b4ff:feb7:b5f%docker0"]
 #object[java.net.Inet4Address 0x1dde9ac5 "/172.17.0.1"]]

License

Copyright © 2017 BilloSystems, Ltd. Co.

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

inet-address's People

Contributors

oubiwann 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.