Ejemplo n.º 1
0
    def get(self, *args, **Kwargs):
        thisday = datetime.datetime.now()
        dname = self.get_argument('dname', default=None, strip=True)
        if not dname:
            return self.write(dict(code=-1, msg="参数错误"))
        sslcert = SslCertificate()
        with DBContext('r') as se:
            domain_info = se.query(DNSDomainList).filter(
                DNSDomainList.domain_name == dname).first()
            if not domain_info:
                return self.write(dict(code=-2, msg="域名错误"))

            domain_dict = model_to_dict(domain_info)
            print(domain_dict)
            sslcertexpirettime = sslcert.sslCertificateExpiredTime(
                domain_dict.get("domain_name"))
            if sslcertexpirettime:
                sslcertdatetime = datetime.datetime.strptime(
                    sslcertexpirettime, r'%b %d %H:%M:%S %Y %Z')
                domain_dict['ssl_cert_expired_days'] = (sslcertdatetime -
                                                        thisday).days
                domain_dict["ssl_cert_expired_time"] = str(sslcertdatetime)
            else:
                domain_dict['ssl_cert_expired_days'] = 0
                domain_dict[
                    "ssl_cert_expired_time"] = "Not SSL Certificate info"
            domain_dict['create_time'] = str(domain_dict.get('create_time'))
            domain_dict['expired_time'] = str(domain_dict.get('expired_time'))
        self.write(dict(code=0, msg='获取域名详情成功', data=domain_dict))
Ejemplo n.º 2
0
    def get(self, *args, **kwargs):
        key = self.get_argument('key', default=None, strip=True)
        value = self.get_argument('value', default=None, strip=True)
        page_size = self.get_argument('page', default=1, strip=True)
        limit = self.get_argument('limit', default=888, strip=True)
        limit_start = (int(page_size) - 1) * int(limit)

        plist = []
        if key and value:
            with DBContext('r') as se:
                count = se.query(DNSDomainList).filter(
                    getattr(DNSDomainList,
                            key).ilike("%{}%".format(value))).count()
                pinfo = se.query(DNSDomainList).filter(
                    getattr(DNSDomainList, key).ilike(
                        "%{}%".format(value))).offset(limit_start).limit(
                            int(limit))

        else:
            with DBContext('r') as se:
                count = se.query(DNSDomainList).count()
                pinfo = se.query(DNSDomainList).offset(limit_start).limit(
                    int(limit))

        for p in pinfo:
            data_dict = model_to_dict(p)
            data_dict["create_time"] = str(data_dict["create_time"])
            data_dict["expired_time"] = str(data_dict["expired_time"])
            plist.append(data_dict)
        return self.write(dict(code=0, msg="获取域名成功", count=count, data=plist))
Ejemplo n.º 3
0
    def get(self, *args, **kwargs):
        new_dict = {}
        with DBContext('r') as session:
            conf_info = session.query(DNSDomainConf).all()

        for msg in conf_info:
            data_dict = model_to_dict(msg)
            new_dict[data_dict.get('conf_name')] = data_dict.get('conf_value')

        self.write(dict(code=0, msg='获取成功', data=new_dict))
Ejemplo n.º 4
0
def getproviderlist():
    """
        Get id, key, secret
    """
    provider_list = []
    with DBContext('r') as se:
        provider_info = se.query(DNSDomainProvider).filter(
            DNSDomainProvider.pro_platform == 'godaddy',
            DNSDomainProvider.pro_status == 1).all()
        for provider in provider_info:
            data_dict = model_to_dict(provider)
            provider_list.append(data_dict)
    return provider_list
Ejemplo n.º 5
0
    def get(self, *args, **kwargs):
        domain = self.get_argument('domain', default=None, strip=True)
        log_list = []
        if not domain:
            return self.write(dict(code=-1, msg='域名参数不能为空'))
        with DBContext('r') as session:
            domain_log = session.query(DNSDomainLog).filter(
                DNSDomainLog.domain_name == domain).order_by(
                    -DNSDomainLog.id).all()

        for msg in domain_log:
            data_dict = model_to_dict(msg)
            data_dict['update_time'] = str(data_dict['update_time'])
            log_list.append(data_dict)
        self.write(dict(code=0, msg='获取成功', data=log_list))
Ejemplo n.º 6
0
    def get(self, *args, **kwargs):
        domain = self.get_argument('domain', default=None, strip=True)
        zone_list = []
        if not domain:
            return self.write(dict(code=-1, msg='请选择一个域名'))

        with DBContext('r') as session:
            zone_info = session.query(DNSDomainZone).filter(
                DNSDomainZone.zone == domain).order_by(
                    DNSDomainZone.region, DNSDomainZone.zone_id).all()
        for msg in zone_info:
            data_dict = model_to_dict(msg)
            data_dict.pop('update_time')
            zone_list.append(data_dict)
        self.write(dict(code=0, msg='获取成功', data=zone_list))
