From e5d9e977e4a7ebe07b2d4d1130dfebc56d2c21e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 13 Jun 2015 07:39:21 +0200 Subject: [PATCH] relay: add a variable to read only one time the HTTP header "X-Real-IP" in the hashtable --- src/plugins/relay/relay-client.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c index 1fa56fa5b..4a6a2615b 100644 --- a/src/plugins/relay/relay-client.c +++ b/src/plugins/relay/relay-client.c @@ -271,6 +271,7 @@ void relay_client_recv_text (struct t_relay_client *client, const char *data) { char *new_partial, *raw_msg, **lines, *pos, *tmp, *handshake; + const char *ptr_real_ip; int i, num_lines, length, rc; if (client->partial_message) @@ -379,15 +380,19 @@ relay_client_recv_text (struct t_relay_client *client, const char *data) relay_client_set_status (client, RELAY_STATUS_DISCONNECTED); } - if (weechat_hashtable_get (client->http_headers, "X-Real-IP")) { - weechat_printf_tags (NULL, "relay_client", - _("%s: websocket client %s%s%s has real IP \"%s\""), - RELAY_PLUGIN_NAME, - RELAY_COLOR_CHAT_CLIENT, - client->desc, - RELAY_COLOR_CHAT, - weechat_hashtable_get (client->http_headers, "X-Real-IP") - ); + ptr_real_ip = weechat_hashtable_get ( + client->http_headers, "X-Real-IP"); + if (ptr_real_ip) + { + weechat_printf_tags ( + NULL, "relay_client", + _("%s: websocket client %s%s%s has real IP " + "address \"%s\""), + RELAY_PLUGIN_NAME, + RELAY_COLOR_CHAT_CLIENT, + client->desc, + RELAY_COLOR_CHAT, + ptr_real_ip); } /* remove HTTP headers */