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) const message_tags_data *tags_data)
{ {
session *sess; session *sess;
char **name_list;
char *host;
char name[NICKLEN]; char name[NICKLEN];
int pos = 0; int i, offset;
sess = find_channel (serv, chan); sess = find_channel (serv, chan);
if (!sess) if (!sess)
@ -687,27 +689,24 @@ inbound_nameslist (server *serv, char *chan, char *names,
userlist_clear (sess); userlist_clear (sess);
} }
while (1) name_list = g_strsplit (names, " ", -1);
for (i = 0; name_list[i]; i++)
{ {
switch (*names) host = NULL;
{
case 0: if (name_list[i][0] == 0)
name[pos] = 0; continue;
if (pos != 0)
userlist_add (sess, name, 0, NULL, NULL, tags_data); /* Server may have userhost-in-names cap */
return; offset = strcspn (name_list[i], "!");
case ' ': if (offset++ < strlen (name_list[i]))
name[pos] = 0; host = name_list[i] + offset;
pos = 0;
userlist_add (sess, name, 0, NULL, NULL, tags_data); g_strlcpy (name, name_list[i], MIN(offset, sizeof(name)));
break;
default: userlist_add (sess, name, host, NULL, NULL, tags_data);
name[pos] = *names;
if (pos < (NICKLEN-1))
pos++;
}
names++;
} }
g_strfreev (name_list);
} }
void void
@ -1673,6 +1672,11 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
strcat (buffer, "extended-join "); strcat (buffer, "extended-join ");
want_cap = 1; 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. /* 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". * 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_update (sess, user);
fe_userlist_rehash (sess, user);
return 1; return 1;
} }