Add support for userhost-in-names capability

This commit is contained in:
TingPing 2013-10-18 04:40:39 -04:00
parent d960006de4
commit 06a7d84b43
2 changed files with 25 additions and 20 deletions

View File

@ -667,8 +667,10 @@ inbound_nameslist (server *serv, char *chan, char *names,
const message_tags_data *tags_data)
{
session *sess;
char **name_list;
char *host;
char name[NICKLEN];
int pos = 0;
int i, offset;
sess = find_channel (serv, chan);
if (!sess)
@ -687,27 +689,24 @@ inbound_nameslist (server *serv, char *chan, char *names,
userlist_clear (sess);
}
while (1)
name_list = g_strsplit (names, " ", -1);
for (i = 0; name_list[i]; i++)
{
switch (*names)
{
case 0:
name[pos] = 0;
if (pos != 0)
userlist_add (sess, name, 0, NULL, NULL, tags_data);
return;
case ' ':
name[pos] = 0;
pos = 0;
userlist_add (sess, name, 0, NULL, NULL, tags_data);
break;
default:
name[pos] = *names;
if (pos < (NICKLEN-1))
pos++;
}
names++;
host = NULL;
if (name_list[i][0] == 0)
continue;
/* Server may have userhost-in-names cap */
offset = strcspn (name_list[i], "!");
if (offset++ < strlen (name_list[i]))
host = name_list[i] + offset;
g_strlcpy (name, name_list[i], MIN(offset, sizeof(name)));
userlist_add (sess, name, host, NULL, NULL, tags_data);
}
g_strfreev (name_list);
}
void
@ -1673,6 +1672,11 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
strcat (buffer, "extended-join ");
want_cap = 1;
}
if (!strcmp (extension, "userhost-in-names"))
{
strcat (buffer, "userhost-in-names ");
want_cap = 1;
}
/* bouncers can prefix a name space to the extension so we should use.
* znc <= 1.0 uses "znc.in/server-time" and newer use "znc.in/server-time-iso".

View File

@ -163,6 +163,7 @@ userlist_add_hostname (struct session *sess, char *nick, char *hostname,
}
fe_userlist_update (sess, user);
fe_userlist_rehash (sess, user);
return 1;
}