def sync_dns_from_my_ip(self, dns_type='<STR_LIT:A>'):
ip_address = '<STR_LIT>'<EOL>for finder in self.public_ip_finder:<EOL><INDENT>try:<EOL><INDENT>result = requests.get(finder)<EOL><DEDENT>except requests.RequestException:<EOL><INDENT>continue<EOL><DEDENT>if result.status_code == <NUM_LIT:200>:<EOL><INDENT>try:<EOL><INDENT>socket.inet_aton(result.text)<EOL>ip_address = result.text<EOL>break<EOL><DEDENT>except socket.error:<EOL><INDENT>try:<EOL><INDENT>socket.inet_aton(result.json().get('<STR_LIT>'))<EOL>ip_address = result.json()['<STR_LIT>']<EOL>break<EOL><DEDENT>except socket.error:<EOL><INDENT>continue<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if ip_address == '<STR_LIT>':<EOL><INDENT>print('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>try:<EOL><INDENT>record = self.get_record(dns_type, self.domain)if len(self.domain.split('<STR_LIT:.>')) == <NUM_LIT:3>else self.get_record(dns_type, self.domain)<EOL><DEDENT>except RecordNotFound:<EOL><INDENT>if self.proxied:<EOL><INDENT>self.create_record(dns_type, self.domain, ip_address, proxied=True)<EOL><DEDENT>else:<EOL><INDENT>self.create_record(dns_type, self.domain, ip_address)<EOL><DEDENT>print('<STR_LIT>'<EOL>.format(new_ip=ip_address))<EOL><DEDENT>else:<EOL><INDENT>if record['<STR_LIT:content>'] != ip_address:<EOL><INDENT>if self.proxied:<EOL><INDENT>self.update_record(dns_type, self.domain, ip_address, proxied=True)<EOL><DEDENT>else:<EOL><INDENT>self.update_record(dns_type, self.domain, ip_address)<EOL><DEDENT>print('<STR_LIT>'<EOL>.format(old_ip=record['<STR_LIT:content>'], new_ip=ip_address))<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT>
Sync dns from my public ip address.
It will not do update if ip address in dns record is already same as
current public ip address.
:param dns_type:
:return: