diff --git a/dash.conf_example b/dash.conf_example index 5d33c7f..e236f4a 100644 --- a/dash.conf_example +++ b/dash.conf_example @@ -1,3 +1,5 @@ -DASH_MAC_ADDRESS= -DASH_URL_CALLBACK= DASH_INTERFACE= + +DASH_MQTT_SERVER=127.0.0.1 +DASH_MQTT_PORT=1883 +DASH_MQTT_TOPIC="dashlisten" diff --git a/docker-compose.yml b/docker-compose.yml index 8dd56bb..6aeea2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,9 +6,10 @@ mem_limit: 128m restart: always environment: - - DASH_MAC_ADDRESS=${DASH_MAC_ADDRESS} - DASH_INTERFACE=${DASH_INTERFACE} - - DASH_URL_CALLBACK=${DASH_URL_CALLBACK} + - DASH_MQTT_SERVER=${DASH_MQTT_SERVER:-127.0.0.1} + - DASH_MQTT_PORT=${DASH_MQTT_PORT:-1883} + - DASH_MQTT_TOPIC=${DASH_MQTT_TOPIC:-dashbutton} tmpfs: - /tmp network_mode: host diff --git a/docker/Dockerfile b/docker/Dockerfile index a6ad1c7..4630d0b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,8 +9,7 @@ ENV DASH_HOME /srv/dash RUN apk update -RUN apk add scapy tcpdump -#RUN apt-get update -qq && apt-get install -qq -y python-scapy tcpdump tcpreplay wireshark python-requests +RUN apk add scapy tcpdump py2-paho-mqtt RUN rm -rf /var/cache/apk/* # working directory diff --git a/docker/dash-listen.py b/docker/dash-listen.py index d35d85d..a621bf1 100644 --- a/docker/dash-listen.py +++ b/docker/dash-listen.py @@ -4,23 +4,27 @@ # should be allowed to perform packed capture. from scapy.all import * +import paho.mqtt.client as mqtt import os -#import requests -DASH_MAC_ADDRESS=os.environ.get('DASH_MAC_ADDRESS') + DASH_INTERFACE=os.environ.get('DASH_INTERFACE') -#URL_CALLBACK=os.environ.get('URL_CALLBACK') + +DASH_MQTT_SERVER = os.environ.get('DASH_MQTT_SERVER') +DASH_MQTT_PORT = os.environ.get('DASH_MQTT_PORT') +DASH_MQTT_TOPIC = os.environ.get('DASH_MQTT_TOPIC') + + def arp_display(pkt): if (pkt.haslayer(DHCP)): print "DHCP from " + pkt[Ether].src - if (pkt[Ether].src == DASH_MAC_ADDRESS): - #requests.get(URL_CALLBACK) - print "DHCP from " + pkt[Ether].src - # end if + client.publish(DASH_MQTT_TOPIC + "/mac", str(pkt[Ether])) # end if # end apr_display +client = mqtt.Client() +client.connect(DASH_MQTT_SERVER, DASH_MQTT_PORT, keepalive=60, bind_address="") try: print sniff(prn=arp_display, iface=DASH_INTERFACE, filter="ip", store=0, count=0)