From 004ae15c55b58996d3f4baf0ca14a1c41ab6ce57 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 20 Oct 2013 20:18:26 +0200 Subject: Don't print fastd version from handshake requests when secure handshakes are set, instead print it on handshake finish --- src/handshake.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/handshake.c') diff --git a/src/handshake.c b/src/handshake.c index dedb482..28abfc2 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -334,6 +334,9 @@ static inline const fastd_method_t* get_method(fastd_context_t *ctx, const fastd } void fastd_handshake_handle(fastd_context_t *ctx, fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer, fastd_buffer_t buffer) { + char *peer_version = NULL; + const fastd_method_t *method = NULL; + fastd_handshake_t handshake = parse_tlvs(&buffer); if (!handshake.tlv_data) { @@ -351,7 +354,12 @@ void fastd_handshake_handle(fastd_context_t *ctx, fastd_socket_t *sock, const fa if (!check_records(ctx, sock, local_addr, remote_addr, peer, &handshake)) goto end_free; - const fastd_method_t *method = get_method(ctx, &handshake); + if (!ctx->conf->secure_handshakes || handshake.type > 1) { + method = get_method(ctx, &handshake); + + if (handshake.records[RECORD_VERSION_NAME].data) + handshake.peer_version = peer_version = strndup((const char*)handshake.records[RECORD_VERSION_NAME].data, handshake.records[RECORD_VERSION_NAME].length); + } if (handshake.type > 1 && !method) { send_error(ctx, sock, local_addr, remote_addr, peer, &handshake, REPLY_UNACCEPTABLE_VALUE, RECORD_METHOD_NAME); @@ -361,5 +369,6 @@ void fastd_handshake_handle(fastd_context_t *ctx, fastd_socket_t *sock, const fa ctx->conf->protocol->handshake_handle(ctx, sock, local_addr, remote_addr, peer, &handshake, method); end_free: + free(peer_version); fastd_buffer_free(buffer); } -- cgit v1.2.3