Ejemplo n.º 7
0
 def get(self, *args, **kwargs):
     _tree = [{"expand": True, "title": "root", "children": []}]
     with DBContext('r') as se:
         private_info = se.query(DNSDomainProvider).order_by(
             DNSDomainProvider.id).all()
         for p in private_info:
             private_dict = {}
             data_dict = model_to_dict(p)
             domain_providers = se.query(DNSDomainProvider.id).outerjoin(
                 DNSDomainList, DNSDomainList.domain_provider ==
                 DNSDomainProvider.id).filter(
                     DNSDomainList.domain_provider == p.id).all()
             private_dict["id"] = data_dict["id"]
             private_dict["the_len"] = len(domain_providers)
             private_dict["title"] = "{} ({})".format(
                 data_dict["pro_name"], len(domain_providers))
             private_dict["pro_name"] = data_dict["pro_name"]
             private_dict["node"] = "root"
             _tree[0]['children'].append(private_dict)
     self.write(dict(code=0, msg="获取供应商列表成功", data=_tree))
Ejemplo n.º 8
0
    def get(self, *args, **kwargs):
        zone = self.get_argument('zone', default=None, strip=True)
        key = self.get_argument('key', default=None, strip=True)
        page_size = self.get_argument('page', default=1, strip=True)
        limit = self.get_argument('limit', default=888, strip=True)
        limit_start = (int(page_size) - 1) * int(limit)
        zone_list = []
        if not zone:
            return self.write(dict(code=-1, msg='请选择一个域名'))

        with DBContext('r') as session:
            if key:
                count = session.query(DNSDomainZone).filter(
                    DNSDomainZone.zone == zone).filter(
                        or_(DNSDomainZone.host.like('%{}%'.format(key)),
                            DNSDomainZone.type.like('%{}%'.format(key)),
                            DNSDomainZone.data.like('%{}%'.format(key)),
                            DNSDomainZone.region.like(
                                '%{}%'.format(key)))).count()
                zone_info = session.query(DNSDomainZone).filter(
                    DNSDomainZone.zone == zone).filter(
                        or_(DNSDomainZone.host.like('%{}%'.format(key)),
                            DNSDomainZone.type.like('%{}%'.format(key)),
                            DNSDomainZone.data.like('%{}%'.format(key)),
                            DNSDomainZone.region.like(
                                '%{}%'.format(key)))).order_by(
                                    DNSDomainZone.zone_id).offset(
                                        limit_start).limit(int(limit))
            else:
                count = session.query(DNSDomainZone).filter(
                    DNSDomainZone.zone == zone).count()
                zone_info = session.query(DNSDomainZone).filter(
                    DNSDomainZone.zone == zone).order_by(
                        DNSDomainZone.zone_id).offset(limit_start).limit(
                            int(limit))
        for msg in zone_info:
            data_dict = model_to_dict(msg)
            data_dict['update_time'] = str(data_dict['update_time'])
            zone_list.append(data_dict)
        self.write(dict(code=0, msg='获取成功', count=count, data=zone_list))
Ejemplo n.º 9
0
    def get(self, *args, **kwargs):
        key = self.get_argument('key', default=None, strip=True)
        domain_list = []
        domain_name_list = []
        with DBContext('r') as session:
            if key:
                domain_info = session.query(DNSDomainName).filter(
                    DNSDomainName.domain_name.like('%{}%'.format(key))).all()
            else:
                domain_info = session.query(DNSDomainName).all()

        for msg in domain_info:
            data_dict = model_to_dict(msg)
            data_dict['create_time'] = str(data_dict['create_time'])
            domain_list.append(data_dict)
            domain_name_list.append(data_dict['domain_name'])

        self.write(
            dict(code=0,
                 msg='获取成功',
                 data=domain_list,
                 domain_name_list=domain_name_list))
Ejemplo n.º 10
0
    #TgChatId = "837951069" #To only North
    TgChatId = "-403702424" #测试级
    TgBot = telegram.Bot(TgApiToken)
    
    #Update all domain list
    godaddy_domain_update()
    namecomd_domain_update()

    #Get domainlist
    with DBContext('r') as se:
        domain_info = se.query(DNSDomainList).all()
        if not domain_info:
            ins_log.read_log("error", "Not domain list or get domain list faield. {}".format(domain_info))
            os.exit(-1)
        for domain in domain_info:
            data_dict = model_to_dict(domain)
            dName = data_dict.get('domain_name')
            DExpiredTime = data_dict.get('expired_time')
            DExpiredDays = (DExpiredTime - todaytime).days
            if DExpiredDays < 15:
                expired_domains.append({'domain_name': dName, 'expired_time': str(DExpiredTime)})
            certificate_time = sslCertificateExpiredTime(dName)
            if certificate_time:
                hasssldomains += 1
                certtime = datetime.datetime.strptime(certificate_time, r'%b %d %H:%M:%S %Y %Z')
                certdays = (certtime - todaytime).days
                if certdays < 30:
                    expired_certificate.append({'domain_name': dName, 'certificate_expired_time': str(certtime)})
                #print("info", "ID:{}   Nname:{}  ExpiredDays: {}    CertificateExpiredTime:{}   CertificateDays:{}".format(data_dict.get('id'), dName, DExpiredDays, certtime, certdays))
            else:
                Nossldomains += 1