From be1286835c016ed2602db8e42f7ca0b367767242 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 30 Oct 2007 22:49:46 +0000 Subject: Add support for nick@server requested by many. We are not likely to backport this, cant actually find reference to it in rfc1459 git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8424 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/commands/cmd_notice.cpp | 23 +++++++++++++++++++++-- src/commands/cmd_privmsg.cpp | 23 +++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index 937feaf93..ca693d62b 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -120,10 +120,29 @@ CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) return CMD_SUCCESS; } + const char* destnick = parameters[0]; + if (IS_LOCAL(user)) - dest = ServerInstance->FindNickOnly(parameters[0]); + { + const char* targetserver = strchr(destnick, '@'); + + if (targetserver) + { + char nickonly[NICKMAX+1]; + strlcpy(nickonly, destnick, targetserver - destnick + 1); + dest = ServerInstance->FindNickOnly(nickonly); + if (dest && strcasecmp(dest->server, targetserver + 1)) + { + /* Incorrect server for user */ + user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; + } + } + else + dest = ServerInstance->FindNickOnly(destnick); + } else - dest = ServerInstance->FindNick(parameters[0]); + dest = ServerInstance->FindNick(destnick); if (dest) { diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index 474eb4b3d..5be9d4cff 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -121,10 +121,29 @@ CmdResult CommandPrivmsg::Handle (const char** parameters, int pcnt, User *user) return CMD_SUCCESS; } + const char* destnick = parameters[0]; + if (IS_LOCAL(user)) - dest = ServerInstance->FindNickOnly(parameters[0]); + { + const char* targetserver = strchr(destnick, '@'); + + if (targetserver) + { + char nickonly[NICKMAX+1]; + strlcpy(nickonly, destnick, targetserver - destnick + 1); + dest = ServerInstance->FindNickOnly(nickonly); + if (dest && strcasecmp(dest->server, targetserver + 1)) + { + /* Incorrect server for user */ + user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; + } + } + else + dest = ServerInstance->FindNickOnly(destnick); + } else - dest = ServerInstance->FindNick(parameters[0]); + dest = ServerInstance->FindNick(destnick); if (dest) { -- cgit v1.2.3