Skip to content

Commit

Permalink
add support to query SVCB and HTTPS records
Browse files Browse the repository at this point in the history
  • Loading branch information
zirngibl authored and blechschmidt committed Oct 1, 2021
1 parent f240c18 commit 7547268
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ typedef enum
DNS_REC_NSEC3 = 50,
DNS_REC_NSEC3PARAM = 51,
DNS_REC_OPENPGPKEY = 61,
DNS_REC_SVCB = 64,
DNS_REC_HTTPS = 65,
DNS_REC_PTR = 12,
DNS_REC_RP = 17,
DNS_REC_RRSIG = 46,
Expand Down Expand Up @@ -194,11 +196,23 @@ dns_record_type dns_str_to_record_type(const char *str)
return DNS_REC_INVALID;
}
case 'h':
if (tolower(str[1]) == 'i' && tolower(str[2]) == 'p' && str[3] == 0)
switch (tolower(str[1]))
{
return DNS_REC_HIP;
case 'i':
if(tolower(str[2]) == 'p' && str[3] == 0)
{
return DNS_REC_HIP;
}
return DNS_REC_INVALID;
case 't':
if(tolower(str[2]) == 't' && tolower(str[3]) == 'p' && tolower(str[4]) == 's' && str[5] == 0)
{
return DNS_REC_HTTPS;
}
return DNS_REC_INVALID;
default:
return DNS_REC_INVALID;
}
return DNS_REC_INVALID;
case 'i':
if (tolower(str[1]) == 'p' && tolower(str[2]) == 's' && tolower(str[3]) == 'e' && tolower(str[4]) == 'c'
&& tolower(str[5]) == 'k' && tolower(str[6]) == 'e' && tolower(str[7]) == 'y' && str[8] == 0)
Expand Down Expand Up @@ -338,6 +352,12 @@ dns_record_type dns_str_to_record_type(const char *str)
return DNS_REC_SSHFP;
}
return DNS_REC_INVALID;
case 'v':
if (tolower(str[2]) == 'c' && tolower(str[3]) == 'b' && str[4] == 0)
{
return DNS_REC_SVCB;
}
return DNS_REC_INVALID;
default:
return DNS_REC_INVALID;
}
Expand Down Expand Up @@ -918,6 +938,10 @@ char *dns_record_type2str(dns_record_type type)
return "TXT";
case DNS_REC_URI:
return "URI";
case DNS_REC_SVCB:
return "SVCB";
case DNS_REC_HTTPS:
return "HTTPS";
default:
snprintf(numbuf, sizeof(numbuf), "%" PRIu16, (uint16_t)type);
return numbuf;
Expand Down

0 comments on commit 7547268

Please # to comment.