Skip to content

Demayl/raku-Sys-IP

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
t
 
 
 
 
 
 
 
 
 
 
 
 

raku Sys::IP

Build Status

Get system IP / Interfaces with Raku programming language

VERSION

0.1.0

DESCRIPTION

Get system IP/DNS/Gateway addresses and interfaces. It doesn't rely on ifconfig/ipconfig etc. It does this by using routing table default route and C ABI. All method works fine on Linux only ( for now ). BSD is the next target.

Coming soon

BSD, Windows

Why not ifconfig / ipconfig

Really ?

Example

use Sys::IP;

# Get system default IP
say Sys::IP.new.get_default_ip(); # 192.168.0.1

# Get all active IP's
say Sys::IP.new.get_ips(); # [ 192.168.0.1, 192.168.0.2 ]

# Get all active interfaces
say Sys::IP.new.get_interfaces(); # [ { name => eth0, ip-addr => 192.168.0.1 }, ...]

# Get all DNS addresses
say Sys::IP.new.get_dns_ips(); # [ 127.0.0.23, 8.8.8.8 ]

Constructor

  • :$ipv6 = False include ipv6 addresses
  • :$loopback = False include loopback interface
  • :$active = True include only active interfaces
  • :$ip = True include only interfaces with assigned IP address

Methods

  • new( Bool :$ipv6 = False, Bool :$loopback = False, Bool :$active = True, Bool :$ip = True --> Sys::IP )
  • get_default_ip( --> Str ) when used with :ipv6 it will return only ipv6 address
  • get_ips( --> Array )
  • get_interfaces( --> Array[Hash] )

Instalation

zef install Sys::IP

Testing

prove -ve 'perl6 -Ilib'

About

Get host IP / Interfaces

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages