mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 00:57:02 +02:00
MEDIUM: config: add complete support for str2sa_range() in dispatch
The dispatch statement now completely relies on str2sa_range() to parse an address.
This commit is contained in:
parent
add0ab1975
commit
f3559bffd6
@ -3945,6 +3945,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
else if (!strcmp(args[0], "dispatch")) { /* dispatch address */
|
||||
struct sockaddr_storage *sk;
|
||||
int port1, port2;
|
||||
char *err_msg = NULL;
|
||||
struct protocol *proto;
|
||||
|
||||
if (curproxy == &defproxy) {
|
||||
Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
|
||||
@ -3954,9 +3956,19 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
else if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
|
||||
err_code |= ERR_WARN;
|
||||
|
||||
sk = str2sa_range(args[1], &port1, &port2, NULL, NULL);
|
||||
sk = str2sa_range(args[1], &port1, &port2, &err_msg, NULL);
|
||||
if (!sk) {
|
||||
Alert("parsing [%s:%d] : '%s' : unknown host in '%s'\n", file, linenum, args[0], args[1]);
|
||||
Alert("parsing [%s:%d] : '%s' : %s\n", file, linenum, args[0], err_msg);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
free(err_msg);
|
||||
goto out;
|
||||
}
|
||||
free(err_msg);
|
||||
|
||||
proto = protocol_by_family(sk->ss_family);
|
||||
if (!proto || !proto->connect) {
|
||||
Alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n",
|
||||
file, linenum, args[0], args[1]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user