X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-metadata.c;h=2a3de1b454cbba48cb0cbe6739f5f49a3350c801;hb=dc6807338e240d8093f43337dab7bfe488c35c4a;hp=5cef8333792cf612f4a4d7f0ca6803bf3796c25b;hpb=35ed57e6c160dc13c2bbca2ca042406285d4ced3;p=ngircd-alex.git diff --git a/src/ngircd/irc-metadata.c b/src/ngircd/irc-metadata.c index 5cef8333..2a3de1b4 100644 --- a/src/ngircd/irc-metadata.c +++ b/src/ngircd/irc-metadata.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors. + * Copyright (c)2001-2015 Alexander Barton (alex@barton.de) and Contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,21 +18,18 @@ * IRC metadata commands */ -#include "imp.h" #include -#include +#include #include #include "conn-func.h" #include "channel.h" -#include "conn-encoding.h" +#include "irc-macros.h" #include "irc-write.h" #include "log.h" #include "messages.h" #include "parse.h" -#include "tool.h" -#include "exp.h" #include "irc-metadata.h" /** @@ -51,43 +48,60 @@ IRC_METADATA(CLIENT *Client, REQUEST *Req) assert(Client != NULL); assert(Req != NULL); - if (Req->argc != 3) - return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, - Client_ID(Client), Req->command); + _IRC_REQUIRE_PREFIX_OR_RETURN_(Client, Req) prefix = Client_Search(Req->prefix); if (!prefix) - return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, + return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->prefix); target = Client_Search(Req->argv[0]); if (!target) - return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, + return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->argv[0]); LogDebug("Got \"METADATA\" command from \"%s\" for client \"%s\": \"%s=%s\".", - Client_ID(Client), Client_ID(target), + Client_ID(prefix), Client_ID(target), Req->argv[1], Req->argv[2]); - /* Mark client: it has receiveda a METADATA command */ - if (!strchr(Client_Flags(target), 'M')) { + /* Mark client: it has received a METADATA command */ + if (!Client_HasFlag(target, 'M')) { snprintf(new_flags, sizeof new_flags, "%sM", Client_Flags(target)); Client_SetFlags(target, new_flags); } - if (*Req->argv[2] && strcasecmp(Req->argv[1], "host") == 0) + if (strcasecmp(Req->argv[1], "cloakhost") == 0) { + Client_UpdateCloakedHostname(target, prefix, Req->argv[2]); + if (Client_Conn(target) > NONE && Client_HasMode(target, 'x')) + IRC_WriteStrClientPrefix(target, prefix, + RPL_HOSTHIDDEN_MSG, Client_ID(target), + Client_HostnameDisplayed(target)); + /* The Client_UpdateCloakedHostname() function already + * forwarded the METADATA command, don't do it twice: */ + return CONNECTED; + } + else if (*Req->argv[2] && strcasecmp(Req->argv[1], "host") == 0) { Client_SetHostname(target, Req->argv[2]); - else if (strcasecmp(Req->argv[1], "info") == 0) + if (Client_Conn(target) > NONE && !Client_HasMode(target, 'x')) + IRC_WriteStrClientPrefix(target, prefix, + RPL_HOSTHIDDEN_MSG, Client_ID(target), + Client_HostnameDisplayed(target)); + } else if (strcasecmp(Req->argv[1], "info") == 0) Client_SetInfo(target, Req->argv[2]); else if (*Req->argv[2] && strcasecmp(Req->argv[1], "user") == 0) Client_SetUser(target, Req->argv[2], true); + else if (strcasecmp(Req->argv[1], "accountname") == 0) + Client_SetAccountName(target, Req->argv[2]); + else if (*Req->argv[2] && strcasecmp(Req->argv[1], "certfp") == 0) + Conn_SetCertFp(Client_Conn(target), Req->argv[2]); else Log(LOG_WARNING, "Ignored metadata update from \"%s\" for client \"%s\": \"%s=%s\" - unknown key!", Client_ID(Client), Client_ID(target), Req->argv[1], Req->argv[2]); + /* Forward the METADATA command to peers that support it: */ IRC_WriteStrServersPrefixFlag(Client, prefix, 'M', "METADATA %s %s :%s", Client_ID(target), Req->argv[1], Req->argv[2]); return CONNECTED;