Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D2d #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

D2d #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/example.config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'''
api_endpoint = 'https://dns.api.gandi.net/api/v5'

#your domain with the subdomains in the zone file/UUID
#your domain with the subdomains in the zone file/UUID
domain = 'mydomain.tld'

#enter all subdomains to be updated, subdomains must already exist to be updated
Expand All @@ -29,17 +29,23 @@
#300 seconds = 5 minutes
ttl = '300'

'''
IP address lookup service
'''
IP address lookup service
run your own external IP provider:
+ https://github.com/mpolden/ipd
+ <?php $ip = $_SERVER['REMOTE_ADDR']; ?>
<?php print $ip; ?>
e.g.
e.g.
+ https://ifconfig.co/ip
+ http://ifconfig.me/ip
+ http://whatismyip.akamai.com/
+ http://ipinfo.io/ip
+ many more ...
'''
ifconfig = 'choose_from_above_or_run_your_own'


'''
Target domain you wish to update your domain to.
'''
target_domain = 'target_domain_you_wish'
29 changes: 17 additions & 12 deletions src/gandi-live-dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
import requests, json
import config
import argparse
import socket

def get_DomainIp(target_domain):
''' Get IPv4 of target domainself.
This is the IP address of another domain you wish to update your own domain to
'''
ipaddress = socket.gethostbyname(target_domain)
return ipaddress

def get_dynip(ifconfig_provider):
''' find out own IPv4 at home <-- this is the dynamic IP which changes more or less frequently
Expand Down Expand Up @@ -89,19 +96,22 @@ def update_records(uuid, dynIP, subdomain):



def main(force_update, verbosity):
def main(force_update, verbosity, d2dmode):

if verbosity:
print "verbosity turned on - not implemented by now"


#get zone ID from Account
uuid = get_uuid()

#compare dynIP and DNS IP
dynIP = get_dynip(config.ifconfig)

#compare dynIP and DNS IP
if d2dmode:
dynIP = get_DomainIp(config.target_domain)
else:
dynIP = get_dynip(config.ifconfig)
dnsIP = get_dnsip(uuid)

if force_update:
print "Going to update/create the DNS Records for the subdomains"
for sub in config.subdomains:
Expand All @@ -118,13 +128,8 @@ def main(force_update, verbosity):
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', help="increase output verbosity", action="store_true")
parser.add_argument('-f', '--force', help="force an update/create", action="store_true")
parser.add_argument('-d', '--d2d', help="domain to domain mode", action="store_true")
args = parser.parse_args()


main(args.force, args.verbose)






main(args.force, args.verbose, args.d2d)