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

dynv6 (IPv4) fails to update IP address and returns a "400 Bad Request" error #433

Closed
Tsuroerusu opened this issue Jul 21, 2023 · 6 comments
Milestone

Comments

@Tsuroerusu
Copy link

Tsuroerusu commented Jul 21, 2023

I just installed inadyn 2.11 on FreeBSD via its package system and configured it as follows:

period = 86400

provider default@ipv4.dynv6.com {
        username = zzzzzz
        password = not_used
        hostname = { yyy.dynv6.net }
}

However when I attempt to start the service, the configtest passes, however it appears to never start, so I ran it in the foreground like so:

/usr/local/sbin/inadyn --once -n -l debug -p inadyn:inadyn -f /usr/local/etc/inadyn.conf -P /var/run/inadyn/inadyn.pid

It discovers the external IP just fine but then fails at the end:

root@server:/usr/local/etc # /usr/local/sbin/inadyn --once -n -l debug -p inadyn:inadyn -f /usr/local/etc/inadyn.conf -P /var/run/inadyn/inadyn.pid
inadyn 13599 - - In-a-dyn version 2.11.0 -- Dynamic DNS update client.
inadyn 13599 - - Resolving hostname yyy.dynv6.net => IP# xxx.xxx.xxx.xxx
inadyn 13599 - - Get address for default@ipv4.dynv6.com
inadyn 13599 - - Checking for IP# change, connecting to checkip.dyndns.com([193.122.6.168]:80)
inadyn 13599 - - Querying DDNS checkip server for my public IP#: GET / HTTP/1.0
Host: checkip.dyndns.com
User-Agent: inadyn/2.11.0 https://github.com/troglobit/inadyn/issues

inadyn 13599 - - Server response: HTTP/1.1 200 OK
Date: Fri, 21 Jul 2023 23:13:05 GMT
Content-Type: text/html
Content-Length: 106
Connection: close
Cache-Control: no-cache
Pragma: no-cache

<html><head><title>Current IP Check</title></head><body>Current IP Address: xxx.xxx.xxx.xxx</body></html>
inadyn 13599 - - Checked my IP, return code 0: OK
inadyn 13599 - - IP server response:
inadyn 13599 - - HTTP/1.1 200 OK
Date: Fri, 21 Jul 2023 23:13:05 GMT
Content-Type: text/html
Content-Length: 106
Connection: close
Cache-Control: no-cache
Pragma: no-cache

<html><head><title>Current IP Check</title></head><body>Current IP Address: xxx.xxx.xxx.xxx</body></html>
inadyn 13599 - - Checking IPv4 address xxx.xxx.xxx.xxx ...
inadyn 13599 - - IPv4 address xxx.xxx.xxx.xxx is valid.
inadyn 13599 - - No IP# change detected for default@ipv4.dynv6.com, still at xxx.xxx.xxx.xxx
inadyn 13599 - - Update forced for alias yyy.dynv6.net, new IP# xxx.xxx.xxx.xxx
inadyn 13599 - - Sending IP# update to DDNS server, connecting to ipv4.dynv6.com([159.69.43.243]:443)
inadyn 13599 - - Sending IP# update to DDNS server, initiating HTTPS ...
inadyn 13599 - - SSL connection using TLS_AES_128_GCM_SHA256
inadyn 13599 - - Certificate OK
inadyn 13599 - - SSL server cert subject: /CN=dynv6.com
inadyn 13599 - - SSL server cert issuer: /C=US/O=Let's Encrypt/CN=R3
inadyn 13599 - - Sending alias table update to DDNS server: GET /api/update?ipv4=xxx.xxx.xxx.xxx&hostname=yyy.dynv6.net&token=zzzzzzHTTP/1.0
Host: ipv4.dynv6.com
User-Agent: inadyn/2.11.0 https://github.com/troglobit/inadyn/issues

inadyn 13599 - - Successfully sent HTTPS request!
inadyn 13599 - - Successfully received HTTPS response (103/8191 bytes)!
inadyn 13599 - - DDNS server response: HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close

400 Bad Request
inadyn 13599 - - Fatal error in DDNS server response: DDNS server response not OK
inadyn 13599 - - 400 Bad Request
inadyn 13599 - - Error response from DDNS server, exiting!
inadyn 13599 - - Error code 48: DDNS server response not OK

The first thing I noticed was this line:

inadyn 13599 - - Sending alias table update to DDNS server: GET /api/update?ipv4=xxx.xxx.xxx.xxx&hostname=yyy.dynv6.net&token=zzzzzzHTTP/1.0

Given the lack of a space character between the token and the "HTTP/1.0", I assumed it somehow added that to the URL by mistake, so I copied that URL and ran it manually in my Firefox browser which worked fine and updated the IP, like so:

https://ipv4.dynv6.com/api/update?ipv4=xxx.xxx.xxx.xxx&hostname=yyy.dynv6.net&token=zzzzzz

I then tried running that command again via Firefox with the "HTTP/1.0" added and then then, somewhat obviously, get a the error code "invalid authentication token" and my Firefox developer console says the site returned a "HTTP/2 401 Unauthorized" error.

Personally, I have no idea what is causing this problem because, assuming the lack of a space between the token in the HTTP command and the "HTTP/1.0" is just cosmetic in the text output, the command works in Firefox but apparently not in inadyn.

@troglobit
Copy link
Owner

You've found a regression in v2.11.0, thanks! As you found out yourself, a space was lost between the token and HTTP/1.0 string.

@Tsuroerusu
Copy link
Author

You've found a regression in v2.11.0, thanks! As you found out yourself, a space was lost between the token and HTTP/1.0 string.

No problem, and sorry for the misclick (close/reopen). Do you think the failure is actually caused by the HTTP/1.0 being part of the URL string, or is this something else?

@troglobit
Copy link
Owner

troglobit commented Jul 22, 2023 via email

@Tsuroerusu
Copy link
Author

It’s definitely that, no doubt.

Cool, at least then it is not any great mystery. :-) I will keep subscribed to this issue, so if you need help testing a patch at some point, I should be able to do so since FreeBSD makes it easy for me to roll my own package. :-)

@troglobit
Copy link
Owner

There, should work better now. Just tack on .patch or .diff to the following hash URL cffc7af to get a -p1 patch file for your system.

@Tsuroerusu
Copy link
Author

I tested the patch and I can confirm that it works fine now. :-)
Thanks for taking the time to look into this so quickly. Basically, I was deploying inadyn on a machine for a client and so getting this resolved was great help.

Hvis du engang er i Danmark, så skylder jeg vidst en øl. :-)
God weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants