mirror of
https://github.com/yrutschle/sslh.git
synced 2025-06-07 19:03:08 +03:00
commit
e66e443d5e
21
probe.c
21
probe.c
@ -107,25 +107,25 @@ void hexdump(const char *mem, unsigned int len)
|
|||||||
{
|
{
|
||||||
/* print offset */
|
/* print offset */
|
||||||
if(i % HEXDUMP_COLS == 0)
|
if(i % HEXDUMP_COLS == 0)
|
||||||
printf("0x%06x: ", i);
|
fprintf(stderr, "0x%06x: ", i);
|
||||||
|
|
||||||
/* print hex data */
|
/* print hex data */
|
||||||
if(i < len)
|
if(i < len)
|
||||||
printf("%02x ", 0xFF & mem[i]);
|
fprintf(stderr, "%02x ", 0xFF & mem[i]);
|
||||||
else /* end of block, just aligning for ASCII dump */
|
else /* end of block, just aligning for ASCII dump */
|
||||||
printf(" ");
|
fprintf(stderr, " ");
|
||||||
|
|
||||||
/* print ASCII dump */
|
/* print ASCII dump */
|
||||||
if(i % HEXDUMP_COLS == (HEXDUMP_COLS - 1)) {
|
if(i % HEXDUMP_COLS == (HEXDUMP_COLS - 1)) {
|
||||||
for(j = i - (HEXDUMP_COLS - 1); j <= i; j++) {
|
for(j = i - (HEXDUMP_COLS - 1); j <= i; j++) {
|
||||||
if(j >= len) /* end of block, not really printing */
|
if(j >= len) /* end of block, not really printing */
|
||||||
putchar(' ');
|
fputc(' ', stderr);
|
||||||
else if(isprint(mem[j])) /* printable char */
|
else if(isprint(mem[j])) /* printable char */
|
||||||
putchar(0xFF & mem[j]);
|
fputc(0xFF & mem[j], stderr);
|
||||||
else /* other char */
|
else /* other char */
|
||||||
putchar('.');
|
fputc('.', stderr);
|
||||||
}
|
}
|
||||||
putchar('\n');
|
fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,6 +297,13 @@ int probe_client_protocol(struct connection *cnx)
|
|||||||
* happens, we just connect to the default protocol so the caller of this
|
* happens, we just connect to the default protocol so the caller of this
|
||||||
* function does not have to deal with a specific failure condition (the
|
* function does not have to deal with a specific failure condition (the
|
||||||
* connection will just fail later normally). */
|
* connection will just fail later normally). */
|
||||||
|
|
||||||
|
/* Dump hex values of the packet */
|
||||||
|
if (verbose) {
|
||||||
|
fprintf(stderr, "hexdump of incoming packet:\n");
|
||||||
|
hexdump(buffer, n);
|
||||||
|
}
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
int res = PROBE_NEXT;
|
int res = PROBE_NEXT;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user