Sha256: 07f36992a9095eb2d42689d6af5f7b64769b693afc27e564366408bc1d7281c2
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
#!/usr/bin/env ruby # lifx-snoop is a utility that snoops on LIFX UDP traffic on both the broadcast port # and the peer broadcast port. # # Usage: # lifx-snoop [regexp, ...] # # By default, it will show all messages. Any arguments passed in will become # regular expressions, which will then match on the string representation of the # message. # # Example: # lifx-snoop Light::Get # Shows only Light::Get messages # lifx-snoop Light::State site=d073d5000000 # Shows only Light::State messages matching site d073d5000000 $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib") require 'lifx' require 'time' matchers = ARGV.map do |arg| Regexp.new(arg, Regexp::IGNORECASE) end if matchers.empty? matchers << // end begin light_udp = LIFX::Transport::UDP.new('0.0.0.0', 56700) light_udp.add_observer(self, :message_received) do |message: nil, ip: nil, transport: nil| if matchers.all? { |m| message.to_s =~ m } puts "#{Time.now.iso8601(5)} BROADCAST: #{ip} #{message}" end end light_udp.listen peer_udp = LIFX::Transport::UDP.new('0.0.0.0', 56750) peer_udp.add_observer(self, :message_received) do |message: nil, ip: nil, transport: nil| if matchers.all? { |m| message.to_s =~ m } puts "#{Time.now.iso8601(5)} PEER: #{ip} #{message}" end end peer_udp.listen rescue LIFX::Message::UnsupportedProtocolVersion end puts "Listening on 56700 and 56750..." puts "^C to quit." sleep
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lifx-0.4.11 | bin/lifx-snoop |
lifx-0.4.10 | bin/lifx-snoop |
lifx-0.4.8 | bin/lifx-snoop |