From: Willy Tarreau Date: Tue, 31 May 2022 07:25:34 +0000 (+0200) Subject: MINOR: server: indicate when no address was expected for a server X-Git-Tag: v2.6.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=245721b329721e862f34cebf6cf355694df31cb0;p=thirdparty%2Fhaproxy.git MINOR: server: indicate when no address was expected for a server When parsing a peers section, it's particularly difficult to make the difference between the local peer which doesn't have any address, and other peers which need one, and the error messages do not help because with just: peers foo bind :8001 server foo 127.0.0.1:8001 server bar 127.0.0.2:8001 One can get such a confusing message when the local peer is "bar": [peers.cfg:15] : 'server foo/bar' : unknown keyword '127.0.0.1:8001'. It's not clear there why the other peer doesn't trigger an error. With this commit we add a hint in the error message when no address was expected. The error remains quite generic (since deep into the server code) but at least the useer gets a hint about why the keyword wasn't understood: [peers.cfg:15] : 'server foo/bar' : unknown keyword '127.0.0.1:8001'. Hint: no address was expected for this server. --- diff --git a/src/server.c b/src/server.c index df84579ba4..5cf0eacdfd 100644 --- a/src/server.c +++ b/src/server.c @@ -2753,10 +2753,14 @@ static int _srv_parse_kw(struct server *srv, char **args, int *cur_arg, if (!kw) { best = srv_find_best_kw(args[*cur_arg]); if (best) - ha_alert("unknown keyword '%s'; did you mean '%s' maybe ?\n", - args[*cur_arg], best); + ha_alert("unknown keyword '%s'; did you mean '%s' maybe ?%s\n", + args[*cur_arg], best, + (parse_flags & SRV_PARSE_PARSE_ADDR) ? "" : + " Hint: no address was expected for this server."); else - ha_alert("unknown keyword '%s'.\n", args[*cur_arg]); + ha_alert("unknown keyword '%s'.%s\n", args[*cur_arg], + (parse_flags & SRV_PARSE_PARSE_ADDR) ? "" : + " Hint: no address was expected for this server."); return ERR_ALERT | ERR_FATAL; }