SVCB and HTTPS record creation bug

It would seem there is a bug in the creation of SVCB and HTTPS records, when entering just an alpn alpn="h3,h2" it accepts it, but when entering ipv4hint and ipv6hint it fails

But only if I use quotes around the IP, so this fails

alpn="h3,h2" ipv4hint="1.2.3.4" ipv6hint="2001:0db8:85a3:0000:0000:8a2e:0370:733"

while this works
alpn="h3,h2" ipv4hint=1.2.3.4 ipv6hint=2001:0db8:85a3:0000:0000:8a2e:0370:733

Oddly enough, after saving, it then quotes the ip hints and looks exactly as i had initially entered it

Edit: it actually does seem to work sometimes, but most times complains DNS Validation Error (Code: 1004) Value for SVCB record is invalid.

Better yet, the API is also not cooperating at all when trying to update SVCB records. I have no issue writing scripts to update any other record, so im aware of Cloudflares annoying quirks (things such as CF returning True/False but then not accepting True/False on PUT calls, requiring lowercase true/false)

Not to mention Cloudflares own API docs have very poor examples. The fact all the examples print out json data instead of using the languages native json encoding function shows just how jank the cloudflare API really is.

Edit: heres a good script for listing and updating SVCB and HTTPS records… I honestly cannot believe cloudflares own documentation shows printing json data manually to the body. this is an absolutely horrible practice that starts newbies down the wrong path. Please cloudflare, get someone well educated in scripting to update the docs. whomever wrote these docs did a poor job.

$type = "HTTPS"
$email = "YOUR_EMAIL"
$apikey = "APIKEY"
$ZoneID = "ZONEID"
$iplink = "https://ipv4.seeip.org"
$ipV6link = "https://ipv6.seeip.org"
$date = get-date -format yyyy-MM-ddTHH-mm-ss-ff
#list all records of $type... -UseBasicParsing disables the ie engine, making it faster and dodges issues with local service accounts not being able to use ie engine
$response = Invoke-RestMethod -UseBasicParsing -Uri "https://api.cloudflare.com/client/v4/zones/$ZoneID/dns_records?type=$type" -Method GET -Headers @{'Accept'='application/json';'X-Auth-Email'="$email";'X-Auth-Key'="$apikey"} -ContentType "application/json" 

#get ip address
Try {
    $CurrentIP=Invoke-RestMethod -UseBasicParsing -Uri "$iplink"
    $CurrentIPV6=Invoke-RestMethod -UseBasicParsing -Uri "$ipV6link"
} Catch {
    $message = $date + " No connection! quitting"
    $message | Out-File $PSScriptRoot/logfile.$ZoneID.$type.txt -Encoding utf8 -Append
    Exit
}
if(!$CurrentIP -or !$CurrentIPv6){
    $message = $date + " API Error! quitting"
    $message | Out-File $PSScriptRoot/logfile.$ZoneID.$type.txt -Encoding utf8 -Append
    Exit
}

$result = $response.result
foreach($r in $result){
    $data = @{
        "type"=$type;
        "name"=$r.name;
        "data"=@{
            "priority"=[int]$r.data.priority;
            "target"=$r.data.target;
            "value"="alpn=`"h3,h2,http/1.1`" ipv4hint=`"$CurrentIP`" ipv6hint=`"$CurrentIPv6`"";
        }
    } | ConvertTo-Json
    Invoke-RestMethod -UseBasicParsing -Uri "https://api.cloudflare.com/client/v4/zones/$ZoneID/dns_records/$($r.id)" -Method PUT  -Headers @{'Accept'='application/json';'X-Auth-Email'="$email";'X-Auth-Key'="$apikey"} -ContentType 'application/json' -Body $data
    
    $message = "$date Updated $($r.name) with $data"
    $message | Out-File $PSScriptRoot/logfile.$ZoneID.$type.txt -Encoding utf8 -Append
}

Interestingly, the API accepts quoted ip hints here, but the web interface does not

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.