Code Monkey home page Code Monkey logo

default-gateway's Issues

Can't get IP Address on Windows 11

WMIC was removed from Windows 10/11.

image

There's no other way to implement this feature without WMIC, or with the new 'Powershell for WMI'?

Intention to deprecate this module

I intend to deprecate this module soon as I'm not willing to maintain it further because it's just a wrong approach overall to parse command output.

Affected users should look for alternatives. For webpack-dev-server, see my recommendation.

Code improvements

child_process.execFile() should be used over .exec() as it's both faster and safer. I think we should also use either pify or execa to make the code more readable.

"interface" is a strict mode reserved keyword

according to this link,
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode#paving_the_way_for_future_ecmascript_versions
interface is a reserved word to use in 'use strict';.

I ran into the node error with default example of destructuring
const {gateway, interface} = await defaultGateway.v4();
and had to go the const interface_v4 = gtw.interface way...

I would propose adding an alias of smth like interf to keep it backwards-compat. Alas it's not that big of a deal to skip the destructive sugar once.
Maybe a warning would be nice as well.

Question about docs

Hi, the docs say for the sync method that it should be:

const result = defaultGateway.v4().sync();
// result = {gateway: '1.2.3.4', interface: 'en1'}

const result = defaultGateway.v6().sync();
// result = {gateway: '2001:db8::1', interface: 'en2'}

But looking at the source, it is seems like it's supposed to be:

const result = defaultGateway.v4.sync();
// result = {gateway: '1.2.3.4', interface: 'en1'}

const result = defaultGateway.v6.sync();
// result = {gateway: '2001:db8::1', interface: 'en2'}

Is that right?

node version broken

{
"name": "default-gateway",
  "version": "5.0.4",
  "description": "Get the default network gateway, cross-platform.",
  "author": "silverwind <[email protected]>",
  "repository": "silverwind/default-gateway",
  "license": "BSD-2-Clause",
  "scripts": {
    "test": "eslint *.js && node --pending-deprecation --trace-deprecation --throw-deprecation --trace-warnings test.js"
  },
  "engines": {
    "node": ">=8"
  },
  "dependencies": {
    "execa": "^3.0.0"
  }
}

execa requires: "node": "^8.12.0 || >=9.7.0", but in your package node engines are "node": ">=8".
However, that does not match, please check it. Thanks.

Windows: The gateway is not from external card

When a computer has virtual network adapters with a gateway, it's selecting the first that finds, but not necessarily is the gateway of the external card.

Example: after run wmic path Win32_NetworkAdapterConfiguration where IPEnabled=true get DefaultIPGateway,Index /format:table in windows I get this response:

3 
{"0.0.0.0"} 5 
{"192.168.1.1", "fe80::dafb:5eff:fe33:3489"} 6 
8

and after parse it the result is 0.0.0.0, but the gateway of the external card is 192.168.1.1

Unsupported platform FreeBSD

npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin,linux,win32","arch":"any"} (current: {"os":"freebsd","arch":"x64"})
npm ERR! notsup Valid OS: darwin,linux,win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: freebsd
npm ERR! notsup Actual Arch: x64

A little funny seeing how it´s BSD licensed :)

/K

idbconnector dependency

When i install default-gateway 3.1.0 console warns about:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\idb-connector):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"aix","arch":"any"} (current: {"os":"win32","arch":"x64"})

and then, when i try to install deps with npm ci it starts to install idb-connector. And result is:

> [email protected] install C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | win32 | x64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\lib\binding\Release\node-v64-ibmi-x64\db2ia.node" (not found)
node-pre-gyp http GET https://github.com/IBM/nodejs-idb-connector/releases/download/1.1.8/db2ia-v1.1.8-node-v64-ibmi-x64.tar.gz
node-pre-gyp http 404 https://github.com/IBM/nodejs-idb-connector/releases/download/1.1.8/db2ia-v1.1.8-node-v64-ibmi-x64.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/IBM/nodejs-idb-connector/releases/download/1.1.8/db2ia-v1.1.8-node-v64-ibmi-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/IBM/nodejs-idb-connector/releases/download/1.1.8/db2ia-v1.1.8-node-v64-ibmi-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Python27\python.exe
gyp info spawn args [ 'C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=2015',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\user\\Desktop\\aa\\electron-quick-start\\node_modules\\idb-connector\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\user\\.node-gyp\\10.15.1\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\user\\.node-gyp\\10.15.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\user\\.node-gyp\\10.15.1\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\user\\Desktop\\aa\\electron-quick-start\\node_modules\\idb-connector',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\user\\Desktop\\aa\\electron-quick-start\\node_modules\\idb-connector\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
  db2ia.cc
  dbconn.cc
  dbstmt.cc
  win_delay_load_hook.cc
c:\users\user\desktop\aa\electron-quick-start\node_modules\idb-connector\src\db2ia\dbconn.h(13): fatal error C1083: Cannot open include file: 'sqlcli.h': No such file or directory (compiling source file ..\src
\db2ia\db2ia.cc) [C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\build\db2ia.vcxproj]
c:\users\user\desktop\aa\electron-quick-start\node_modules\idb-connector\src\db2ia\dbconn.h(13): fatal error C1083: Cannot open include file: 'sqlcli.h': No such file or directory (compiling source file ..\src
\db2ia\dbconn.cc) [C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\build\db2ia.vcxproj]
c:\users\user\desktop\aa\electron-quick-start\node_modules\idb-connector\src\db2ia\dbconn.h(13): fatal error C1083: Cannot open include file: 'sqlcli.h': No such file or directory (compiling source file ..\src
\db2ia\dbstmt.cc) [C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\build\db2ia.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\user\\Desktop\\aa\\electron-quick-start\\node_modules\\idb-connector\\lib\\binding\\Release\\node-v64-ibmi-x64\\db2ia.node" "--module_name=db2ia" "--module_path=C:\\Users\\user\\Desktop\\aa\\electron-quick-start\\node_modules\\idb-connector\\lib\\binding\\Release\\node-v64-ibmi-x64" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\lib\binding\Release\node-v64-ibmi-x64\db2ia.node --module_name=db2ia --module_path=C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\lib\binding\Release\node-v64-ibmi-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Windows_NT 10.0.17134
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\Desktop\\aa\\electron-quick-start\\node_modules\\idb-connector\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector
node-pre-gyp ERR! node -v v10.15.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\lib\binding\Release\node-v64-ibmi-x64\db2ia.node --module_name=db2ia --module_path=C:\Users\user\Desktop\aa\electron-quick-start\node_modules\idb-connector\lib\binding\Release\node-v64-ibmi-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)

With default-gateway v3.0.1 all is ok.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.