wget: initial support for ftps://

function                                             old     new   delta
spawn_ssl_client                                       -     185    +185
parse_url                                            409     461     +52
packed_usage                                       32259   32278     +19
tls_run_copy_loop                                    293     306     +13
ssl_client_main                                      128     138     +10
showmode                                             330     338      +8
P_FTPS                                                 -       5      +5
filter_datapoints                                    177     179      +2
deflate                                              907     905      -2
decode_one_format                                    723     716      -7
wget_main                                           2591    2440    -151
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 6/3 up/down: 294/-160)          Total: 134 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2018-02-06 15:15:08 +01:00
parent e999657f6d
commit 403f2999f9
4 changed files with 42 additions and 16 deletions

View File

@ -15,7 +15,7 @@
//kbuild:lib-$(CONFIG_SSL_CLIENT) += ssl_client.o
//usage:#define ssl_client_trivial_usage
//usage: "-s FD [-r FD] [-n SNI]"
//usage: "[-e] -s FD [-r FD] [-n SNI]"
//usage:#define ssl_client_full_usage ""
#include "libbb.h"
@ -30,26 +30,28 @@ int ssl_client_main(int argc UNUSED_PARAM, char **argv)
// INIT_G();
tls = new_tls_state();
opt = getopt32(argv, "s:#r:#n:", &tls->ofd, &tls->ifd, &sni);
if (!(opt & 2)) {
opt = getopt32(argv, "es:#r:#n:", &tls->ofd, &tls->ifd, &sni);
if (!(opt & (1<<2))) {
/* -r N defaults to -s N */
tls->ifd = tls->ofd;
}
if (!(opt & 3)) {
if (!(opt & (3<<1))) {
if (!argv[1])
bb_show_usage();
/* Undocumented debug feature: without -s and -r, takes HOST arg and connects to it */
//
// Talk to kernel.org:
// printf "GET / HTTP/1.1\r\nHost: kernel.org\r\n\r\n" | ./busybox ssl_client kernel.org
// printf "GET / HTTP/1.1\r\nHost: kernel.org\r\n\r\n" | busybox ssl_client kernel.org
if (!sni)
sni = argv[1];
tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443);
}
tls_handshake(tls, sni);
tls_run_copy_loop(tls);
BUILD_BUG_ON(TLSLOOP_EXIT_ON_LOCAL_EOF != 1);
tls_run_copy_loop(tls, /*flags*/ opt & 1);
return EXIT_SUCCESS;
}