Esempio n. 1
0
 def send_mail(self, subject, message=None):
     record_message = os.linesep.join(["%s: %s" % (key, value)
         for key, value in { \
             "id": self.record.pk,
             "region": self.record.region_name,
             "subdomain": self.record.full_subdomain,
             "rtype": QTYPE.get(self.record.rtype),
             "rclass": CLASS.get(self.record.rclass),
             "rdata": self.record.content
         }.items()
     ])
     message = os.linesep.join([record_message, message or ""])
     md5 = hashlib.md5()
     md5.update((subject + message).encode('utf8'))
     mail_id = md5.hexdigest()
     mail_interval = cache.get_or_set("mail_interval:%s" % mail_id,
                                      time.time(), settings.EMAIL_INTERVAL)
     if (time.time() - mail_interval) < settings.EMAIL_INTERVAL: return
     recipient_list = [user.email for user in \
             self.record.domain.operators.all() if user.email]
     send_mail("%s%s" % (settings.EMAIL_SUBJECT_PREFIX, subject),
               message,
               from_email=None,
               recipient_list=recipient_list,
               fail_silently=True)
Esempio n. 2
0
 def query(self, request, origin=None):
     tracking_chain = []  # Prevent infinite recursion
     region = self._get_or_set_cached_region(origin)
     records, checker_records = [], []
     for index, record in enumerate(
             self._query(request.questions, region, tracking_chain)):
         if index > settings.DNSKEY_MAXIMUM_QUERY_DEPTH:
             break
         if record.subdomain:
             checker_records.append(record)
         if record.status == 1:
             rr = RR.fromZone("{rr} {ttl} {rclass} {rtype} {rdata}".format(
                 rr=record.full_subdomain,
                 ttl=record.ttl,
                 rclass=CLASS.get(record.rclass),
                 rtype=QTYPE.get(record.rtype),
                 rdata=record.content))
             records.append(record)
             request.add_answer(*rr)
     if len(checker_records) > 0:
         query_records.send(sender=LocalQueryProxy, records=checker_records)
     return request
Esempio n. 3
0
 def __unicode__(self):
     return "%s %s %s" % (self.qname, QTYPE.get(self.qtype), CLASS.get(self.qclass))