In Files

  • resolv.rb

Resolv::DNS::Message::MessageEncoder

Public Class Methods

new() click to toggle source
 
               # File resolv.rb, line 1202
def initialize
  @data = ''
  @names = {}
  yield self
end
            

Public Instance Methods

put_bytes(d) click to toggle source
 
               # File resolv.rb, line 1212
def put_bytes(d)
  @data << d
end
            
put_label(d) click to toggle source
 
               # File resolv.rb, line 1258
def put_label(d)
  self.put_string(d.string)
end
            
put_labels(d) click to toggle source
 
               # File resolv.rb, line 1244
def put_labels(d)
  d.each_index {|i|
    domain = d[i..-1]
    if idx = @names[domain]
      self.put_pack("n", 0xc000 | idx)
      return
    else
      @names[domain] = @data.length
      self.put_label(d[i])
    end
  }
  @data << "\00""
end
            
put_length16() click to toggle source
 
               # File resolv.rb, line 1220
def put_length16
  length_index = @data.length
  @data << "\00\\00""
  data_start = @data.length
  yield
  data_end = @data.length
  @data[length_index, 2] = [data_end - data_start].pack("n")
end
            
put_name(d) click to toggle source
 
               # File resolv.rb, line 1240
def put_name(d)
  put_labels(d.to_a)
end
            
put_pack(template, *d) click to toggle source
 
               # File resolv.rb, line 1216
def put_pack(template, *d)
  @data << d.pack(template)
end
            
put_string(d) click to toggle source
 
               # File resolv.rb, line 1229
def put_string(d)
  self.put_pack("C", d.length)
  @data << d
end
            
put_string_list(ds) click to toggle source
 
               # File resolv.rb, line 1234
def put_string_list(ds)
  ds.each {|d|
    self.put_string(d)
  }
end
            
to_s() click to toggle source
 
               # File resolv.rb, line 1208
def to_s
  return @data
end