UNPKG

3.47 kBMarkdownView Raw
1# oui
2[![](https://img.shields.io/npm/v/oui.svg?style=flat)](https://www.npmjs.org/package/oui) [![](https://img.shields.io/npm/dm/oui.svg)](https://www.npmjs.org/package/oui)
3> Look up MAC addresses for their vendor in the IEEE OUI database
4
5The data used in this module comes from the [IEEE OUI Data](https://standards-oui.ieee.org/oui/oui.txt) which is updated once a week on Sunday. The module is also able self-update on demand.
6
7## Installation
8```console
9$ npm i oui
10```
11## Example
12```js
13var oui = require('oui');
14
15console.log(oui('20:37:06:12:34:56'));
16//=> Cisco Systems, Inc
17//=> 80 West Tasman Drive
18//=> San Jose CA 94568
19//=> United States
20
21console.log(oui.search('*Juniper Systems*'))
22//=> [
23//=> {
24//=> oui: '0C0535',
25//=> organization: 'Juniper Systems\n1132 W. 1700 N.\nLogan UT 84321\nUnited States'
26//=> }
27//=> ]
28```
29
30## Installation (CLI)
31```console
32$ npm install -g oui
33```
34## Examples (CLI)
35```console
36$ oui 20:37:06:12:34:56
37Cisco Systems, Inc
3880 West Tasman Drive
39San Jose CA 94568
40United States
41```
42```console
43$ oui --search cisco theory
44OUI ORGANZATION ADDRESS COUNTRY
45000C41 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
46000F66 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
47001217 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
48001310 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
49```
50To update the local OUI database:
51```console
52$ oui --update
53```
54Or from the original IEEE source (slow):
55```console
56$ oui --update http://standards.ieee.org/develop/regauth/oui/oui.txt
57```
58
59## API
60### oui(input, [options])
61- `input` *string*: The input string. Non-hexadecimal characters and characters after 6 hex characters are found are ignored unless `options.strict` is set.
62- `options` *Object*: A optional options object.
63 - `strict` *boolean*: When `true`, only [strict input formats will be accepted](#strictformats). Will throw an error when an invalid format is supplied.
64 - `file` *string*: A absolute file path to `oui.json`, which contains the parsed oui data. Defaults to the `oui.json` in the module directory.
65
66Returns: Either a string, or `null` if no matches are found. Throws if input is not a string.
67
68### oui.update([options])
69- `options` *Object*: A optional options object.
70 - `url` *string*: The URL from where to retrieve `oui.txt`. Default `"https://standards-oui.ieee.org/oui/oui.txt"`.
71 - `file` *string*: A absolute file path for `oui.json`, which is used to store the parsed oui data. Defaults to the `oui.json` in the module directory.
72
73Returns: A Promise that indicates when the internal database has been updated. Rejects on error.
74
75### oui.search(patterns [, options])
76- `patterns` *string/Array*: One or more wildcard patterns to search the vendor data, as supported by [minimatch](https://github.com/isaacs/minimatch).
77- `options` *Object*: A optional options object.
78 - `file` *String*: A absolute file path for `oui.json`, which is used to store the parsed oui data. Defaults to the `oui.json` in the module directory.
79 - All [minimatch options](https://github.com/isaacs/minimatch#options) are supported as well.
80
81Returns a array of objects in the format {oui, organization}.
82<a name="strictformats" />
83#### strict formats
84- `000000`
85- `00:00:00`
86- `00-00-00`
87- `000000000000`
88- `0000.0000.0000`
89- `00:00:00:00:00:00`
90- `00-00-00-00-00-00`
91
92© [silverwind](https://github.com/silverwind), distributed under BSD licence