Bug #6874
closedDynamic DNS w/ DNSimple
100%
Description
Around line 1380 in src/etc/inc/dyndns.class is a chunk of code that looks like this:
case 'dnsimple': /* Responds with HTTP 200 on success. Responds with HTTP 4xx on error. Returns JSON data as body */ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($data, 0, $header_size); $body = substr($data, $header_size); if (preg_match("/Status: 200\s/i", $header)) { $status = $status_intro . $success_str . gettext("IP Address Updated Successfully!"); $successful_update = true; } else if (preg_match("/Status: 4\d\d\s/i", $header)) {
The problem is right about if (preg_match("/Status: 200\s/i", $header)) {
which is correctly checking the response.
The actual response header looks like this:
HTTP/1.1 200 OK^M Server: nginx^M Date: Mon, 24 Oct 2016 06:13:15 GMT^M Content-Type: application/json; charset=utf-8^M Transfer-Encoding: chunked^M Connection: keep-alive^M Access-Control-Allow-Origin: *^M Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with^M Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS^M ETag: W/"ece8e39eaf0ef8783c19b83ab439b367"^M Cache-Control: max-age=0, private, must-revalidate^M X-Request-Id: 4f8ab086-79b0-423b-8119-d146cd1baf2c^M X-Runtime: 0.041082^M X-Content-Type-Options: nosniff^M X-Download-Options: noopen^M X-Frame-Options: DENY^M X-Permitted-Cross-Domain-Policies: none^M X-XSS-Protection: 1; mode=block^M Strict-Transport-Security: max-age=31536000^M ^M
I changed it to if (preg_match("/200\sOK\s/i", $header)) {
and it's working fine.
It'd be nice if this were updated to work with v2 of their API, but I'd be happy if that change made it into the next release.
Updated by Christoph Filnkößl about 8 years ago
I stumbled on to the same problem just now when implementing a new dyndns provider.
The code was wrong for both the 200 and 4xx response codes.
Additionally the header wasn't even provided so it couldn't have worked either way.
I submitted a pull request that fixes the header usage and DNSimple:
https://github.com/pfsense/pfsense/pull/3206
Updated by Renato Botelho about 8 years ago
- Status changed from New to Feedback
- Assignee set to Renato Botelho
- Target version set to 2.4.0
- % Done changed from 0 to 100
PR has been merged, thanks!
Updated by Jim Pingle almost 8 years ago
- Status changed from Feedback to Resolved
Tested, works. Error and success conditions are logged properly.