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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71e8096ab107491a5769ef20a0e57919caca9ee8
4
- data.tar.gz: beda3fc02671cae6908888d9bd81ce7bd455c35a
3
+ metadata.gz: 9c90fc97d3bb2f4215218815b7697a8315026a03
4
+ data.tar.gz: 71bdddb56b295d00a7757be236caed3cc95a93d3
5
5
  SHA512:
6
- metadata.gz: 447623c5a5ee31fabf5a4ec727a721173617b3e31e5dd8675400258feeb390cf391c4d824f5ebb99bb36e0b49fdb12da6cca47fbe00c33c4cda553fdf4bb32ca
7
- data.tar.gz: 412c16946e1810679813ab21a50ee4286a82c480020cf1883dd077333b272870975b16bb14fcdca8783d2d1581961ec977e8d4be95232a90e4b8418c1c8198a0
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
- [ARP](https://en.wikipedia.org/wiki/Address_Resolution_Protocol) packets and
157
- DHCP packets (sent from 0.0.0.0). Older buttons use the ARP method, while newer
158
- buttons issue DHCP packets.
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
@@ -5,13 +5,10 @@ module LifxDash
5
5
 
6
6
  # Berkeley Packet filter for Amazon Dash buttons
7
7
  #
8
- # - older dash buttons issue an ARP packet from 0.0.0.0
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 = "(arp or (udp and src port 68 and dst port 67)) and src host 0.0.0.0"
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
- pkt = PacketFu::IPPacket.parse(packet)
26
- # only consider the first packet sent
27
- if pkt && pkt.ip_id == 1
28
- mac = PacketFu::EthHeader.str2mac(pkt.eth_src)
29
- block.call(pkt, mac) if block
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
@@ -1,3 +1,3 @@
1
1
  module LifxDash
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
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.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-01 00:00:00.000000000 Z
11
+ date: 2017-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli