Network
This module can do network operations
Set timout
var network = Module.load("Network", { version: "v1.0.0" });
network.setTimeout(500); // default
the timeout value used for ping
, multiplePings
& traceroute
Pinging
var network = Module.load("Network", { version: "v1.0.0" });
var result = network.ping("sirenia.eu");
The result
is a PingResultInstance
JSON object with the following properties:
status
is the status of the attempted pingtime
is the round trip time of the pingbytes
is the amount of bytes receivedaddress
is the IP address of the replyttl
is the time to livetoString()
string representation of result
Pinging multiple times
var network = Module.load("Network", { version: "v1.0.0" });
var result = network.multiplePings("sirenia.eu", 7);
The result
is a MultiplePingInstance
JSON object with the following properties:
averageTime
is the average time for the pingsall
is an array containingPingResultInstance
for each pingtoString()
string representation like in terminal.
DNS lookup
var network = Module.load("Network", { version: "v1.0.0" });
var result = network.dnsLookup("sirenia.eu");
The result
is an array of strings which holds the IP addresses the host is know by, often just one result.
Wake On Lan
var network = Module.load("Network", { version: "v1.0.0" });
network.wakeOnLAN("04-7C-16-2C-61-C1");
Turns on the computer with the mac address “04-7C-16-2C-61-C1”
ARP
var network = Module.load("Network", { version: "v1.0.0" });
var res = network.arp();
The result
is an ArpInstance
JSON object, with the following properties:
table
returns an object with all IP’s mapped to a mac address- eg.
res.table["10.0.0.1"]
to get the mac of ip 10.0.0.1
- eg.
toString()
returns the table formatted as a string
Ipconfig
var network = Module.load("Network", { version: "v1.0.0" });
var res = network.ipconfig();
The result
is a IPConfigInstance
JSON object with the following properties:
mac
is your physical address / mac addressdnsSuffix
is your DNS suffixiPv4
is your IPv4 AddresssubnetMask
is your subnet maskDHCP
is your DHCP serverdnsServers
is your DNS servers as a string split by a spacedescription
is description on your internet devicename
is the name of your connectiontype
is the type of your connectionlinkLocalIPv6
is your link-local IPv6 addresstoString()
returns a string with all the information
Traceroute
var network = Module.load("Network", { version: "v1.0.0" });
var options = { ttl: 128 }; // default value
var res = network.traceroute("sirenia.eu", options);
the result
is a TracerouteInstance
JSON object with the following properties:
pings
is the array ofPingResultInstance
from the traceroutetoString()
returns a string formatted like traceroute in terminal
Netstat
var network = Module.load("Network", { version: "v1.0.0" });
var res = network.netstat("-a"); // -a is optional and does the same as -a for netstat in terminal
the result
is a NetStatInstance
JSON object with the following properties:
getActive()
returns an array ofActiveConnection
getTCPListeners()
returns an array ofListeningConnection
. Note this is empty if “-a” flag is not usedgetUDPListeners()
returns an array ofListeningConnection
. Note this is empty if “-a” flag is not usedtoString()
returns all results in a string
ActiveConnection
is a JSON with the following properties:
getLocalAddress()
returns the local addressgetForeignAddress()
returns the foreign addressgetState()
returns the state of the connectiontoString()
returns the connection formatted as a string
ListeningConnection
is a JSON with the following properties:
getLocalAddress()
returns the local addresstoString()
returns the connection formatted as a string