diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2016-11-25 20:16:06 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2016-11-25 20:16:06 +0000 |
commit | 8d532683386121e70810b0d7c6642cc2c2b89cb0 (patch) | |
tree | 866010763c829a35b18603c5af58896bd14afd18 /src/conn-tools/s6-tlsclient.c | |
parent | 018025f0f36a4847df265c9948dbaf7073ed3245 (diff) | |
download | s6-networking-8d532683386121e70810b0d7c6642cc2c2b89cb0.tar.xz |
Fix build bugs. It builds!
Two things remain to do:
- how to pass SNI information to libtls
- how to detect cert issuer key type for ECC in bearssl
Diffstat (limited to 'src/conn-tools/s6-tlsclient.c')
-rw-r--r-- | src/conn-tools/s6-tlsclient.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/conn-tools/s6-tlsclient.c b/src/conn-tools/s6-tlsclient.c index 6d2249a..a1cd75d 100644 --- a/src/conn-tools/s6-tlsclient.c +++ b/src/conn-tools/s6-tlsclient.c @@ -9,9 +9,9 @@ #include <skalibs/ip46.h> #include <s6-networking/config.h> -#define USAGE "s6-tlsclient [ options ] ip port prog...\n" \ +#define USAGE "s6-tlsclient [ options ] host port prog...\n" \ "s6-tcpclient options: [ -q | -Q | -v ] [ -4 | -6 ] [ -d | -D ] [ -r | -R ] [ -h | -H ] [ -n | -N ] [ -t timeout ] [ -l localname ] [ -T timeoutconn ] [ -i localip ] [ -p localport ]\n" \ -"s6-tlsc options: [ -S | -s ] [ -Y | -y ] [ -K timeout ]" +"s6-tlsc options: [ -S | -s ] [ -Y | -y ] [ -K timeout ] [ -k servername ]" #define dieusage() strerr_dieusage(100, USAGE) @@ -19,6 +19,7 @@ typedef struct options_s options_t, *options_t_ref ; struct options_s { char const *localname ; + char const *servername ; unsigned int timeout ; unsigned int ximeout ; unsigned int yimeout ; @@ -40,6 +41,7 @@ struct options_s #define OPTIONS_ZERO \ { \ .localname = 0, \ + .servername = 0, \ .timeout = 0, \ .ximeout = 2, \ .yimeout = 58, \ @@ -66,7 +68,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "qQv46DdHhRrnNt:l:T:i:p:SsYyK:", &l) ; + register int opt = subgetopt_r(argc, argv, "qQv46DdHhRrnNt:l:T:i:p:SsYyK:k:", &l) ; if (opt == -1) break ; switch (opt) { @@ -78,7 +80,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'D' : o.flagD = 1 ; break ; case 'd' : o.flagD = 0 ; break ; case 'H' : o.flagH = 1 ; break ; - case 'h' : o.flagh = 0 ; break ; + case 'h' : o.flagH = 0 ; break ; case 'R' : o.flagr = 0 ; break ; case 'r' : o.flagr = 1 ; break ; case 'n' : o.flagN = 0 ; break ; @@ -106,6 +108,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'Y' : o.flagy = 0 ; break ; case 'y' : o.flagy = 1 ; break ; case 'K' : if (!uint0_scan(l.arg, &o.kimeout)) dieusage() ; break ; + case 'k' : o.servername = l.arg ; break ; default : dieusage() ; } } @@ -113,13 +116,20 @@ int main (int argc, char const *const *argv, char const *const *envp) if (argc < 3) dieusage() ; } + if (!o.servername && !o.flagH) + { + ip46full_t ip ; + if (!ip46full_scan(argv[0], &ip)) + o.servername = argv[0] ; + } + { unsigned int m = 0 ; unsigned int pos = 0 ; char fmt[UINT_FMT * 4 + UINT16_FMT + IP46_FMT] ; - char const *newargv[26 + argc] ; + char const *newargv[28 + argc] ; newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpclient" ; - if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" ; "-q" ; + if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" : "-q" ; if (o.flag4) newargv[m++] = "-4" ; if (o.flag6) newargv[m++] = "-6" ; if (o.flagD) newargv[m++] = "-D" ; @@ -172,6 +182,11 @@ int main (int argc, char const *const *argv, char const *const *envp) pos += uint_fmt(fmt + pos, o.kimeout) ; fmt[pos++] = 0 ; } + if (o.servername) + { + newargv[m++] = "-k" ; + newargv[m++] = o.servername ; + } newargv[m++] = "--" ; while (*argv) newargv[m++] = *argv++ ; newargv[m++] = 0 ; |