Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add support to query SVCB and HTTPS records #120

Merged
merged 1 commit into from
Oct 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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