troglobit/inadyn

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

Tsuroerusu opened this issue · 6 comments

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.

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.

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?

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. :-)

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.

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!