From d2a93c3a03abbbed65dca5aba961972ddcb73462 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 6 Oct 2019 07:37:55 +0200 Subject: [PATCH] websocket module will now only disable show-connect-info on the ports that have listen::options::websocket. It will no longer disable it on all ports. --- include/h.h | 9 ++------- src/bsd.c | 6 +++--- src/modules/ident_lookup.c | 6 +++--- src/modules/websocket.c | 7 ------- src/user.c | 18 ++++++++++++++++++ 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/include/h.h b/include/h.h index faa85215e..078c6e400 100644 --- a/include/h.h +++ b/include/h.h @@ -143,9 +143,6 @@ extern void del_ListItem(ListStruct *, ListStruct **); extern MODVAR LoopStruct loop; extern int del_banid(Channel *channel, char *banid); extern int del_exbanid(Channel *channel, char *banid); -#ifdef SHOWCONNECTINFO - - #define BREPORT_DO_DNS "NOTICE * :*** Looking up your hostname...\r\n" #define BREPORT_FIN_DNS "NOTICE * :*** Found your hostname\r\n" #define BREPORT_FIN_DNSC "NOTICE * :*** Found your hostname (cached)\r\n" @@ -158,10 +155,7 @@ extern MODVAR char REPORT_DO_DNS[256], REPORT_FIN_DNS[256], REPORT_FIN_DNSC[256] REPORT_FAIL_DNS[256], REPORT_DO_ID[256], REPORT_FIN_ID[256], REPORT_FAIL_ID[256]; -extern MODVAR int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns, - R_do_id, R_fin_id, R_fail_id; - -#endif +extern MODVAR int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns, R_do_id, R_fin_id, R_fail_id; extern MODVAR struct list_head client_list; extern MODVAR struct list_head lclient_list; extern MODVAR struct list_head server_list; @@ -952,3 +946,4 @@ extern char *unrl_utf8_make_valid(const char *str); extern void utf8_test(void); extern MODVAR int non_utf8_nick_chars_in_use; extern void short_motd(Client *client); +extern int should_show_connect_info(Client *client); diff --git a/src/bsd.c b/src/bsd.c index 31f5ab41d..f50b0a6d0 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -1019,7 +1019,7 @@ struct hostent *he; if (!DONT_RESOLVE) { - if (SHOWCONNECTINFO && !client->serv && !IsServersOnlyListener(client->local->listener)) + if (should_show_connect_info(client)) sendto_one(client, NULL, "%s", REPORT_DO_DNS); dns_special_flag = 1; he = unrealdns_doclient(client); @@ -1035,7 +1035,7 @@ struct hostent *he; } else { /* Host was in our cache */ client->local->hostp = he; - if (SHOWCONNECTINFO && !client->serv && !IsServersOnlyListener(client->local->listener)) + if (should_show_connect_info(client)) sendto_one(client, NULL, "%s", REPORT_FIN_DNSC); } } @@ -1049,7 +1049,7 @@ void proceed_normal_client_handshake(Client *client, struct hostent *he) { ClearDNSLookup(client); client->local->hostp = he; - if (SHOWCONNECTINFO && !client->serv && !IsServersOnlyListener(client->local->listener)) + if (should_show_connect_info(client)) sendto_one(client, NULL, "%s", client->local->hostp ? REPORT_FIN_DNS : REPORT_FAIL_DNS); if (!dns_special_flag && !IsIdentLookup(client)) diff --git a/src/modules/ident_lookup.c b/src/modules/ident_lookup.c index d04fefe07..456388798 100644 --- a/src/modules/ident_lookup.c +++ b/src/modules/ident_lookup.c @@ -53,7 +53,7 @@ static void ident_lookup_failed(Client *client) } ClearIdentLookupSent(client); ClearIdentLookup(client); - if (SHOWCONNECTINFO && !client->serv && !IsServersOnlyListener(client->local->listener)) + if (should_show_connect_info(client)) sendto_one(client, NULL, "%s", REPORT_FAIL_ID); if (!IsDNSLookup(client)) finish_auth(client); @@ -90,7 +90,7 @@ static int ident_lookup_connect(Client *client) return 0; } - if (SHOWCONNECTINFO && !client->serv && !IsServersOnlyListener(client->local->listener)) + if (should_show_connect_info(client)) sendto_one(client, NULL, "%s", REPORT_DO_ID); set_sock_opts(client->local->authfd, client, IsIPV6(client)); @@ -165,7 +165,7 @@ static void ident_lookup_receive(int fd, int revents, void *userdata) if (!IsDNSLookup(client)) finish_auth(client); - if (SHOWCONNECTINFO && !client->serv && !IsServersOnlyListener(client->local->listener)) + if (should_show_connect_info(client)) sendto_one(client, NULL, "%s", REPORT_FIN_ID); if (len > 0) diff --git a/src/modules/websocket.c b/src/modules/websocket.c index 8492f8c4a..c966b39c6 100644 --- a/src/modules/websocket.c +++ b/src/modules/websocket.c @@ -95,13 +95,6 @@ MOD_INIT() MOD_LOAD() { - if (SHOWCONNECTINFO) - { - config_warn("I'm disabling set::options::show-connect-info for you " - "as this setting is incompatible with the websocket module."); - SHOWCONNECTINFO = 0; - } - return MOD_SUCCESS; } diff --git a/src/user.c b/src/user.c index 19d977a94..d1062214f 100644 --- a/src/user.c +++ b/src/user.c @@ -639,3 +639,21 @@ int is_handshake_finished(Client *client) return 0; } + +/** Should we show connection info to the user? + * This depends on the set::show-connect-info setting but also + * on various other properties, such as serversonly ports, + * websocket, etc. + * If someone needs it, then we can also call a hook here. Just tell us. + */ +int should_show_connect_info(Client *client) +{ + if (SHOWCONNECTINFO && + !client->serv && + !IsServersOnlyListener(client->local->listener) && + !client->local->listener->websocket_options) + { + return 1; + } + return 0; +}