lts-po / plugin-oui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OUI plugin for SPR

Sample SPR plugin in node.js to return oui info for a MAC address prefix

Add to SPR

checkout the repo & add the state/plugin-oui directory for the http socket:

$ cd super
$ git clone https://github.com/lts-po/plugin-oui.git
$ mkdir state/plugin-oui

add the container to docker-compose.yaml:

  plugin-oui:
    container_name: super-plugin-oui
    build: plugin-oui
    network_mode: host
    logging: 
      driver: journald
    depends_on:
      - "base"
    volumes:
      - ./state/plugin-oui/:/state/plugin-oui/

build and run the container:

$ ./build_docker_compose.sh plugin-oui
$ docker-compose up -d plugin-oui

make sure the api is running:

$ curl --unix-socket ./state/plugin-oui/oui_plugin http:///localhost/001122

Add plugin to the API

add a defenition under Plugins in state/api/config:

{
  "Plugins" : [
    {
      "Name": "dns-block",
      "URI": "dns/block",
      "UnixPath": "/state/dns/dns_block_plugin"
    },
    {
      "Name": "dns-log",
      "URI": "dns/log",
      "UnixPath": "/state/dns/dns_log_plugin"
    },
    {
      "Name": "oui",
      "URI": "oui",
      "UnixPath": "/state/plugin-oui/oui_plugin"
    }
  ]
}

make sure the state directory is mounted for api in docker-compose.yaml:

  api:
    container_name: superapi
    build: api
    network_mode: host
    privileged: true
    restart: always
    depends_on:
      - "base"
      - "wifid"
      - "dhcp"
      - "frontend"
    logging:
      driver: journald
    volumes:
      - ./configs/base/:/configs/base/
      - ./configs/devices/:/configs/devices/
      - ./configs/zones/:/configs/zones/
      - ./configs/wifi/:/configs/wifi/
      - ./configs/scripts/:/configs/scripts/
      - ./state/wifi/:/state/wifi/
      - ./state/dhcp/:/state/dhcp/
      - ./state/api/:/state/api/
      - ./state/dns/:/state/dns/
      - ./state/plugin-oui/:/state/plugin-oui/
      - ./frontend/build:/ui/

and restart the api:

$ docker-compose stop api
$ docker-compose up -d api

verify the api proxy is working:

$ curl -u "admin:$PASS" http://localhost/plugins/oui/001122

NOTE: For convenience you can share a plugins state directory and mount it docker-compose.yaml under api:

      - ./state/plugins/:/state/plugins/

Standalone

start the server:

$ node index

testing the api:

$ curl --unix-socket ./http.sock http:///localhost/001122
{"provider":"CIMSYS Inc","country":"Korea, Republic Of"}

Notes

oui.json is from https://github.com/silverwind/oui/blob/master/oui.json

About


Languages

Language:JavaScript 88.3%Language:Dockerfile 11.7%