commit ef46bc469fb8fe767900d10e9eb9d2b8a27d8cb9
parent 264911a44c5f5e8dd0469442b82d795deb4c831c
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Thu, 30 Jul 2020 14:51:25 -0500
now fails if proper arguments aren't provided
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/tlsrp.c b/tlsrp.c
@@ -227,7 +227,6 @@ main(int argc, char* argv[])
if (argc < 3)
usage();
- // TODO make parameter format enforcement stricter
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-u") == 0)
backpath = argv[++i];
@@ -251,14 +250,14 @@ main(int argc, char* argv[])
usage();
}
- if (backpath && (backhost || backport))
- die("cannot receive from both unix and network socket");
+ if ((backpath && backhost) || !(backpath || backport))
+ die("can only serve on unix socket xor network socket");
- if (frontpath && (fronthost || frontport))
- die("cannot serve to both unix and network socket");
+ if ((frontpath && fronthost) || !(frontpath || frontport))
+ die("can only receive on unix socket xor network socket");
if (!ca_path || !cert_path || !key_path)
- usage();
+ die("must provide ca_path, cert_path and key_path")
if ((config = tls_config_new()) == NULL)
tcdie(config, "failed to get tls config:");