Giter Club home page Giter Club logo

netdetector's Introduction

NetDetector

NetDetector is a daemon which checks for and responds to a given MAC or IP address on the network.

Help text

> NetDetector  -h
Usage: NetDetector [-h] [-v] [-c 'ITEM, ...'] [-d 'ITEM, ...'] [-r RATE]
                   [-C CONNECT-COUNT] [-D DISCONNECT-COUNT]
                   [-i INTERFACE] ADDR
Positional arguments:
  ADDR
        The IP or MAC address to detect.
Optional arguments:
  -h, --help
        Displays this help message and exits.
  -v, --version
        Displays the version.
  -c 'ITEM, ...', --connect 'ITEM, ...'
        The command (with args separated by commas) to run when the address is
          detected on the network.
  -d 'ITEM, ...', --disconnect 'ITEM, ...'
        The command (with args separated by commas) to run when the address is no
          longer detected on the network.
  -r RATE, --rate RATE
        The poll rate in seconds.
        Default: 60
  -C CONNECT-COUNT, --connect-count CONNECT-COUNT
        The number of consecutive connection detections that must elapse before the
          connect command is run.
        Default: 1
  -D DISCONNECT-COUNT, --disconnect-count DISCONNECT-COUNT
        The number of consecutive disconnection detections that must elapse before
          the disconnect command is run.
        Default: 1
  -i INTERFACE, --interface INTERFACE
        The network interface to use as the scope identifier.
        Default: 1

Detection

test.sh

#!/bin/bash

cmd="$1"

if [ "$cmd" = "connect" ]
then
        echo "$NET_DETECTOR_ADDRESS detected"
elif [ "$cmd" = "disconnect" ]
then
        echo "$NET_DETECTOR_ADDRESS not detected"
fi

NetDetector

> NetDetector fe80::9c11:e50:ad4f:f749 -i eth2 -r 1 -c "./test.sh,connect" -d "./test.sh,disconnect"
(fe80::9c11:e50:ad4f:f749%3) - Watching
(fe80::9c11:e50:ad4f:f749%3) - Not detected
(fe80::9c11:e50:ad4f:f749%3) - Running: ./test.sh disconnect
fe80::9c11:e50:ad4f:f749%3 not detected
(fe80::9c11:e50:ad4f:f749%3) - Detected
(fe80::9c11:e50:ad4f:f749%3) - Running: ./test.sh connect
fe80::9c11:e50:ad4f:f749%3 detected

netdetector's People

Watchers

 avatar  avatar

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.