Skip to content
Open
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions src/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
(unsigned int) ptr->Data.SOA.dwDefaultTtl);
break;

case DNS_TYPE_SRV:
snprintf(buf, sizeof buf, "%u %u %u %s",
ptr->Data.SRV.wPriority,
ptr->Data.SRV.wWeight,
ptr->Data.SRV.wPort,
ptr->Data.SRV.pNameTarget);
break;

default:
raw = 1;
rawdata = PROTECT(Rf_allocVector(RAWSXP, ptr->wDataLength));
Expand Down Expand Up @@ -468,6 +476,24 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
soa[0], soa[1], soa[2], soa[3], soa[4]);
break; }

case ns_t_srv:
u_int16_t priority, weight, port;
char target[NS_MAXDNAME];

NS_GET16(priority, data);
NS_GET16(weight, data);
NS_GET16(port, data);
ret = xxns_name_uncompress(ns_msg_base(msg), ns_msg_end(msg),
data, target, sizeof target);
if (ret < 0) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_SYSTEM_ERROR("Cannot parse SRV target hostname");
}
snprintf(buf, sizeof buf, "%u %u %u %s", priority, weight, port, target);
break;

default:
raw = 1;
rawdata = PROTECT(Rf_allocVector(RAWSXP, ns_rr_rdlen(rec)));
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-nsl.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_that("nsl function works with SRV records", {
testthat::skip_on_ci()

result = nsl("_http._tcp.mxtoolbox.com", type = 33L)
expect_true("10 100 80 mxtoolbox.com" %in% unlist(result$answer$data))
})
Loading