包详细信息

getmac

bevry272.6kArtistic-2.06.6.0

Get the MAC address of the current machine you are on.

deno, deno-edition, deno-entry, denoland

自述文件

getmac

Status of the GitHub Workflow: bevry NPM version NPM downloads
GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button
Discord server badge Twitch community badge

Get the MAC address of the current machine you are on.

This library will not run in web browsers / on the client-side / in webpack / in browserify / in angular / in react / in jQuery / in HTML. It will only run on Node.js environments, which the web browser is not.

Usage

Complete API Documentation.

CLI

Install globally npm install -g getmac, then run with getmac-node

API

Install locally npm install --save getmac, then use like so:

import getMAC, { isMAC } from 'getmac'

// Fetch the computer's MAC address
console.log(getMAC())

// Fetch the computer's MAC address for a specific interface
console.log(getMAC('eth0'))

// Validate that an address is a MAC address
if (isMAC('e4:ce:8f:5b:a7:fc')) {
    console.log('valid MAC')
} else {
    console.log('invalid MAC')
}

Advanced

If you want to do advanced filtering, use os.networkInterfaces() instead.

Install

npm

  • Install: npm install --save getmac
  • Import: import pkg from ('getmac')
  • Require: const pkg = require('getmac').default

Deno

import pkg from 'https://unpkg.com/getmac@^6.6.0/edition-deno/index.ts'

Editions

This package is published with the following editions:

  • getmac/source/index.ts is TypeScript source code with Import for modules
  • getmac aliases getmac/edition-es2022/index.js
  • getmac/edition-es2022/index.js is TypeScript compiled against ES2022 for Node.js 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modules
  • getmac/edition-es2022-esm/index.js is TypeScript compiled against ES2022 for Node.js 12 || 14 || 16 || 18 || 20 || 21 with Import for modules
  • getmac/edition-types/index.d.ts is TypeScript compiled Types with Import for modules
  • getmac/edition-deno/index.ts is TypeScript source code made to be compatible with Deno

History

Discover the release history by heading on over to the HISTORY.md file.

Backers

Code

Discover how to contribute via the CONTRIBUTING.md file.

Authors

Maintainers

Contributors

Finances

GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button

Sponsors

  • Andrew Nesbitt — Software engineer and researcher
  • Balsa — We're Balsa, and we're building tools for builders.
  • Codecov — Empower developers with tools to improve code quality and testing.
  • Poonacha Medappa
  • Rob Morris
  • Sentry — Real-time crash reporting for your web apps, mobile apps, and games.
  • Syntax — Syntax Podcast

Donors

License

Unless stated otherwise all works are:

and licensed under:

更新日志

History

v6.6.0 2023 December 29

v6.5.0 2023 December 27

v6.4.0 2023 December 6

v6.3.0 2023 November 25

v6.2.0 2023 November 21

v6.1.0 2023 November 15

v6.0.0 2023 November 13

  • Updated dependencies, base files, and editions using boundation
  • Minimum required Node.js version changed from node: >=10 to node: >=8 adapting to ecosystem changes

v5.21.0 2023 November 1

v5.20.0 2021 July 30

v5.19.0 2021 July 29

v5.18.0 2021 July 28

v5.17.0 2020 October 29

v5.16.0 2020 September 4

v5.15.0 2020 August 18

v5.14.0 2020 August 4

v5.13.0 2020 July 22

v5.12.0 2020 July 22

v5.11.0 2020 June 25

v5.10.0 2020 June 21

v5.9.0 2020 June 21

v5.8.0 2020 June 20

v5.7.0 2020 June 10

v5.6.0 2020 June 10

v5.5.0 2020 May 22

v5.4.0 2020 May 21

v5.3.0 2020 May 20

v5.2.0 2020 May 6

v5.1.0 2020 January 29

v5.0.0 2019 December 18

v4.4.0 2019 December 9

v4.3.0 2019 December 1

v4.2.0 2019 December 1

v4.1.0 2019 November 18

v4.0.1 2019 November 18

  • MAC addresses with single character parts are now considered valid

v4.0.0 2019 November 18

v3.0.1 2019 November 18

  • Better handling of errors with the getmac-node binary

v3.0.0 2019 November 18

  • getMac renamed to getMAC and has the function signature (iface?: string) => Promise<string>
  • extractMAC is now exported, if you already have the MAC interfaces string, with the signature (input: string, iface?: string) => string
  • isMac renamed to isMAC
  • Converted to TypeScript
  • Updated dependencies, base files, and editions using boundation

v2.0.0 2019 November 18

  • Updated dependencies, base files, and editions using boundation
  • Minimum required node version changed from node: >=0.10 to node: >=8 to keep up with mandatory ecosystem changes

v1.5.0 2019 November 13

v1.4.6 2018 September 3

v1.4.5 2018 August 24

  • Updated dependencies

v1.4.4 2018 August 19

  • Minimum supported node version is now 0.10
  • Updated base files and editions using boundation

v1.4.3 2018 June 7

v1.4.2 2018 June 6

v1.4.1 2018 March 28

v1.4.0 2018 January 25

  • Now compiled with CoffeeScript v2
  • Now uses editions to use the ESNext compiled edition for environments that support it, otherwise use the ES2015 compiled edition
  • Updated base files

v1.3.0 2018 January 25

v1.2.1 2016 May 10

v1.1.0 2016 May 10

  • Updated dependencies
  • Repackaged

v1.0.7 2015 March 5

  • Added fix for iproute2 commands in absence of ifconfig on Linux machines

v1.0.6 2013 October 27

  • Repackaged

v1.0.5 2013 September 2

  • Will now ignore zero-filled mac addresses and error if none are found - Thanks to Uwe Klawitter for issue #1
  • Can now pass an optional object as the first argument to getmac that can contain data as a String to scan instead of executing the appropriate command to fetch the data
  • Dependency updates

v1.0.4 2013 February 12

  • Better compatibility with linux distros

v1.0.3 2013 February 12

  • Minor optimisation

v1.0.2 2013 February 12

  • Fixed windows support, turns out they format mac addresses differently

v1.0.1 2013 February 12

  • Renamed getmac executable to getmac-node to avoid conflict on windows

v1.0.0 2013 February 12

  • Initial working commit