Giter Club home page Giter Club logo

mac2vendor-api-selfhosting's Introduction

mac2vendor/OUI-lookup API for static webservers

This POSIX shell script fetches the latest OUI file,
parses it and generates a filesystem-hierarchy which
can be used from a static webserver for a very simple
mac2vendor API, e.g. for the mac-address 3C:D9:2B:xx:xx:xx

# curl http://yourserver/oui/3c/d9/2b
Hewlett Packard

on your server execute this (needs ~6 min / 23 mbytes disk)

# ./update.sh /var/www/oui

this repository is updated once a day.

This poor mens API make sense on embedded or IoT-devices
with a low amount of storage. You can try it on this demo-server:

# curl http://intercity-vpn.de/oui/3c/d9/2b
# curl http://intercity-vpn.de/oui/3c/d9/2b.json

For the lazy people there is also an up-to-date 1.6mb-tar.xz:

# mkdir /var/www/oui && cd /var/www/oui
# wget http://intercity-vpn.de/oui/oui.tar.xz
# tar xJf oui.tar.xz

Ready.

example mac2vendor (posix shell function)

#!/bin/sh

mac2vendor()
{
	local vendor cachefile mac=$1

	set -- $( echo "${mac:-aa,bb,cc}" | tr 'A-F' 'a-f' | tr -c '0-9a-f' ' ' )
	cachefile="/dev/shm/mac2vendor-$1-$2-$3"

	cat "$cachefile" 2>/dev/null || {
		vendor="$( wget -qO - "http://intercity-vpn.de/oui/$1/$2/$3" | head -n1 )"
		[ "$vendor" ] && echo "$vendor" && echo "$vendor" >"$cachefile"
	}
}

cronjob on server:

# once: git config --global user.name 'bot'
# once: git config --global user.email 'bot@yourdomain'
# while :;do rm oui.txt; ./update.sh /var/www/oui; git push; sleep 86400; done

TODO

# grep '(base 16)' oui.txt |
   while read L; do set -- $L; shift 3; echo $*; done |
    sort -u |
     tr -cd '\11\12\15\40-\176' |
      sed 's/\(.\)/\1\n/g' |
       sort -u
79

mac2vendor-api-selfhosting's People

Contributors

bittorf avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

vaginessa

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.