Beispiel #1
0
import logging
import godaddypy

if "GD_KEY" not in os.environ:
    raise Exception(
        "Missing Godaddy API-key in GD_KEY environment variable! Please register one at https://developer.godaddy.com/keys/"
    )

if "GD_SECRET" not in os.environ:
    raise Exception(
        "Missing Godaddy API-secret in GD_SECRET environment variable! Please register one at https://developer.godaddy.com/keys/"
    )

api_key = os.environ["GD_KEY"]
api_secret = os.environ["GD_SECRET"]
my_acct = godaddypy.Account(api_key=api_key, api_secret=api_secret)
client = godaddypy.Client(my_acct)

logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.INFO)


def _get_zone(domain):
    parts = domain.split(".")
    zone_parts = parts[-2::]
    zone = ".".join(zone_parts)
    return zone


def _get_subdomain_for(domain, zone):
Beispiel #2
0
import sys
import logging
from tld import get_tld
import time
import godaddypy
from OpenSSL import crypto
import configparser

if "GD_KEY" not in os.environ:
    raise Exception("Missing Godaddy API-key in GD_KEY environment variable! Please register one at https://developer.godaddy.com/keys/")

if "GD_SECRET" not in os.environ:
    raise Exception("Missing Godaddy API-secret in GD_SECRET environment variable! Please register one at https://developer.godaddy.com/keys/")

my_acct = godaddypy.Account(
    api_key=os.environ["GD_KEY"], 
    api_secret=os.environ["GD_SECRET"]
)
client = godaddypy.Client(my_acct)

logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.INFO)

def _get_zone(domain):
    d = get_tld(domain,as_object=True,fix_protocol=True)
    return d.tld


def _get_subdomain_for(domain, zone):
    subdomain = domain[0:(-len(zone)-1)]
    return subdomain
# get current IP-addresses
ipv4 = False
ipv6 = False
try:
    ipv4 = requests.get('https://v4.ident.me/').content.decode()
except requests.exceptions.ConnectionError:
    logging.warn('GoDaddyUpdater: Cannot get current IPv4-Address')

try:
    ipv6 = requests.get('https://v6.ident.me/').content.decode()
except requests.exceptions.ConnectionError:
    logging.warn('GoDaddyUpdater: Cannot get current IPv6-Address')

# call godaddy api
account = godaddypy.Account(api_key=GODADDY_PUBLIC_KEY,
                            api_secret=GODADDY_SECRET_KEY)
client = godaddypy.Client(account)

for domain, subdomains in DOMAINS.items():
    if isinstance(subdomains, str):
        subdomains = [subdomains]

    if isinstance(subdomains, bool) and subdomains == True:
        subdomains = ['@']

    new_records = []
    for subdomain in subdomains:
        if ipv4:
            new_records.append({
                'data': ipv4,
                'name': subdomain,
def godaddyapi(key, secret):  # Returns godaddy API Client object.
    a = godaddypy.Account(api_key=key, api_secret=secret)
    return godaddypy.Client(a)