MEDIUM: tools: make str2sa_range() check that the protocol has ->connect()

Most callers of str2sa_range() need the protocol only to check that it
provides a ->connect() method. It used to be used to verify that it's a
stream protocol, but it might be a bit early to get rid of it. Let's keep
the test for now but move it to str2sa_range() when the new flag PA_O_CONNECT
is present. This way almost all call places could be cleaned from this.

There's a strange test in the server address parsing code that rechecks
the family from the socket which seems to be a duplicate of the previously
removed tests. It will have to be rechecked.
diff --git a/src/tools.c b/src/tools.c
index f2553a6..c4bc821 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -1176,7 +1176,7 @@
 			ss.ss_family = AF_CUST_UDP4;
 	}
 
-	if (proto) {
+	if (proto || (opts & PA_O_CONNECT)) {
 		/* Note: if the caller asks for a proto, we must find one,
 		 * except if we return with an fqdn that will resolve later,
 		 * in which case the address is not known yet (this is only
@@ -1187,6 +1187,11 @@
 			memprintf(err, "unsupported protocol family %d for address '%s'", ss.ss_family, str);
 			goto out;
 		}
+
+		if ((opts & PA_O_CONNECT) && new_proto && !new_proto->connect) {
+			memprintf(err, "connect() not supported for this protocol family %d used by address '%s'", ss.ss_family, str);
+			goto out;
+		}
 	}
 
 	ret = &ss;