diff options
-rw-r--r-- | src/commands/cmd_notice.cpp | 23 | ||||
-rw-r--r-- | src/commands/cmd_privmsg.cpp | 23 |
2 files changed, 42 insertions, 4 deletions
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) { |