-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
37 lines (27 loc) · 963 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { xAPnetAddress } from '../lib/xap-net-address'
import { NetworkInterfaceInfoIPv4 } from 'os';
console.log('Test xAPnetAddress:')
var myint: NetworkInterfaceInfoIPv4 | undefined
try {
myint = xAPnetAddress.defaultInterface()
} catch {
console.log(' Exception thrown: default gateway could not be determined - is there a network?')
process.exit(1)
}
if(myint) {
console.log(' Selected network interface is: ' + myint.mac)
let myip = xAPnetAddress.defaultIP()
if(myip) {
console.log(' Default IP calculated as: ' + myip.toString())
} else {
console.log(' Default IP could not be determined')
}
let mybr = xAPnetAddress.defaultBroadcastIP()
if(mybr) {
console.log(' Default broadcast IP calculated as: ' + mybr.toString())
} else {
console.log(' Default broadcast IP could not be determined')
}
} else {
console.log(' Error: Appropriate network interface could not be determined - are there any?')
}