MINOR: standard: avoid DNS resolution from the function str2sa_range()
This patch blocks the DNS resolution in the function str2sa_range(),
this is useful if the function is used during the HAProxy runtime.
diff --git a/src/standard.c b/src/standard.c
index 7964b88..a468700 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -760,10 +760,12 @@
* that the caller will have to free(),
* - NULL if there was an explicit address that doesn't require resolution.
*
+ * Hostnames are only resolved if <resolve> is non-null.
+ *
* When a file descriptor is passed, its value is put into the s_addr part of
* the address when cast to sockaddr_in and the address family is AF_UNSPEC.
*/
-struct sockaddr_storage *str2sa_range(const char *str, int *low, int *high, char **err, const char *pfx, char **fqdn)
+struct sockaddr_storage *str2sa_range(const char *str, int *low, int *high, char **err, const char *pfx, char **fqdn, int resolve)
{
static struct sockaddr_storage ss;
struct sockaddr_storage *ret = NULL;
@@ -862,7 +864,7 @@
if (str2ip2(str2, &ss, 0) == NULL) {
use_fqdn = 1;
- if (str2ip(str2, &ss) == NULL) {
+ if (!resolve || str2ip2(str2, &ss, 1) == NULL) {
memprintf(err, "invalid address: '%s' in '%s'\n", str2, str);
goto out;
}