Adding 8021x windows function
This commit is contained in:
parent
a4c27734ed
commit
7c3c8b2436
@ -293,6 +293,36 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getWindowsIEEE8021x(connectionType) {
|
||||||
|
let i8021x = {
|
||||||
|
state: 'Unknown',
|
||||||
|
protocol: 'Unknown',
|
||||||
|
};
|
||||||
|
if(connectionType == 'wired'){
|
||||||
|
try {
|
||||||
|
const state8021x = execSync('netsh lan show interface', util.execOptsWin);
|
||||||
|
console.log('state funtion', state8021x);
|
||||||
|
const stateRsult = state8021x.output.split('\n').pop();
|
||||||
|
const currentState = stateRsult.includes('auth');
|
||||||
|
i8021x.state = currentState ? 'Enabled' : 'Disabled';
|
||||||
|
if (i8021x.state === 'Disabled') {
|
||||||
|
return i8021x;
|
||||||
|
}
|
||||||
|
const protocol8021x = execSync('netsh lan show profiles', util.execOptsWin);
|
||||||
|
console.log('protocol function', protocol8021x);
|
||||||
|
protocol8021x.output.split('\r\n').filter((protocolauth) => {
|
||||||
|
const currentProtocol = protocolauth.includes('EAP');
|
||||||
|
if(currentProtocol) i8021x.protocol = protocolauth.split(':').pop();
|
||||||
|
});
|
||||||
|
return i8021x;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
return i8021x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i8021x;
|
||||||
|
}
|
||||||
|
|
||||||
function splitSectionsNics(lines) {
|
function splitSectionsNics(lines) {
|
||||||
const result = [];
|
const result = [];
|
||||||
let section = [];
|
let section = [];
|
||||||
@ -436,13 +466,15 @@ function getLinuxIfaceDNSsuffix(connectionName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLinuxIfaceAuthProtocol(connectionName) {
|
function getLinuxIfaceAuth8021x(connectionName) {
|
||||||
if(connectionName) {
|
if(connectionName) {
|
||||||
const cmd = `nmcli connection show "${connectionName}" \| grep 802-1x.eap;`;
|
const cmd = `nmcli connection show "${connectionName}" \| grep 802-1x.eap;`;
|
||||||
try {
|
try {
|
||||||
const result = execSync(cmd).toString();
|
const result = execSync(cmd).toString();
|
||||||
const resultFormat = result.replace(/\s+/g,' ').trim();
|
const resultFormat = result.replace(/\s+/g,' ').trim();
|
||||||
const authenticationProtocol = resultFormat.split(" ").slice(1).toString();
|
const authenticationProtocol = resultFormat.split(" ").slice(1).toString();
|
||||||
|
|
||||||
|
|
||||||
return authenticationProtocol == '--' ? '': authenticationProtocol;
|
return authenticationProtocol == '--' ? '': authenticationProtocol;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return 'Not configured';
|
return 'Not configured';
|
||||||
@ -452,6 +484,17 @@ function getLinuxIfaceAuthProtocol(connectionName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLinuxIfaceState8021x(authenticationProtocol) {
|
||||||
|
if(authenticationProtocol) {
|
||||||
|
if(authenticationProtocol == 'Not configured'){
|
||||||
|
return 'Disabled';
|
||||||
|
}
|
||||||
|
return 'Enabled';
|
||||||
|
} else {
|
||||||
|
return 'Unknown';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function testVirtualNic(iface, ifaceName, mac) {
|
function testVirtualNic(iface, ifaceName, mac) {
|
||||||
const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97'];
|
const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97'];
|
||||||
if (mac) {
|
if (mac) {
|
||||||
@ -523,7 +566,8 @@ function networkInterfaces(callback) {
|
|||||||
let operstate = 'down';
|
let operstate = 'down';
|
||||||
let dhcp = false;
|
let dhcp = false;
|
||||||
let dnsSuffix = '';
|
let dnsSuffix = '';
|
||||||
let authProtocol = '';
|
let auth8021x = '';
|
||||||
|
let state8021x = '';
|
||||||
let type = '';
|
let type = '';
|
||||||
|
|
||||||
if (ifaces.hasOwnProperty(dev)) {
|
if (ifaces.hasOwnProperty(dev)) {
|
||||||
@ -580,7 +624,8 @@ function networkInterfaces(callback) {
|
|||||||
const connectionName = getLinuxIfaceConnectionName(iface);
|
const connectionName = getLinuxIfaceConnectionName(iface);
|
||||||
dhcp = getLinuxIfaceDHCPstatus(connectionName);
|
dhcp = getLinuxIfaceDHCPstatus(connectionName);
|
||||||
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
|
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
|
||||||
authProtocol = getLinuxIfaceAuthProtocol(connectionName);
|
auth8021x = getLinuxIfaceAuth8021x(connectionName);
|
||||||
|
state8021x = getLinuxIfaceState8021x(auth8021x);
|
||||||
lines = execSync(cmd).toString().split('\n');
|
lines = execSync(cmd).toString().split('\n');
|
||||||
|
|
||||||
|
|
||||||
@ -603,7 +648,8 @@ function networkInterfaces(callback) {
|
|||||||
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
authProtocol = 'Unknown';
|
|
||||||
|
|
||||||
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
||||||
nics.forEach(detail => {
|
nics.forEach(detail => {
|
||||||
if (detail.mac === mac) {
|
if (detail.mac === mac) {
|
||||||
@ -614,6 +660,11 @@ function networkInterfaces(callback) {
|
|||||||
type = detail.type;
|
type = detail.type;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('type', type);
|
||||||
|
const IEEE8021x = getWindowsIEEE8021x(type);
|
||||||
|
console.log('result', IEEE8021x);
|
||||||
|
auth8021x = IEEE8021x.protocol;
|
||||||
|
state8021x = IEEE8021x.state;
|
||||||
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) {
|
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) {
|
||||||
type = 'wireless';
|
type = 'wireless';
|
||||||
}
|
}
|
||||||
@ -635,7 +686,8 @@ function networkInterfaces(callback) {
|
|||||||
speed,
|
speed,
|
||||||
dhcp,
|
dhcp,
|
||||||
dnsSuffix,
|
dnsSuffix,
|
||||||
authProtocol,
|
auth8021x,
|
||||||
|
state8021x,
|
||||||
carrierChanges,
|
carrierChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user