]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: config: add complete support for str2sa_range() in 'server'
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Mar 2013 19:04:27 +0000 (20:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 10 Mar 2013 19:07:40 +0000 (20:07 +0100)
The server addresses are now completely parsed using str2sa_range()
and the resulting protocol is checked for support for connect().

src/cfgparse.c

index b5e02cd96bd4b91aa75edd49a1b9944455fee6b4..cc1ae426b8e012b9f12da279b7e217997d2429bd 100644 (file)
@@ -4043,7 +4043,7 @@ stats_error_parsing:
                }
 
                err = invalid_char(args[1]);
-               if (err) {
+               if (err && !defsrv) {
                        Alert("parsing [%s:%d] : character '%c' is not permitted in server name '%s'.\n",
                              file, linenum, *err, args[1]);
                        err_code |= ERR_ALERT | ERR_FATAL;
@@ -4053,6 +4053,8 @@ stats_error_parsing:
                if (!defsrv) {
                        struct sockaddr_storage *sk;
                        int port1, port2;
+                       char *err_msg = NULL;
+                       struct protocol *proto;
 
                        if ((newsrv = (struct server *)calloc(1, sizeof(struct server))) == NULL) {
                                Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
@@ -4082,9 +4084,19 @@ stats_error_parsing:
                         *  - IP:+N => port=+N, relative
                         *  - IP:-N => port=-N, relative
                         */
-                       sk = str2sa_range(args[2], &port1, &port2, NULL, NULL);
+                       sk = str2sa_range(args[2], &port1, &port2, &err_msg, NULL);
                        if (!sk) {
-                               Alert("parsing [%s:%d] : Unknown host in '%s'\n", file, linenum, args[2]);
+                               Alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], 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;
                        }