networkInterfaceDefault() optimization (macOS)

This commit is contained in:
Sebastian Hildebrandt
2020-09-16 22:31:43 +02:00
parent 57cd89ac74
commit e03431d6ae
6 changed files with 23 additions and 17 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ function getDefaultNetworkInterface() {
if (_darwin || _freebsd || _openbsd || _netbsd || _sunos) {
let cmd = '';
if (_linux) cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\'';
if (_darwin) cmd = 'route get 0.0.0.0 2>/dev/null | grep interface: | awk \'{print $2}\'';
if (_darwin) cmd = 'route -n get default 2>/dev/null | grep interface: | awk \'{print $2}\'';
if (_freebsd || _openbsd || _netbsd || _sunos) cmd = 'route get 0.0.0.0 | grep interface:';
let result = execSync(cmd);
ifacename = result.toString().split('\n')[0];