observerss / pygodaddy

3rd Party Client Library for Manipulating Go Daddy DNS Records.
https://pygodaddy.readthedocs.org/
Other
37 stars 30 forks source link

Can't seem to connect to dns.godaddy.com #22

Open Yveske82 opened 8 years ago

Yveske82 commented 8 years ago

Since 2 days now I get an error when I run pygodaddy without making any changes. I tried with a previous, working installation but even ten I keep getting the error:

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pygodaddy/godaddy.py", line 87, in update_dns(public_ip) File "/usr/local/lib/python2.7/dist-packages/pygodaddy/godaddy.py", line 46, in update_dns client.login(GODADDY_USERNAME, GODADDY_PASSWORD) File "/usr/local/lib/python2.7/dist-packages/pygodaddy/client.py", line 99, in login r = self.session.get(self.default_url) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 487, in get return self.request('GET', url, _kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request resp = self.send(prep, _send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 585, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 467, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='dns.godaddy.com', port=443): Max retries exceeded with url: /default.aspx (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x762c2510>: Failed to establish a new connection: [Errno -2] Name or service not known',))

Can't seem to connect to dns.godaddy.com but I don't know if this is a godaddy issue or shoudl I be looking at my installation?

trkadi commented 8 years ago

Yes, it also does not work for me but enough. I decided to use godaddypy and man, much better! Full automatic for all of your accounts domins and A records.. And just a few lines. Use that! :)

Yveske82 commented 8 years ago

Do I just need to pass api key and api secret in the account file?

_api_key = None _api_secret = None

trkadi commented 8 years ago

My ipUpdater.py :))

#!/usr/bin/env python3

# Full package imports
import pif, sys

# Partial imports
from godaddypy import Client, Account

userAccount  = Account(api_key='here-comes-you-public-api-key', api_secret='here-comes-you-secret-api-key')
userClient   = Client(userAccount)
publicIP     = pif.get_public_ip('ident.me')

# Updates all domains all records
try:
    updateResult = userClient.update_ip(publicIP)
except:
    print(sys.exc_info()[1])
    sys.exit()

if updateResult is True:
    print('Update ended with no Exception.')
Yveske82 commented 8 years ago

If I try run the updater I get a no such file or directory, well kind of. Normally it should look like: bash: /usr/local/lib/python2.7/dist-packages/godaddypy/ipupdater.py : No such file or directory While now I get just: : No such file or directory But maybe I should go start an issue at godaddypy page?

trkadi commented 8 years ago

Can you copy your script? (with removed api keys naturally)

Yveske82 commented 8 years ago

Actually just copied yours. I do have python 2.7 instead of 3

#!/usr/bin/env python

# Full package imports
import pif, sys

# Partial imports
from godaddypy import Client, Account

userAccount  = Account(api_key='****', api_secret='****')
userClient   = Client(userAccount)
publicIP     = pif.get_public_ip('ident.me')

# Updates all domains all records
try:
    updateResult = userClient.update_ip(publicIP)
except:
    print(sys.exc_info()[1])
    sys.exit()

if updateResult is True:
    print('Update ended with no Exception.')
Yveske82 commented 8 years ago

Never mind, got it to work, I don't really know python. Had to add python in front of my script. It seems to work great now. You sir are a life safer. Thank you so much. It's just the same I guess as pygodaddy, just add it to a cron every 5 minutes?

PS. I know my api was visible for a minute. Already changed and deleted :)

trkadi commented 8 years ago

Yep. :) It's faster than pygodaddy cause of API - BUT nobody should misunderstand me, pygodadd was cool and the only tool for a while.. - Welcome. ^-^

Yveske82 commented 8 years ago

Not saying anything bad about pygodaddy. It worked great for me until 2 days ago. Anyway, I'm happy I got it able to change it again pygodaddy or godaddypy. Kinda bought a domain for € 0.99 impulsive and then realized I couldn't update my ip but that's fixed. Anyway thanks a lot for your help.

Yveske82 commented 8 years ago

Did you ever have the problem that your A-Record get's deleted? It happens to me once a day with this error:

Response Data: {u'message': u'One or more of the given records is invalid', u'code':
u'INVALID_RECORDS', u'errors': [u'ARECORD @ None is not a valid IP address'], u'name':
u'_Class'}

It happens to me like once a day.

trkadi commented 8 years ago

Hmm, quite interesting.. Also happened with me. They made a change as the lilac stuff write.. but it would be ridiculous if records got deleted cause of that...

Yveske82 commented 8 years ago

Well if it happened to you as well at least I'm not alone with the issue. I made an issue at the godaddypy page so hopefully this can get resolved soon. Right now when I can't reach my web address anymore I know I have to login my godaddy account and create a new A-record. So I guess this is how it will be done for now.

trkadi commented 8 years ago

just create an '@' record (and if you have more subdomains then also create the subdomains record.. with 0.0.0.0 and run the updater. That will solve it but yeah, migrate ourselves to godaddypy :dash: :D

Yveske82 commented 8 years ago

:D For now it will do yes but hopefully there be a fix soon. Or a way to auto create a new record

Yveske82 commented 8 years ago

Take a look here Got an answer on my issue already. Just adding a piece of code to your script. Testing it now.

sidheshdivekar29 commented 8 years ago

Hi, I generated my api_key and api_secret but when I client.get_domains() for testing it out godaddy returns {u'message': u'Malformed API secret', u'code': u'MALFORMED_API_SECRET', u'name': u'ApiError'}.

Has anyone seen this.

trkadi commented 8 years ago

Is it a production api key? And:

Note: Sometimes the production API keys don't seem to work correctly. Just delete it and request another one.

sidheshdivekar29 commented 8 years ago

Yes, its production api key, we regenerated it couple of times.

sidheshdivekar29 commented 8 years ago

Got it working. Between is there a way to delete an a record. I tried updating existing A record and modifying ttl to 0, but that does not delete an A record.

sistemaciesac commented 8 years ago

migrate ourselves to godaddypy too, Got it working, thanks a lot for your help and sharing :)

