Class: Dap::Filter::FilterSplitNonDynamicDomains

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/dap/filter/names.rb

Overview

Acts like SplitDomains but strips out common dynamic IP RDNS formats

XXX - Lots of work left to do

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#expand(data) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/dap/filter/names.rb', line 112

def expand(data)
  names = []
  data  = data.unpack("C*").pack("C*").
    gsub(/.*ip\d+\.ip\d+\.ip\d+\.ip\d+\./, '').
    gsub(/.*\d+[\_\-\.x]\d+[\_\-\.x]\d+[\_\-\.x]\d+[^\.]+/, '').
    gsub(/.*node-[a-z0-9]+.*pool.*dynamic\./, '').
    gsub(/.*[a-z][a-z]\d+\.[a-z]as[a-z0-9]+\./, '').
    # cl223.001033200.technowave.ne.jp
    gsub(/^cl\d+.[0-9]{6,14}\./, '').
    # n157.s1117.m-zone.jp
    gsub(/^n\d+.s\d+\.m-zone.jp/, 'm-zone.jp').
    # u570054.xgsnu2.imtp.tachikawa.mopera.net
    # s505207.xgsspn.imtp.tachikawa.spmode.ne.jp
    gsub(/^[us]\d+.xgs[a-z0-9]+\.imtp/, 'imtp').
    # tzbm6501209.tobizaru.jp
    gsub(/^tzbm[0-9]{6,9}\./, '').
    # ARennes-556-1-256-bdcst.w2-14.abo.wanadoo.fr
    gsub(/.*\-\d+\-\d+\-\d+\-(net|bdcst)\./, '').
    # bl19-128-119.dsl.telepac.pt
    gsub(/.*\d+\-\d+\-\d+\.dsl/, 'dsl').
    gsub(/.*pool\./, '').
    gsub(/.*dynamic\./, '').
    gsub(/.*static\./, '').
    gsub(/.*dhcp[^\.]+\./, '').
    gsub(/^\d{6,100}\./, '').
    gsub(/^\.+/, '').
    tr('^a-z0-9.-', '')

  bits  = data.split('.')
  while (bits.length > 1)
    names << bits.join('.')
    bits.shift
  end
  names
end

#process(doc) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/dap/filter/names.rb', line 100

def process(doc)
  lines = [ ]
  self.opts.each_pair do |k,v|
    if doc.has_key?(k)
      expand(doc[k]).each do |line|
        lines << doc.merge({ "#{k}.domain" => line })
      end
    end
  end
 lines.length == 0 ? [ doc ] : [ lines ]
end