diff -ruN a/etc/inc/dyndns.class b/etc/inc/dyndns.class --- a/etc/inc/dyndns.class 2023-04-12 21:54:49.096627500 +0200 +++ b/etc/inc/dyndns.class 2023-04-13 20:03:21.329706400 +0200 @@ -1296,52 +1296,47 @@ /* see https://redmine.pfsense.org/issues/11293 * and https://redmine.pfsense.org/issues/12352 */ + $cookieFile = "/var/tmp/one.com.cookie"; + curl_setopt($ch, CURLOPT_URL, "https://www.one.com/admin/"); - curl_setopt($ch, CURLOPT_HEADER, 1); //return the full headers to extract the cookies + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent); $output = curl_exec($ch); - $last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); - - // extract the cookies - preg_match_all("/^Set-cookie: (.*?);/ism", $output, $cookies); - if (count($cookies[1]) > 0) { - $cookie_data = implode("; ", $cookies[1]); - } + $dom = new DOMDocument; + $dom->loadHTML($output); + $formTag = $dom->getElementsByTagName("form")[0]; + $login_url = $formTag->getAttribute("action"); // login in $post_data['username'] = $this->_dnsUser; $post_data['password'] = $this->_dnsPass; $post_data['credentialId'] = ''; - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); - curl_setopt($ch, CURLOPT_URL, $last_url); - curl_setopt($ch, CURLOPT_COOKIE, $cookie_data); - curl_setopt($ch, CURLOPT_HEADER, 1); //return the full headers to extract the cookies + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=' . $this->_dnsUser . '&password=' . $this->_dnsPass . '&credentialId='); + curl_setopt($ch, CURLOPT_URL, $login_url); curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent); $output = curl_exec($ch); - // extract the cookies - preg_match_all("/^Set-cookie: (.*?);/ism", $output, $cookies); - if (count($cookies[1]) > 0) { - $cookie_data = implode("; ", $cookies[1]); - } - // gets all DNS records of the domain. $post_data = null; - $url = "https://www.one.com/admin/api/domains/" . $this->_dnsDomain + "/dns/custom_records"; + $url = "https://www.one.com/admin/api/domains/" . $this->_dnsDomain . "/dns/custom_records"; curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); - curl_setopt($ch, CURLOPT_COOKIE, $cookie_data); + curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent); $output = curl_exec($ch); $result = json_decode($output, true); $records = $result['result']['data']; + $this->_dnsHostname = $this->_dnsHostname == "@" ? "" : $this->_dnsHostname; // Allow "@" to indicate root domain // finds the record id of a record from it's subdomain foreach ($records as $rec) { + log_error($rec['attributes']['prefix'] . ":" . $this->_dnsHostname); if ($rec['attributes']['prefix'] == $this->_dnsHostname) { $id = $rec['id']; break; @@ -1349,6 +1344,7 @@ } if (!$id) { log_error("Could not find one.com hostname record id"); + unlink($cookieFile); return false; } @@ -1716,6 +1712,10 @@ @curl_close($ch); $this->_checkStatus($http_code, $curl_error, $data, $header); } + + if (isset($cookieFile)) { + unlink($cookieFile); + } } /** diff -ruN a/usr/local/www/services_dyndns_edit.php b/usr/local/www/services_dyndns_edit.php --- a/usr/local/www/services_dyndns_edit.php 2023-04-13 19:52:39.707765400 +0200 +++ b/usr/local/www/services_dyndns_edit.php 2023-04-13 20:01:28.802407300 +0200 @@ -127,6 +127,8 @@ } elseif (($pconfig['type'] == "cloudflare") || ($pconfig['type'] == "cloudflare-v6")) { $host_to_check = $_POST['host'] == '@' ? $_POST['domainname'] : ( $_POST['host'] . '.' . $_POST['domainname'] ); $allow_wildcard = true; + } elseif (substr($pconfig['type'], 0, 6) == "onecom") { + $host_to_check = $_POST['host'] == '@' ? $_POST['domainname'] : ( $_POST['host'] . '.' . $_POST['domainname'] ); } elseif ((($pconfig['type'] == "godaddy") || ($pconfig['type'] == "godaddy-v6")) && ($_POST['host'] == '@.' || $_POST['host'] == '@')) { $host_to_check = $_POST['domainname']; } elseif (($pconfig['type'] == "digitalocean" || $pconfig['type'] == "digitalocean-v6") && ($_POST['host'] == '@.' || $_POST['host'] == '@')) {