diff --git a/src/dns_poller.c b/src/dns_poller.c index 8f5f030..6e73d16 100644 --- a/src/dns_poller.c +++ b/src/dns_poller.c @@ -153,7 +153,8 @@ static void set_bootstrap_source_addr(ares_channel channel, } ares_set_local_ip6(channel, (const unsigned char *)&addr_v6); } else { - WLOG("Bootstrap source address '%s' is not a valid IP literal", source_addr); + // otherwise treat it as a device/interface name + ares_set_local_dev(channel, source_addr); return; } } diff --git a/src/dns_poller.h b/src/dns_poller.h index 6c411ce..b5bed43 100644 --- a/src/dns_poller.h +++ b/src/dns_poller.h @@ -37,7 +37,7 @@ typedef struct { // provided ev_loop. `bootstrap_dns` is a comma-separated list of DNS servers to // use for the lookup `hostname` every `interval_seconds`. For each successful // lookup, `cb` will be called with the resolved address. -// `source_addr` optionally binds bootstrap DNS lookups to a specific IP. +// `source_addr` optionally binds bootstrap DNS lookups to a specific IP/device. // `family` should be AF_INET for IPv4 or AF_UNSPEC for both IPv4 and IPv6. // // Note: hostname *not* copied. It should remain valid until diff --git a/src/https_client.c b/src/https_client.c index 0427721..878acb8 100644 --- a/src/https_client.c +++ b/src/https_client.c @@ -321,7 +321,7 @@ static void https_fetch_ctx_init(https_client_t *client, ASSERT_CURL_EASY_SETOPT(ctx, CURLOPT_PROXY, client->opt->curl_proxy); } if (client->opt->source_addr) { - DLOG_REQ("Using source address: %s", client->opt->source_addr); + DLOG_REQ("Using source address or device: %s", client->opt->source_addr); ASSERT_CURL_EASY_SETOPT(ctx, CURLOPT_INTERFACE, client->opt->source_addr); } if (client->opt->ca_info) { diff --git a/src/options.c b/src/options.c index fa04d2c..46949e8 100644 --- a/src/options.c +++ b/src/options.c @@ -260,7 +260,7 @@ void options_show_usage(int __attribute__((unused)) argc, char **argv) { printf(" supports it (http, https, socks4a, socks5h), otherwise\n"); printf(" initial DNS resolution will still be done via the\n"); printf(" bootstrap DNS servers.\n"); - printf(" -S source_addr Source IPv4/v6 address for outbound HTTPS and bootstrap DNS.\n"); + printf(" -S source_addr/dev Source IPv4/v6 address or device for outbound HTTPS and bootstrap DNS.\n"); printf(" (Default: system default)\n"); printf(" -x Use HTTP/1.1 instead of HTTP/2. Useful with broken\n" " or limited builds of libcurl.\n"); diff --git a/src/options.h b/src/options.h index 30784d2..a03cb85 100644 --- a/src/options.h +++ b/src/options.h @@ -46,7 +46,7 @@ struct Options { // e.g. "socks5://127.0.0.1:1080" const char *curl_proxy; - // Source address for outbound HTTPS connections + // Source address or device for outbound HTTPS connections and ares const char *source_addr; // 1 = Use only HTTP/1.1 for limited OpenWRT libcurl (which is not built with HTTP/2 support)