getSurreal commented 8 years ago

Thanks Adam for your starter script. Updating "all" records was too aggressive for me so here's an alternative to just update a single record.

!/usr/bin/env python3

Full package imports

import pif, sys

Partial imports

from godaddypy import Client, Account

domain = 'example.com' a_record = 'www'

userAccount = Account(api_key='Your_Key', api_secret='Your_Secret') userClient = Client(userAccount) publicIP = pif.get_public_ip('ident.me')

try: currentIP = userClient.get_record(domain, a_record, 'A') if (publicIP != currentIP["data"]): client.update_record_ip(publicIP, domain, a_record, 'A') if updateResult is True: print('Update ended with no Exception.') else: print('No DNS update needed.') except: print(sys.exc_info()[1]) sys.exit()

On 05/21/2016 01:18 PM, Ádám Török wrote:

My ipUpdater.py :))

!/usr/bin/env python3

Full package imports

import pif, sys

Partial imports

from godaddypyimport Client, Account

userAccount= Account(api_key='here-comes-you-public-api-key',api_secret='here-comes-you-secret-api-key') userClient= Client(userAccount) publicIP= pif.get_public_ip('ident.me')

Updates all domains all records

try: updateResult= userClient.update_ip(publicIP) except: print(sys.exc_info()[1]) sys.exit()

if updateResultis True: print('Update ended with no Exception.')

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/observerss/pygodaddy/issues/22#issuecomment-220792794

frol commented 8 years ago

@getSurreal JFYI, updateResult is not defined in your script, so it will crash.

getSurreal commented 8 years ago

thanks @frol . I'm not sure I should keep pasting code here, but here's the corrected version anyhow. I guess the proper thing to do is submit a pull request to the right project with this example.

#!/usr/bin/env python3

# Full package imports
import pif, sys

# Partial imports
from godaddypy import Client, Account

domain = 'example.com'
a_record = 'www'

userAccount  = Account(api_key='Your_Key', api_secret='Your_Secret')
userClient   = Client(userAccount)
publicIP     = pif.get_public_ip('ident.me')

try:
     currentIP = userClient.get_record(domain, a_record, 'A')
     if (publicIP != currentIP["data"]):
         updateResult = userClient.update_record_ip(publicIP, domain, a_record, 'A')
         if updateResult is True:
             print('Update ended with no Exception.')
     else:
         print('No DNS update needed.')
except:
     print(sys.exc_info()[1])
     sys.exit()
artoleus commented 8 years ago

@getSurreal I tried the above code and it didn't work for me I had to change a couple of things. Those were:

  1. userClient.get_record(domain, a_record, 'A') should be userClient.get_records(domain, 'A', a_record)
  2. publicIP != currentIP["data"] should be publicIP != currentIP[0]['data']
getSurreal commented 8 years ago

@artoleus Thanks for reply. It's working for me as is.

1) Your correction is not the correct syntax. See function below

def update_record_ip(self, ip, domain, name, record_type):
        """Update the IP address for a single record
        ip -- the new IP for the DNS record (ex. '123.1.2.255')
        domain -- the domain where the DNS belongs to (ex. 'example.com')
        name -- the DNS record name to be updated (ex. 'dynamic')
        record_type -- Record type (ex. 'CNAME', 'A'...)

2) My 'publicIP' does not come back as an array, but could be helpful for others.

artoleus commented 8 years ago

@getSurreal Not sure how it is working, are you using an older version?:

1) It is the correct syntax if you are looking at the right function try looking at "get_records" as I discussed. Also there is no function called "get_record."
def get_records(self, domain, record_type=None, name=None):

Although your code is similar to the example given in the example folder you will see that he has specified name=a_record, record_type='A' in the call to that function so position in that case doesn't matter. If you don't specify the type of entry then position becomes relevant.

2) neither does mine. It is accessing currentIP that is the issue. If you look at his example again you will see has used for records in records to get to the ["data"] record to load CurrentIP, which gives the same result as my suggestion

see his example below:

#!/usr/bin/env python3

# Full package imports
import sys

import pif
# Partial imports
from godaddypy import Client, Account

domain = 'example.com'
a_record = 'www'

userAccount = Account(api_key='YOUR_KEY', api_secret='YOUR_SECRET')
userClient = Client(userAccount)
publicIP = pif.get_public_ip('ident.me')

try:
    records = userClient.get_records(domain, name=a_record, record_type='A')
    for record in records:
        if publicIP != record["data"]:
            updateResult = userClient.update_record_ip(publicIP, domain, name=a_record, record_type='A')
            if updateResult is True:
                print('Update ended with no Exception.')
        else:
            print('No DNS update needed.')
except:
    print(sys.exc_info()[1])
    sys.exit()
nightah commented 8 years ago

I've ported a similar script from using pygodaddy to godaddypy. It can update multiple domains and hostnames and also has some logging, currently it's only retrieving A records but it's pretty simple to change if you want to update a CNAME or such.

https://github.com/nightah/godaddy-dyndns

Credits to CodeCorrupt and Sascha's original script.

JeremyCanfield commented 7 years ago

I sure am glad I happened upon this thread. I just discovered pygodaddy a couple days ago, and I couldn't understand why I was unable to connect to dns.godaddy.com. I just installed godaddypy an hour ago, and I'm able to connect to dns.godaddy.com now and view and update A and AAAA records. The godaddypy script is great.