Class: RushButton::Server
- Inherits:
-
Object
- Object
- RushButton::Server
- Includes:
- PacketFu
- Defined in:
- lib/rush_button/server.rb
Instance Method Summary collapse
- #add(mac_addr, &block) ⇒ Object
-
#initialize(iface) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(iface) ⇒ Server
Returns a new instance of Server.
6 7 8 9 |
# File 'lib/rush_button/server.rb', line 6 def initialize iface @iface = iface @buttons = [] end |
Instance Method Details
#add(mac_addr, &block) ⇒ Object
11 12 13 |
# File 'lib/rush_button/server.rb', line 11 def add mac_addr, &block @buttons << DashButton.new(mac_addr).on_press(&block) end |
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rush_button/server.rb', line 15 def start puts "Dash Button capturing..." if $DEBUG cap = Capture.new(iface:@iface, filter:Protocol::ARP, promisc:true) cap.stream.each do |pkt| if ARPPacket.can_parse?(pkt) src_mac = ARPPacket.parse(pkt).eth_src_readable @buttons.find {|e| e.mac == src_mac}&.press end end end |