72
struct addrinfo *saddr;
72
int res = PROBE_AGAIN;
75
74
struct connection cnx;
77
cnx.q[0].fd = in_socket;
81
80
FD_SET(in_socket, &fds);
82
81
memset(&tv, 0, sizeof(tv));
83
82
tv.tv_sec = probing_timeout;
84
res = select(in_socket + 1, &fds, NULL, NULL, &tv);
88
cnx.q[0].fd = in_socket;
90
if (FD_ISSET(in_socket, &fds)) {
91
/* Received data: figure out what protocol it is */
92
prot = probe_client_protocol(&cnx);
94
/* Timed out: it's necessarily SSH */
95
prot = timeout_protocol();
84
while (res == PROBE_AGAIN) {
85
/* POSIX does not guarantee that tv will be updated, but the client can
86
* only postpone the inevitable for so long */
87
res = select(in_socket + 1, &fds, NULL, NULL, &tv);
91
if (FD_ISSET(in_socket, &fds)) {
92
/* Received data: figure out what protocol it is */
93
res = probe_client_protocol(&cnx);
95
/* Timed out: it's necessarily SSH */
96
cnx.proto = timeout_protocol();
100
check_access_rights(in_socket, prot->service)) {
101
if (cnx.proto->service &&
102
check_access_rights(in_socket, cnx.proto->service)) {
104
106
/* Connect the target socket */
105
out_socket = connect_addr(saddr, in_socket, prot->description);
107
out_socket = connect_addr(&cnx, in_socket);
106
108
CHECK_RES_DIE(out_socket, "connect");
108
110
cnx.q[1].fd = out_socket;
110
112
log_connection(&cnx);
112
flush_defered(&cnx.q[1]);
114
flush_deferred(&cnx.q[1]);