mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-25 06:53:03 +00:00
MEDIUM: config: use a single str2sa_range() call to parse bind addresses
str2listener() now doesn't check the address syntax, it only relies on str2sa_range() to retrieve the address and family.
This commit is contained in:
parent
b44dc2f388
commit
12eb2a6a97
@ -206,7 +206,7 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
||||
next = dupstr = strdup(str);
|
||||
|
||||
while (next && *next) {
|
||||
struct sockaddr_storage ss;
|
||||
struct sockaddr_storage ss, *ss2;
|
||||
|
||||
str = next;
|
||||
/* 1) look for the end of the first address */
|
||||
@ -214,25 +214,12 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
||||
*next++ = 0;
|
||||
}
|
||||
|
||||
if (*str == '/') {
|
||||
struct sockaddr_storage *ss2;
|
||||
|
||||
ss2 = str2sa_range(str, &port, &end, err,
|
||||
curproxy == global.stats_fe ? NULL : global.unix_bind.prefix);
|
||||
if (!ss2)
|
||||
goto fail;
|
||||
ss = *ss2;
|
||||
port = end = 0;
|
||||
}
|
||||
else {
|
||||
struct sockaddr_storage *ss2;
|
||||
|
||||
ss2 = str2sa_range(str, &port, &end, NULL, NULL);
|
||||
if (!ss2) {
|
||||
memprintf(err, "invalid listening address: '%s'\n", str);
|
||||
goto fail;
|
||||
}
|
||||
ss2 = str2sa_range(str, &port, &end, err,
|
||||
curproxy == global.stats_fe ? NULL : global.unix_bind.prefix);
|
||||
if (!ss2)
|
||||
goto fail;
|
||||
|
||||
if (ss2->ss_family == AF_INET || ss2->ss_family == AF_INET6) {
|
||||
if (!port && !end) {
|
||||
memprintf(err, "missing port number: '%s'\n", str);
|
||||
goto fail;
|
||||
@ -243,9 +230,6 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* OK the address looks correct */
|
||||
ss = *ss2;
|
||||
|
||||
if (port < 1 || port > 65535) {
|
||||
memprintf(err, "invalid port '%d' specified for address '%s'.\n", port, str);
|
||||
goto fail;
|
||||
@ -257,6 +241,9 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
||||
}
|
||||
}
|
||||
|
||||
/* OK the address looks correct */
|
||||
ss = *ss2;
|
||||
|
||||
for (; port <= end; port++) {
|
||||
l = (struct listener *)calloc(1, sizeof(struct listener));
|
||||
l->obj_type = OBJ_TYPE_LISTENER;
|
||||
|
Loading…
Reference in New Issue
Block a user