Class: Dap::Filter::FilterDecodeUPNP_SSDP_Reply

Inherits:
Object
  • Object
show all
Includes:
BaseDecoder
Defined in:
lib/dap/filter/udp.rb

Overview

Decode a SSDP probe response ( zmap: upnp_1900.pkt )

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from BaseDecoder

#process

Methods included from Base

#initialize, #process

Instance Method Details

#decode(data) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/dap/filter/udp.rb', line 84

def decode(data)
  head = { }
  lines = data.split(/\r?\n/)
  return if lines.empty?
  if /^HTTP\/\d+\.\d+\s+(?<http_code>\d+)(?:\s+(?<http_message>.*))?/ =~ lines.first
    head["upnp_http_code"] = http_code
    head["upnp_http_message"] = http_message
  else
    return
  end

  lines.shift
  lines.each do |line|
    k,v = line.strip.split(':', 2)
    next if not k
    head["upnp_#{k.downcase}"] = (v.to_s.strip)
  end
  head
end