mirror of
https://github.com/moparisthebest/sslh
synced 2024-11-24 01:52:24 -05:00
new test for PROBE_AGAIN; changed deferred_data to begin_deferred_data where appropriate
This commit is contained in:
parent
025545aee3
commit
96f5d6387e
2
common.c
2
common.c
@ -166,7 +166,7 @@ int defer_write(struct queue *q, void* data, int data_size)
|
|||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "**** writing deferred on fd %d\n", q->fd);
|
fprintf(stderr, "**** writing deferred on fd %d\n", q->fd);
|
||||||
|
|
||||||
p = realloc(q->deferred_data, q->deferred_data_size + data_size);
|
p = realloc(q->begin_deferred_data, q->deferred_data_size + data_size);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
perror("realloc");
|
perror("realloc");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
8
probe.c
8
probe.c
@ -234,9 +234,9 @@ static int regex_probe(const char *p, int len, struct proto *proto)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the beginning of data coming from the client connection and check if
|
* Read the beginning of data coming from the client connection and check if
|
||||||
* it's a known protocol. Then leave the data on the deferred
|
* it's a known protocol.
|
||||||
* write buffer of the connection and returns a pointer to the protocol
|
* Return PROBE_AGAIN if not enough data, or PROBE_MATCH if it succeeded in
|
||||||
* structure
|
* which case cnx->proto is set to the appropriate protocol.
|
||||||
*/
|
*/
|
||||||
int probe_client_protocol(struct connection *cnx)
|
int probe_client_protocol(struct connection *cnx)
|
||||||
{
|
{
|
||||||
@ -260,7 +260,7 @@ int probe_client_protocol(struct connection *cnx)
|
|||||||
if (verbose) fprintf(stderr, "probing for %s\n", p->description);
|
if (verbose) fprintf(stderr, "probing for %s\n", p->description);
|
||||||
|
|
||||||
cnx->proto = p;
|
cnx->proto = p;
|
||||||
res = p->probe(cnx->q[1].deferred_data, cnx->q[1].deferred_data_size, p);
|
res = p->probe(cnx->q[1].begin_deferred_data, cnx->q[1].deferred_data_size, p);
|
||||||
}
|
}
|
||||||
if (res != PROBE_NEXT)
|
if (res != PROBE_NEXT)
|
||||||
return res;
|
return res;
|
||||||
|
6
probe.h
6
probe.h
@ -6,9 +6,9 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PROBE_NEXT,
|
PROBE_NEXT, /* Enough data, probe failed -- it's some other protocol */
|
||||||
PROBE_MATCH,
|
PROBE_MATCH, /* Enough data, probe successful -- it's the current protocol */
|
||||||
PROBE_AGAIN,
|
PROBE_AGAIN, /* Not enough data for this probe, try again with more data */
|
||||||
} probe_result;
|
} probe_result;
|
||||||
|
|
||||||
struct proto;
|
struct proto;
|
||||||
|
19
t
19
t
@ -18,6 +18,7 @@ my $pidfile = "/tmp/sslh_test.pid";
|
|||||||
my $SSL_CNX = 1;
|
my $SSL_CNX = 1;
|
||||||
my $SSH_SHY_CNX = 1;
|
my $SSH_SHY_CNX = 1;
|
||||||
my $SSH_BOLD_CNX = 1;
|
my $SSH_BOLD_CNX = 1;
|
||||||
|
my $SSH_PROBE_AGAIN = 1;
|
||||||
my $SSL_MIX_SSH = 1;
|
my $SSL_MIX_SSH = 1;
|
||||||
my $SSH_MIX_SSL = 1;
|
my $SSH_MIX_SSL = 1;
|
||||||
my $BIG_MSG = 0; # This test is unreliable
|
my $BIG_MSG = 0; # This test is unreliable
|
||||||
@ -62,7 +63,7 @@ for my $binary (@binaries) {
|
|||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
warn "spawned $sslh_pid\n";
|
warn "spawned $sslh_pid\n";
|
||||||
sleep 1; # valgrind can be heavy -- wait 5 seconds
|
sleep 5; # valgrind can be heavy -- wait 5 seconds
|
||||||
|
|
||||||
|
|
||||||
my $test_data = "hello world\n";
|
my $test_data = "hello world\n";
|
||||||
@ -108,6 +109,22 @@ for my $binary (@binaries) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test: PROBE_AGAIN, incomplete first frame
|
||||||
|
if ($SSH_PROBE_AGAIN) {
|
||||||
|
print "***Test: incomplete SSH first frame\n";
|
||||||
|
my $cnx_h = new IO::Socket::INET(PeerHost => "localhost:$sslh_port");
|
||||||
|
warn "$!\n" unless $cnx_h;
|
||||||
|
if (defined $cnx_h) {
|
||||||
|
my $td = "SSH-2.0 testsuite\t$test_data";
|
||||||
|
print $cnx_h substr $td, 0, 2;
|
||||||
|
sleep 1;
|
||||||
|
print $cnx_h substr $td, 2;
|
||||||
|
my $data = <$cnx_h>;
|
||||||
|
is($data, "ssh: $td", "Incomplete first SSH frame");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Test: One SSL half-started then one SSH
|
# Test: One SSL half-started then one SSH
|
||||||
if ($SSL_MIX_SSH) {
|
if ($SSL_MIX_SSH) {
|
||||||
print "***Test: One SSL half-started then one SSH\n";
|
print "***Test: One SSL half-started then one SSH\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user