// Source
isc_sockaddr_t source_address;
+ // Transport
+ dns_transport_type_t transport;
+
// Zones
const char** zones;
unsigned int num_zones;
// Create the context
static ctx_t ctx = {
- .path = DEFAULT_PATH,
+ .path = DEFAULT_PATH,
+ .transport = DNS_TRANSPORT_NONE,
};
static dns_fixedname_t fixed = {};
dns_zone_setminxfrratein(zone, 10240, 300);
dns_xfrin_create(zone, xfrtype, &ctx.primary_address, &ctx.source_address, NULL,
- DNS_TRANSPORT_NONE, NULL, ctx.tlsctx_cache, ctx.memctx, &xfrin);
+ ctx.transport, NULL, ctx.tlsctx_cache, ctx.memctx, &xfrin);
// Start the transfer
return dns_xfrin_start(xfrin, transfer_done);
static const char* args_doc = "TODO";
enum {
- OPT_DEBUG = 1,
- OPT_PATH = 2,
- OPT_PRIMARY = 3,
+ OPT_DEBUG = 1,
+ OPT_PATH = 2,
+ OPT_PRIMARY = 3,
+ OPT_TRANSPORT = 4,
};
static struct argp_option options[] = {
- { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 },
- { "path", OPT_PATH, "PATH", 1, "Path where to store the zones", 0 },
- { "primary", OPT_PRIMARY, "HOSTNAME", 1, "The hostname of the primary to fetch from", 0 },
+ { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 },
+ { "path", OPT_PATH, "PATH", 1, "Path where to store the zones", 0 },
+ { "primary", OPT_PRIMARY, "HOSTNAME", 1, "The hostname of the primary to fetch from", 0 },
+ { "transport", OPT_TRANSPORT, "TRANSPORT", 1, "Choose the transport to use (TCP or TLS)", 0 },
{ NULL },
};
ctx.primary = arg;
break;
+ case OPT_TRANSPORT:
+ // TCP
+ if (strcmp(arg, "TCP") == 0)
+ ctx.transport = DNS_TRANSPORT_TCP;
+
+ // TLS
+ else if (strcmp(arg, "TLS") == 0)
+ ctx.transport = DNS_TRANSPORT_TLS;
+
+ // Fail on unknown transport
+ else
+ argp_failure(state, EXIT_FAILURE, 0, "Unknown transport: %s", arg);
+
+ break;
+
case ARGP_KEY_ARG:
zones = reallocarray(ctx.zones, ctx.num_zones + 1, sizeof(*ctx.zones));
if (!zones) {