-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenv.js
More file actions
37 lines (30 loc) 路 844 Bytes
/
Copy pathenv.js
File metadata and controls
37 lines (30 loc) 路 844 Bytes
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
34
35
36
37
const os = require('os');
const fs = require('fs');
const path = require('path');
class Env {
constructor() {
}
async defaultNetworkInterface()
{
if( process.platform === 'win32' || process.platform === 'linux' )
{
return await this.getDefaultInterface();
}
else if( process.platform === 'darwin' )
{
return 'en0';
}
}
async getDefaultInterface() {
const si = require('systeminformation');
let interfaces = await si.networkInterfaces();
for( var iFace of interfaces )
{
if( iFace.virtual == false && iFace.internal == false && iFace.ip4 ){
return iFace.ifaceName;
}
}
return "Not Found";
}
}
module.exports = new Env();