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.
This commit is contained in:
Bram Matthys 2019-10-06 07:37:55 +02:00
parent ba7ff01e0f
commit d2a93c3a03
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98
5 changed files with 26 additions and 20 deletions

View file

@ -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);

View file

@ -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))

View file

@ -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)

View file

@ -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;
}

View file

@ -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;
}