diff --git a/update.py b/update.py index 882c05c..960daf3 100644 --- a/update.py +++ b/update.py @@ -30,6 +30,7 @@ def get_public_ip(): return None return res.text.strip() + def get_namesilo_dns(key, domain, target_host): res = get(LIST_URL.format(base=BASE_URL, key=key, domain=domain)) if res.status_code != 200: @@ -39,7 +40,7 @@ def get_namesilo_dns(key, domain, target_host): host = i.find('./host').text if host == target_host: return { - 'rrid': i.find('./host').text, + 'rrid': i.find('./record_id').text, 'value': i.find('./value').text, 'host': host, } @@ -79,7 +80,8 @@ def main(): print('NAMESILO API service is down or target not found') sys.exit() - if namesilo_data['value'] == public_ip: + curr_ip = namesilo_data['value'] + if curr_ip == public_ip: print('Current value is okay. No need to do anything') sys.exit() @@ -88,7 +90,9 @@ def main(): if not result: print('Updating process failed.') sys.exit() - print('Updated to a new IP: {}'.format(public_ip)) + + print('Updated to a new IP: {} from {}'.format(public_ip, curr_ip)) + if __name__ == '__main__': main()