MINOR: tools: make str2sa_range() directly return the protocol
We'll need this so that it can return pointers to stacked protocol in
the future (for QUIC). In addition this removes a lot of tests for
protocol validity in the callers.
Some of them were checked further apart, or after a call to
str2listener() and they were simplified as well.
There's still a trick, we can fail to return a protocol in case the caller
accepts an fqdn for use later. This is what servers do and in this case it
is valid to return no protocol. A typical example is:
server foo localhost:1111
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index 8da8955..7d9569c 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -2224,15 +2224,14 @@
goto error;
}
- sk = str2sa_range(args[cur_arg+1], NULL, &port1, &port2, NULL,
+ sk = str2sa_range(args[cur_arg+1], NULL, &port1, &port2, NULL, &proto,
errmsg, NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM);
if (!sk) {
memprintf(errmsg, "'%s' : %s.", args[cur_arg], *errmsg);
goto error;
}
- proto = protocol_by_family(sk->ss_family);
- if (!proto || !proto->connect) {
+ if (!proto->connect) {
memprintf(errmsg, "'%s' : connect() not supported for this address family.\n",
args[cur_arg]);
goto error;