Exemple #1
0
 def makePutContext(self, name, zone):
     ret = super(Driver, self).makePutContext(name, zone)
     ret.zoneid = self._switchToZone(name)
     for record in ret.newrecords:
         if record.rclass != 'IN':
             raise api.UnsupportedRecordType(
                 _(
                     'DomainMonster does not support non-"IN" record classes: {!r}',
                     (record, )))
         if record.ttl != 14400:
             raise api.UnsupportedRecordType(
                 _('DomainMonster does not support non-4 hour TTLs: {!r}',
                   (record, )))
     # update the faked serial-tracking record...
     # TODO: it should only do this if there were actual changes...
     srec = None
     for record in ret.records:
         if record.type == 'TXT' and record.name == '_dnssync.' + ret.name:
             srec = record
             break
     for record in ret.newrecords:
         if record.type == 'TXT' and record.name == '_dnssync.' + ret.name:
             if srec is not None and record.content == srec.content:
                 record.content = self._bumpSerial(record)
             break
     else:
         ret.newrecords.append(
             api.Record(name='_dnssync.' + ret.name,
                        ttl=14400,
                        rclass='IN',
                        type='TXT',
                        content=self._bumpSerial(srec)))
     return ret
Exemple #2
0
def reg2api(record, name):
    record = aadict(record)
    # reg: {'rid':'55026','zid':'4442','domainid':'12345','type':'A',
    #       'name':'fh3.example.ly','ttl':'14400','content':'10.11.12.237',}
    ret = api.Record(name=absdom(record.name),
                     rclass='IN',
                     ttl=int(record.ttl),
                     **morph.pick(record, 'rid', 'zid', 'domainid', 'type',
                                  'content'))
    if ret.type not in api.Record.TYPES:
        raise api.DriverError(
            _('unknown/unexpected Registerly record type: "{}"', ret.type))
    if ret.type in (api.Record.TYPE_MX, api.Record.TYPE_CNAME,
                    api.Record.TYPE_NS):
        ret.update(content=absdom(ret.content))
    if ret.type == api.Record.TYPE_SOA:
        # there's stuff missing!... content form should be:
        #   {root} {contact} {serial} {refresh} {retry} {expire} {minttl}
        # but is comming back as:
        #   ns1.libyanspider.com support.libyanspider.com 0
        # so fetching from DNS... ugh.
        return ret.update(content=regGetSoaContent(name))
    if ret.type == api.Record.TYPE_MX:
        return ret.update(priority=int(record.prio))
    if ret.type == api.Record.TYPE_CNAME:
        return ret.update(content=absdom(ret.content))
    # TODO: verify api.Record.TYPE_SRV...
    # TODO: verify api.Record.TYPE_NAPTR...
    # todo: Registerly also supports "PTR" and "URL" records... hm...
    return ret
Exemple #3
0
    def getRecords(self, name):
        zid = self._switchToZone(name)
        resp = self.session.get(self.BASEURL + '/members/managedns/')
        records = parser.extractDnsRecords(resp.text)
        serial = self._makeSerial()

        for record in records:
            # todo: unfortunately, the TTL and RDCLASS fields need to be faked...
            record.ttl = 14400
            record.rclass = 'IN'
            # making use of the work-around record...
            if record.type == 'TXT' and record.name == '_dnssync.' + name:
                serial = dict(urlparse.parse_qsl(record.content)).get(
                    's', serial)

        # todo: unfortunately, the SOA and NS records need to be faked...
        records = [
            api.Record(name=name,
                       ttl=14400,
                       rclass='IN',
                       type='SOA',
                       content='ns1.domainmonster.com. hostmaster.' + name +
                       ' ' + serial + ' 7200 1800 1209600 7200'),
            api.Record(name=name,
                       ttl=14400,
                       rclass='IN',
                       type='NS',
                       content='ns1.domainmonster.com.'),
            api.Record(name=name,
                       ttl=14400,
                       rclass='IN',
                       type='NS',
                       content='ns2.domainmonster.com.'),
            api.Record(name=name,
                       ttl=14400,
                       rclass='IN',
                       type='NS',
                       content='ns3.domainmonster.com.'),
        ] + records

        return records
Exemple #4
0
def ze2api(record, name):
  if not record.host or record.host == '@':
    record.host = absdom(name)
  else:
    record.host = absdom(record.host + '.' + name)
  ret = api.Record(
    name=record.host, rclass='IN', type=record.rtype, ttl=dur2sec(record.ttl))
  if record.zone_id:
    ret.zoneedit_id = record.zone_id
  if record.rtype == api.Record.TYPE_SOA:
    return ret.update(
      ttl     = 3600,
      content = 'dns0.zoneedit.com. zone.zoneedit.com. {serial} {refresh} {retry} {expire} {minttl}'.format(
        serial  = zeGetSerial(name) or int(time.time()),
        refresh = dur2sec(record.refresh),
        retry   = dur2sec(record.retry),
        expire  = dur2sec(record.expire),
        minttl  = dur2sec(record.ttl),
      ))
  if record.rtype == api.Record.TYPE_NS:
    if record.server == 'LOCAL':
      record.server = 'local.zoneedit.'
    return ret.update(content=record.server)
  if record.rtype == api.Record.TYPE_MX:
    if record.server == 'LOCAL':
      record.server = 'local.zoneedit.'
    return ret.update(priority=dur2sec(record.pref), content=absdom(record.server))
  if record.rtype == api.Record.TYPE_A:
    if record.ip == 'PARK':
      record.ip = '0.0.0.0'
    return ret.update(content=record.ip)
  if record.rtype == api.Record.TYPE_AAAA:
    if record.ip == 'PARK':
      record.ip = '::0'
    return ret.update(content=record.ip)
  if record.rtype == api.Record.TYPE_CNAME:
    return ret.update(content=absdom(record.alias))
  if record.rtype == api.Record.TYPE_TXT:
    return ret.update(content=record.txt)
  raise ValueError(
    _('unknown/unexpected/unimplemented ZoneEdit record type "{}"', record.rtype))
Exemple #5
0
def extractDnsRecords(html):
  records  = []
  origin   = absdom(origin_cre.search(html).group(1))
  sections = section_cre.split(html)[1:]
  sections = [(sections[idx*2], sections[idx*2+1]) for idx in range(len(sections) / 2)]
  if len(sections) != 7:
    raise HtmlScrapingError(
      'unexpected number of record type sections (%r instead of 7)' % (len(sections),))
  for rdtype, section in sections:
    cre = record_cre.get(rdtype) or record_cre.get('*')
    for match in cre.finditer(section):
      rec = api.Record(
        id      = match.group('id'),
        name    = match.group('name') + '.' + origin if match.group('name') else origin,
        type    = rdtype,
        content = match.group('content'),
      )
      if len(match.groups()) > 3:
        rec.priority = int(match.group('priority'))
      if len(match.groups()) > 5:
        rec.weight   = int(match.group('weight'))
        rec.port     = int(match.group('port'))
      records.append(rec)
  return records