diff options
author | Marius Halden <marius.h@lden.org> | 2017-01-01 21:52:49 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2017-01-01 21:52:49 +0100 |
commit | efaa514039a4b907e2c5c6309295c66b27b1f691 (patch) | |
tree | 55f4962e14be3df95c4168d06a8d1b95ccfb8298 | |
parent | d35affbcea87f453fb20c4bb545a10b668eae81b (diff) | |
parent | 2e8523b30bafa86685655001457a2615936b646a (diff) |
Merge branch 'master' into patched-master
-rw-r--r-- | dcc.c | 2 | ||||
-rw-r--r-- | doc/user-guide/commands.xml | 10 | ||||
-rw-r--r-- | irc_im.c | 7 | ||||
-rw-r--r-- | lib/ftutil.c | 14 | ||||
-rw-r--r-- | lib/ftutil.h | 12 | ||||
-rw-r--r-- | protocols/account.c | 3 | ||||
-rw-r--r-- | protocols/bee_user.c | 10 | ||||
-rw-r--r-- | protocols/jabber/s5bytestream.c | 2 |
8 files changed, 31 insertions, 29 deletions
@@ -91,7 +91,7 @@ file_transfer_t *dccs_send_start(struct im_connection *ic, irc_user_t *iu, const irc_t *irc = (irc_t *) ic->bee->ui_data; struct sockaddr_storage saddr; char *errmsg; - char host[HOST_NAME_MAX]; + char host[NI_MAXHOST]; char port[6]; if (file_size > global.conf->ft_max_size) { diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 91e02ff2..1ddf9764 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1007,19 +1007,23 @@ </description> </bitlbee-setting> - <bitlbee-setting name="handle_unknown" type="string" scope="global"> + <bitlbee-setting name="handle_unknown" type="string" scope="account,global"> <default>add_channel</default> - <possible-values>root, add, add_private, add_channel, ignore</possible-values> + <possible-values>add_private, add_channel, ignore</possible-values> <description> <para> - By default, messages from people who aren't in your contact list are shown in a control channel instead of as a private message. + By default, messages from people who aren't in your contact list are shown in a control channel (add_channel) instead of as a private message (add_private) </para> <para> If you prefer to ignore messages from people you don't know, you can set this one to "ignore". "add_private" and "add_channel" are like add, but you can use them to make messages from unknown buddies appear in the channel instead of a query window. </para> + <para> + This can be set to individual accounts, which is useful to only ignore accounts that are targeted by spammers, without missing messages from legitimate unknown contacts in others. Note that incoming add requests are visible regardless of this setting. + </para> + <note> <para> Although these users will appear in your control channel, they aren't added to your real contact list. When you restart BitlBee, these auto-added users will be gone. If you want to keep someone in your list, you have to fixate the add using the <emphasis>add</emphasis> command. @@ -88,11 +88,12 @@ static gboolean bee_irc_user_new(bee_t *bee, bee_user_t *bu) str_reject_chars(iu->host, " ", '_'); if (bu->flags & BEE_USER_LOCAL) { - char *s = set_getstr(&bee->set, "handle_unknown"); + char *s = set_getstr(&bu->ic->acc->set, "handle_unknown") ? : + set_getstr(&bee->set, "handle_unknown"); - if (strcmp(s, "add_private") == 0) { + if (g_strcasecmp(s, "add_private") == 0) { iu->last_channel = NULL; - } else if (strcmp(s, "add_channel") == 0) { + } else if (g_strcasecmp(s, "add_channel") == 0) { iu->last_channel = irc->default_channel; } } diff --git a/lib/ftutil.c b/lib/ftutil.c index 3c79ba1f..8da88de9 100644 --- a/lib/ftutil.c +++ b/lib/ftutil.c @@ -62,13 +62,13 @@ int ft_listen(struct sockaddr_storage *saddr_ptr, char *host, char *port, int co if (scolon) { if (for_bitlbee_client) { *scolon = '\0'; - strncpy(host, ftlisten, HOST_NAME_MAX); + strncpy(host, ftlisten, NI_MAXHOST); *scolon = ';'; } else { - strncpy(host, scolon + 1, HOST_NAME_MAX); + strncpy(host, scolon + 1, NI_MAXHOST); } } else { - strncpy(host, ftlisten, HOST_NAME_MAX); + strncpy(host, ftlisten, NI_MAXHOST); } if ((colon = strchr(host, ':'))) { @@ -77,13 +77,13 @@ int ft_listen(struct sockaddr_storage *saddr_ptr, char *host, char *port, int co } } else if (copy_fd >= 0 && getsockname(copy_fd, (struct sockaddr*) &saddrs, &ssize) == 0 && (saddrs.ss_family == AF_INET || saddrs.ss_family == AF_INET6) && - getnameinfo((struct sockaddr*) &saddrs, ssize, host, HOST_NAME_MAX, + getnameinfo((struct sockaddr*) &saddrs, ssize, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == 0) { /* We just took our local address on copy_fd, which is likely to be a sensible address from which we can do a file transfer now - the most sensible we can get easily. */ } else { - ASSERTSOCKOP(gethostname(host, HOST_NAME_MAX + 1), "gethostname()"); + ASSERTSOCKOP(gethostname(host, NI_MAXHOST), "gethostname()"); } memset(&hints, 0, sizeof(struct addrinfo)); @@ -108,7 +108,7 @@ int ft_listen(struct sockaddr_storage *saddr_ptr, char *host, char *port, int co if (!inet_ntop(saddr->ss_family, saddr->ss_family == AF_INET ? ( void * ) &(( struct sockaddr_in * ) saddr)->sin_addr.s_addr : ( void * ) &(( struct sockaddr_in6 * ) saddr)->sin6_addr.s6_addr, - host, HOST_NAME_MAX)) { + host, NI_MAXHOST)) { strcpy(errmsg, "inet_ntop failed on listening socket"); return -1; } @@ -127,7 +127,7 @@ int ft_listen(struct sockaddr_storage *saddr_ptr, char *host, char *port, int co } /* I hate static-length strings.. */ - host[HOST_NAME_MAX - 1] = '\0'; + host[NI_MAXHOST - 1] = '\0'; port[5] = '\0'; return fd; diff --git a/lib/ftutil.h b/lib/ftutil.h index d8317b2f..054d6534 100644 --- a/lib/ftutil.h +++ b/lib/ftutil.h @@ -25,17 +25,7 @@ #define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ #endif -/* Some ifdefs for ulibc and apparently also BSD (Thanks to Whoopie) */ -#ifndef HOST_NAME_MAX -#include <sys/param.h> -#ifdef MAXHOSTNAMELEN -#define HOST_NAME_MAX MAXHOSTNAMELEN -#else -#define HOST_NAME_MAX 255 -#endif -#endif - /* This function should be used with care. host should be AT LEAST a - char[HOST_NAME_MAX+1] and port AT LEAST a char[6]. */ + char[NI_MAXHOST+1] and port AT LEAST a char[6]. */ int ft_listen(struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client, char **errptr); diff --git a/protocols/account.c b/protocols/account.c index aa1ffe61..80b1d020 100644 --- a/protocols/account.c +++ b/protocols/account.c @@ -59,6 +59,9 @@ account_t *account_add(bee_t *bee, struct prpl *prpl, char *user, char *pass) s = set_add(&a->set, "auto_reconnect", "true", set_eval_bool, a); + s = set_add(&a->set, "handle_unknown", NULL, NULL, a); + s->flags |= SET_NULL_OK; + s = set_add(&a->set, "nick_format", NULL, NULL, a); s->flags |= SET_NULL_OK; diff --git a/protocols/bee_user.c b/protocols/bee_user.c index ced92ee9..79c99ec9 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -169,10 +169,13 @@ void imcb_buddy_status(struct im_connection *ic, const char *handle, int flags, bee_user_t *bu, *old; if (!(bu = bee_user_by_handle(bee, ic, handle))) { - if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "add") == 0) { + char *h = set_getstr(&ic->acc->set, "handle_unknown") ? : + set_getstr(&ic->bee->set, "handle_unknown"); + + if (g_strncasecmp(h, "add", 3) == 0) { bu = bee_user_new(bee, ic, handle, BEE_USER_LOCAL); } else { - if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "ignore") != 0) { + if (g_strcasecmp(h, "ignore") != 0) { imcb_log(ic, "imcb_buddy_status() for unknown handle %s:\n" "flags = %d, state = %s, message = %s", handle, flags, state ? state : "NULL", message ? message : "NULL"); @@ -254,7 +257,8 @@ void imcb_buddy_msg(struct im_connection *ic, const char *handle, const char *ms bu = bee_user_by_handle(bee, ic, handle); if (!bu && !(ic->flags & OPT_LOGGING_OUT)) { - char *h = set_getstr(&bee->set, "handle_unknown"); + char *h = set_getstr(&ic->acc->set, "handle_unknown") ? : + set_getstr(&ic->bee->set, "handle_unknown"); if (g_strcasecmp(h, "ignore") == 0) { return; diff --git a/protocols/jabber/s5bytestream.c b/protocols/jabber/s5bytestream.c index 9c79de8e..7380d565 100644 --- a/protocols/jabber/s5bytestream.c +++ b/protocols/jabber/s5bytestream.c @@ -887,7 +887,7 @@ void jabber_si_set_proxies(struct bs_transfer *bt) char *proxysetting = g_strdup(set_getstr(&tf->ic->acc->set, "proxy")); char *proxy, *next, *errmsg = NULL; char port[6]; - char host[HOST_NAME_MAX + 1]; + char host[NI_MAXHOST + 1]; jabber_streamhost_t *sh, *sh2; GSList *streamhosts = jd->streamhosts; |