from PfsenseFauxapi.PfsenseFauxapi import PfsenseFauxapi
from alibabacloud_tea_openapi import models as open_api_models from alibabacloud_alidns20150109.client import Client as Client from alibabacloud_alidns20150109 import models as models from alibabacloud_tea_util.client import Client as UtilClient
describe_domain_records_request = models.DescribeDomainRecordsRequest(domain_name=domain_name, rrkey_word=rr,type=type) resp = client.describe_domain_records(describe_domain_records_request) record = resp.body.domain_records.record[0] # 记录ID record_id = record.record_id # 记录值 records_value = record.value logging.info('Previous record value is: %s.' % records_value) ifnot UtilClient.equal_string(current_ip_addr, records_value): update_domain_records_request = models.UpdateDomainRecordRequest(record_id=record_id, rr=rr, type=type, value=current_ip_addr) client.update_domain_record(update_domain_records_request) logging.info('Updated record value : %s.' % current_ip_addr)
if __name__ == '__main__': if get_interfacestatus()[0] == 'up': current_ip_addr = get_interfacestatus()[1] if current_ip_addr: update_record() else: logging.warning('Can not get the ipv6 address!') else: logging.warning('Can not get the ipv6 address. Please check the wan interface!')