lifx_dash 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/lifx_dash/capturer.rb +11 -10
- data/lib/lifx_dash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c90fc97d3bb2f4215218815b7697a8315026a03
|
4
|
+
data.tar.gz: 71bdddb56b295d00a7757be236caed3cc95a93d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf8e41e3db5e3bcf6a0e7f8e2449f0139f3de606a3260b066b49aa0cb44c5b0e2d3beaf41e5df839992d18f5bb535405bcd02480039e7c72ed66438cae03837
|
7
|
+
data.tar.gz: 1b0f089fcdabd020fbd60503bdff78b8651220555e056c426a55877aba86a033b68da10301a2d232f057fb4d4e39f90f7b5f2f4888f2cb41d85ed4eec216cac9
|
data/README.md
CHANGED
@@ -152,10 +152,10 @@ take a moment and check it hasn't already been raised (and possibly closed).
|
|
152
152
|
|
153
153
|
This gem uses the [PacketFu](https://rubygems.org/gems/packetfu) gem (and
|
154
154
|
[libpcap](https://sourceforge.net/projects/libpcap/) under the hood) to monitor
|
155
|
-
data packets on your network. This packet stream filters
|
156
|
-
[
|
157
|
-
DHCP
|
158
|
-
|
155
|
+
data packets on your network. This packet stream filters for
|
156
|
+
[DHCP](https://wiki.wireshark.org/DHCP) packets (sent from 0.0.0.0). Older dash
|
157
|
+
buttons sent both DHCP and [ARP](https://wiki.wireshark.org/ARP) packets but
|
158
|
+
detecting ARP reliably was problematic.
|
159
159
|
|
160
160
|
When a valid packet is detected with a known source MAC address, the LIFX HTTP
|
161
161
|
API [toggle-power](https://api.developer.lifx.com/docs/toggle-power) endpoint is
|
data/lib/lifx_dash/capturer.rb
CHANGED
@@ -5,13 +5,10 @@ module LifxDash
|
|
5
5
|
|
6
6
|
# Berkeley Packet filter for Amazon Dash buttons
|
7
7
|
#
|
8
|
-
# -
|
9
|
-
# - newer buttons broadcast a DHCP request from 0.0.0.0
|
10
|
-
# - use the following bfp in WireShark to snoop for raw packets
|
11
|
-
# - (arp or (udp.srcport == 68 and udp.dstport == 67)) and ip.src == 0.0.0.0
|
8
|
+
# - most dash buttons broadcast a DHCP request from 0.0.0.0
|
12
9
|
# - for more details see https://github.com/ide/dash-button/issues/36
|
13
10
|
#
|
14
|
-
PACKET_FILTER = "
|
11
|
+
PACKET_FILTER = "udp and src port 68 and dst port 67 and udp[247:4] == 0x63350103 and src host 0.0.0.0"
|
15
12
|
|
16
13
|
attr_reader :iface
|
17
14
|
|
@@ -22,11 +19,15 @@ module LifxDash
|
|
22
19
|
def listen(&block)
|
23
20
|
# examine packets on the stream
|
24
21
|
capturer.stream.each do |packet|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
if PacketFu::IPPacket.can_parse?(packet)
|
23
|
+
pkt = PacketFu::IPPacket.parse(packet)
|
24
|
+
# only consider the first (early ip ids) even packet sent
|
25
|
+
# since dhcp often sends 2 packets in a quick burst
|
26
|
+
if pkt && pkt.ip_id < 5 && (pkt.ip_id % 2) == 0
|
27
|
+
puts pkt.inspect
|
28
|
+
mac = PacketFu::EthHeader.str2mac(pkt.eth_src)
|
29
|
+
block.call(pkt, mac) if block
|
30
|
+
end
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
data/lib/lifx_dash/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lifx_dash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hutchinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|