TimothyYe / godns

A dynamic DNS client tool that supports AliDNS, Cloudflare, Google Domains, DNSPod, HE.net & DuckDNS & DreamHost, etc, written in Go.
https://timothyye.github.io/godns/
Apache License 2.0
1.51k stars 224 forks source link

Google DNS not working - potentially need to set user agent string #46

Closed jfritz closed 4 years ago

jfritz commented 5 years ago

godns 1.9.1 doesn't seem to successfully update my ddns with Google. The messaging looks successful:

C:\Users\jeff\Desktop\GoDNS>godns.exe
[GoDNS] 2019/08/30 18:46:20 GoDNS started, entering main loop...
[GoDNS] 2019/08/30 18:46:20 Creating DNS handler with provider: Google
[GoDNS] 2019/08/30 18:46:21 currentIP is: [censored]
[GoDNS] 2019/08/30 18:46:21 Going to sleep, will start next checking in 300 seconds...

however, checking Google Domains, the last update for my DNS was stated to be months ago.

To check, I made the request directly via a browser to the end point using the same config/username/password/domain, and this successfully updated my ddns IP. https://CENSORED:CENSORED@domains.google.com/nic/update?hostname=CENSORED.net&myip=CENSORED

I noticed that UpdateIP() in the Google handler does not set a user agent when sending the request to the Google API endpoint. Per Google's API documentation, you should set a user agent when updating DNS: "Note: You must set a user agent in your request as well. Web browsers will generally add this for you when testing via the above url."

Note the user agent might be required for other services as well, as it is one of the few things public API endpoints can use to ban "bad" bots who improperly use APIs without actually banning specific IPs directly - not saying this is the case here, but just noting in general.

Edit: is there a way I can set user agent via the configuration?

TimothyYe commented 5 years ago

Thanks for your feedback, I'll add it.

TimothyYe commented 5 years ago

@jfritz Please try this version https://github.com/TimothyYe/godns/releases/tag/V1.9.2 You can set the user agent via the configuration now.

jfritz commented 5 years ago

Alright, the user agent was probably an issue, but I dug deeper (since it still wasn't working) and found another problem (which I hope is probably the last/root cause issue). Sorry for all the hassle here.

The username:password need to be provided via HTTP Basic Auth, not as query string parameters or POST data as the code is currently doing. Below is an example from the Google Domains API documentation.

Tl;dr - this might be as simple as using req.SetBasicAuth(username, password) and removing the values.Add("username:password", ...).

2019-09-03 20_56_13-Window

TimothyYe commented 5 years ago

@jfritz Really appreciate with your feedback. I don't have a Google domain account since it is not supported in my country. You may try this version: https://github.com/TimothyYe/godns/releases/tag/V1.9.3

TimothyYe commented 4 years ago

Hi @jfritz , is this issue fixed already? I plan to close this issue...

BradHemmingsen commented 4 years ago

Hi @TimothyYe, have you confirmed with any test users that Google DNS Update is working?

I'm getting the following feedback in a Windows environment:

` E:\Repositories\godns-2.1>godns.exe

[GoDNS] 2020/04/22 16:09:23 GoDNS started, entering main loop... [GoDNS] 2020/04/22 16:09:23 Creating DNS handler with provider: Google [GoDNS] 2020/04/22 16:09:24 currentIP is: CENSORED [GoDNS] 2020/04/22 16:09:24 CENSORED Start to update record IP... [GoDNS] 2020/04/22 16:09:24 Update IP success: notfqdn [GoDNS] 2020/04/22 16:09:24 Going to sleep, will start next checking in 21600 seconds... `

However, updating manually in the browser works https://CENSORED:CENSORED@domains.google.com/nic/update?hostname=CENSORED.com&myip=CENSORED

TimothyYe commented 4 years ago

@hemming1 Hmmm, Google Domain is unavailable in my country, however, I'll find a way to register an account and try to reproduce this issue.

BradHemmingsen commented 4 years ago

@jfritz Were you able to get your domain ip to update successfully?

jfritz commented 4 years ago

I ultimately I ran into crunch time at work and it prevented me from debugging the issue further. I did get the direct web request updates to work as you mentioned earlier.

On Thu, Apr 23, 2020, 11:07 AM Brad Hemmingsen notifications@github.com wrote:

@jfritz https://github.com/jfritz Were you able to get your domain ip to update successfully?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TimothyYe/godns/issues/46#issuecomment-618489051, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCAQ5YL5FFK2KOGRYTZBLROBRVNANCNFSM4ISR6WSQ .

BradHemmingsen commented 4 years ago

@TimothyYe would it be useful if I setup a temporary domain for you to test on?

TimothyYe commented 4 years ago

@BradHemmingsen That would be great! Thanks!

TimothyYe commented 4 years ago

@BradHemmingsen Now I get another error, it seems that DDNS is not enabled for this temporary domain. Would you pls help to enable it?

nohost - The hostname does not exist, or does not have Dynamic DNS enabled.
TimothyYe commented 4 years ago

@BradHemmingsen Issue has been fixed, pls try this pre-release version: https://github.com/TimothyYe/godns/releases/tag/V2.1.1