Skip to content

Commit

Permalink
Adds additional logs to TLSProxy and s_server
Browse files Browse the repository at this point in the history
  • Loading branch information
fwh-dc committed Jan 18, 2024
1 parent 2fba71b commit 18bb0f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
15 changes: 11 additions & 4 deletions apps/s_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,8 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
timeoutp = NULL;

i = select(width, (void *)&readfds, NULL, NULL, timeoutp);
BIO_printf(bio_s_out, "FWH i=%i, %i\n",
i, __LINE__);

if ((SSL_is_dtls(con)) && DTLSv1_handle_timeout(con) > 0)
BIO_printf(bio_err, "TIMEOUT occurred\n");
Expand All @@ -2664,6 +2666,8 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
int j, lf_num;

i = raw_read_stdin(buf, bufsize / 2);
BIO_printf(bio_s_out, "FWH i=%i, %i\n",
i, __LINE__);
lf_num = 0;
/* both loops are skipped when i <= 0 */
for (j = 0; j < i; j++)
Expand All @@ -2680,19 +2684,22 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
assert(lf_num == 0);
} else {
i = raw_read_stdin(buf, bufsize);
BIO_printf(bio_s_out, "FWH i=%i, %i\n",
i, __LINE__);
}

if (!s_quiet && !s_brief) {
if ((i <= 0) || (buf[0] == 'Q')) {
BIO_printf(bio_s_out, "DONE\n");
BIO_printf(bio_s_out, "DONE:i=%i, buf[0]='%c' %i\n",
i, buf[0], __LINE__);
(void)BIO_flush(bio_s_out);
BIO_closesocket(s);
close_accept_socket();
ret = -11;
goto err;
}
if ((i <= 0) || (buf[0] == 'q')) {
BIO_printf(bio_s_out, "DONE\n");
BIO_printf(bio_s_out, "DONE:%i\n", __LINE__);
(void)BIO_flush(bio_s_out);
if (SSL_version(con) != DTLS1_VERSION)
BIO_closesocket(s);
Expand Down Expand Up @@ -2795,7 +2802,7 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
goto err;
/* break; */
case SSL_ERROR_ZERO_RETURN:
BIO_printf(bio_s_out, "DONE\n");
BIO_printf(bio_s_out, "DONE:%i\n", __LINE__);
(void)BIO_flush(bio_s_out);
ret = 1;
goto err;
Expand Down Expand Up @@ -2886,7 +2893,7 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
ret = 1;
goto err;
case SSL_ERROR_ZERO_RETURN:
BIO_printf(bio_s_out, "DONE\n");
BIO_printf(bio_s_out, "DONE:%i\n", __LINE__);
(void)BIO_flush(bio_s_out);
ret = 1;
goto err;
Expand Down
10 changes: 9 additions & 1 deletion util/perl/TLSProxy/Proxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ sub start
# Connect right away...
$self->connect_to_server();

print STDERR "Proxy connected to server\n";

return $self->clientstart;
}

Expand Down Expand Up @@ -395,6 +397,7 @@ sub clientstart
print STDERR "Client command: $execcmd\n";
}

print STDERR "Starting s_client\n";
open(my $savedout, ">&STDOUT");
# If we open pipe with new descriptor, attempt to close it,
# explicitly or implicitly, would incur waitpid and effectively
Expand All @@ -404,17 +407,22 @@ sub clientstart
kill(3, $self->{real_serverpid});
die "Failed to $execcmd: $err\n";
}
print STDERR "s_client started\n";
$self->{clientpid} = $pid;

# queue [magic] input
print $self->reneg ? "R" : "test";
my $client_input = $self->reneg ? "R" : "test";
print STDERR "Queueing s_client input:'$client_input'\n";
print $client_input;

# this closes client's stdin without waiting for its pid
print STDERR "Close client stdin\n";
open(STDOUT, ">&", $savedout);
close($savedout);
}

# Wait for incoming connection from client
print STDERR "Wait for incoming connection from client\n";
my $fdset = IO::Select->new($self->{proxy_sock});
if (!$fdset->can_read(60)) {
kill(3, $self->{real_serverpid});
Expand Down

0 comments on commit 18bb0f8

Please sign in to comment.