isc_sockaddr_t source_address;
// Transport
- dns_transport_type_t transport;
+ dns_transport_type_t transport_type;
+ dns_transport_list_t* transports;
+ dns_transport_t* transport;
uint32_t port;
// Zones
dns_zone_setminxfrratein(zone, 10240, 300);
dns_xfrin_create(zone, xfrtype, &ctx.primary_address, &ctx.source_address, NULL,
- ctx.transport, NULL, ctx.tlsctx_cache, ctx.memctx, &xfrin);
+ ctx.transport_type, ctx.transport, ctx.tlsctx_cache, ctx.memctx, &xfrin);
// Start the transfer
return dns_xfrin_start(xfrin, transfer_done);
zone_done(zone);
}
+static int configure_transports(void) {
+ dns_name_t* name = NULL;
+ int r;
+
+ // Use the name of the primary
+ r = dns_name_from_string(&name, ctx.primary);
+ if (r) {
+ ERROR("Failed to parse the transport name %s: %s\n",
+ ctx.primary, isc_result_totext(r));
+ return r;
+ }
+
+ // Allocate a new transport list
+ ctx.transports = dns_transport_list_new(ctx.memctx);
+
+ // Allocate a new transport
+ ctx.transport = dns_transport_new(name, ctx.transport_type, ctx.transports);
+
+ // Set the remote hostname (for TLS SNI)
+ switch (ctx.transport_type) {
+ case DNS_TRANSPORT_TLS:
+ dns_transport_set_remote_hostname(ctx.transport, ctx.primary);
+ dns_transport_set_tlsname(ctx.transport, ctx.primary);
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
static void run_loop(void* data) {
struct in_addr any = {
.s_addr = INADDR_ANY,
// Create the source address
isc_sockaddr_fromin(&ctx.source_address, &any, 0);
+ // Configure transports
+ r = configure_transports();
+ if (r)
+ goto ERROR;
+
// Create a view
r = dns_view_create(ctx.memctx, ctx.loopmgr, ctx.dispatchmgr,
dns_rdataclass_in, "default", &ctx.view);
if (ctx.view)
dns_view_detach(&ctx.view);
+ // Destroy the transport
+ if (ctx.transport)
+ dns_transport_detach(&ctx.transport);
+
+ // Destroy the transport list
+ if (ctx.transports)
+ dns_transport_list_detach(&ctx.transports);
+
// Destroy the zone manager
if (ctx.zonemgr) {
dns_zonemgr_shutdown(ctx.zonemgr);
case OPT_TRANSPORT:
// TCP
if (strcmp(arg, "TCP") == 0) {
- ctx.transport = DNS_TRANSPORT_TCP;
+ ctx.transport_type = DNS_TRANSPORT_TCP;
ctx.port = 53;
// TLS
} else if (strcmp(arg, "TLS") == 0) {
- ctx.transport = DNS_TRANSPORT_TLS;
+ ctx.transport_type = DNS_TRANSPORT_TLS;
ctx.port = 853;
// Fail on unknown transport