示例#1
0
        update = ' and '.join(_update)
        save_iplist_as_db(ipdb, iplist)
        logging.info('直连 IP 库已保存完毕')
    except Exception as e:
        logging.warning('更新直连 IP 库 %r 失败:%s' % (ipdb, e))
    finally:
        downloading = False
        data_source_manager.clear_source_data()

def test(ipdb):
    global update
    update = 'keep IP test'
    save_iplist_as_db(ipdb, [])
    print('IP 保留地址已保存完毕')

data_source_manager = DataSourceManager()
ds_APNIC = data_source_manager.add('APNIC', Url_APNIC, parse_apnic_iplist)
ds_17MON = data_source_manager.add('17mon', Url_17MON, parse_cidr_iplist)
ds_GAOYIFAN = data_source_manager.add('GaoYiFan', Url_GAOYIFAN, parse_cidr_iplist)
ds_APNIC.add(['mo', 'hk'])
#更新一般在月初几天,由于内容不包含日期信息,故记录为获取时的日期信息
ds_17MON.datefmt = '%Y%m%d'
#每日 3:00 之后更新
ds_GAOYIFAN.datefmt = '%Y%m%d'

is_main = __name__ == '__main__'
logging = getlogger(is_main)

if is_main:
    if len(sys.argv) < 2:
        print('使用 "--help" 可查看命令行参数说明\n')
示例#2
0
        domains_list.append(b'')
        domains_list.append(b'#end')
        save_domains_as_txt(txt, domains_list)
        logging.debug('更新信息:%s' % update)
        logging.debug('包含域名条目数:%s' % count)
        logging.debug('保存地址:%s' % txt)
        logging.info('直连域名列表已保存完毕')
    except Exception as e:
        logging.warning('更新直连域名列表 %r 失败:%s' % (txt, e))
    finally:
        downloading = False
        data_source_manager.clear_source_data()


data_source_manager = DataSourceManager()
ds_FELIX = data_source_manager.add('Felix', Url_FCHINA, parse_dnsmasq_domains,
                                   'felixonmars/accelerated-domains.china')
ds_FAPPLE = ds_FELIX.add_child('Apple',
                               Url_FAPPLE,
                               fullname='felixonmars/apple.china')

is_main = __name__ == '__main__'
logging = getlogger(is_main)

if is_main:
    if len(sys.argv) < 2:
        print('使用 "--help" 可查看命令行参数说明\n')
    if '--help' in sys.argv:
        print('''
用法: