Wiki - Network Information

Compatibility

Background

Obtain detailed network information from the PC such as ip, mac, and hostname.

Caveats

Code

Primary Adapter

Using qz.networking.device(), you can obtain information about the primary adapter used by the a PC.

// Get information about a single device
qz.networking.device().then(device => console.log(device));

// Returns
▶️ {
   hostname: "inspiron",
   id: "Local Area Connection",
   ip: "192.168.1.9",
   ip4: (1) ["192.168.1.9"],
   ip6: (1) ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
   mac: "C4910CB0B9A7",
   name: "Local Area Connection",
   primary: true,
   up: true,
   username: "Administrator"
}

To obtain only the MAC address of the PC:

// Get information about a single network device
qz.networking.device().then(device => console.log(device.mac));

// Returns
"C4910CB0B9A7"

All Adapters

Using qz.networking.devices(), you can obtain an array of all adapter information used by the PC.

qz.networking.devices().then(devices => console.log(devices));

// Returns
(3) [...]
▶️ 0: {name: "Local Area Connection", ip: "192.168.1.9", ip4: Array(1), ip6: Array(1), primary: true, up: true,}
▶️ 1: {name: "Wireless Network Connection", ip: "192.168.1.12", ip6: Array(1), primary: false, up: true,}
▶️ 2: {name: "Loopback Adapter", ip: "127.0.0.1", ip4: Array(1), ip6: Array(1), primary: false,}

... trouble locating the correct adapter? Consider using a data-filter.

Override Default Domain

By default, QZ Tray makes a socket connection to google.com to resolve the default network adapter. If google.com is unreachable, you may use an IP or hostname of your choosing.

// use 'yahoo.com' to identify the default network adapter
qz.networking.device({ hostname: 'yahoo.com', port: 443 }).then(device => console.log(device));
Edit this page