Network
This module can do network operations
Set timout
var network = Module.load("Network", { version: "v1.0.0" });
network.setTimeout(500); // defaultthe 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:
statusis the status of the attempted pingtimeis the round trip time of the pingbytesis the amount of bytes receivedaddressis the IP address of the replyttlis 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:
averageTimeis the average time for the pingsallis an array containingPingResultInstancefor 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:
tablereturns 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:
macis your physical address / mac addressdnsSuffixis your DNS suffixiPv4is your IPv4 AddresssubnetMaskis your subnet maskDHCPis your DHCP serverdnsServersis your DNS servers as a string split by a spacedescriptionis description on your internet devicenameis the name of your connectiontypeis the type of your connectionlinkLocalIPv6is 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:
pingsis the array ofPingResultInstancefrom 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 terminalthe result is a NetStatInstance JSON object with the following properties:
getActive()returns an array ofActiveConnectiongetTCPListeners()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
