Add flag to prevent duplicate server version sends and fix syntax error

parent cf1fbef9
......@@ -600,6 +600,13 @@ void handle_tunnel_data(SSL *ssl __attribute__((unused)), const char *request_id
pthread_mutex_unlock(&tunnel_mutex);
} else {
// wsssh/wssshc: Send directly to target socket
// Skip if server version was already sent early
if (active_tunnel->server_version_sent && strstr(data, "SSH-2.0-OpenSSH_10.0p2 Debian-8")) {
if (debug) {
printf("[DEBUG] Skipping duplicate server version send\n");
fflush(stdout);
}
} else {
if (debug) {
printf("[DEBUG] Attempting to send %zu bytes to socket %d\n", data_len, target_sock);
printf("[DEBUG - TOREMOVE] Target socket is %d\n", target_sock);
......@@ -670,6 +677,7 @@ void handle_tunnel_data(SSL *ssl __attribute__((unused)), const char *request_id
fflush(stdout);
}
}
}
free(data);
}
......@@ -1062,6 +1070,7 @@ int setup_tunnel(const char *wssshd_host, int wssshd_port, const char *client_id
active_tunnel->active = 1;
active_tunnel->broken = 0;
active_tunnel->ssl = ssl;
active_tunnel->server_version_sent = 0;
// Start listening on local port
int listen_sock = socket(AF_INET, SOCK_STREAM, 0);
......
......@@ -40,6 +40,7 @@ typedef struct {
SSL *ssl; // WebSocket SSL connection
frame_buffer_t *outgoing_buffer; // Buffer for data to send to local socket (wsscp only)
frame_buffer_t *incoming_buffer; // Buffer for incoming data before connection is established
int server_version_sent; // Flag to indicate if server version was sent early
} tunnel_t;
// Global variables
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment