public override void Parse(string[] spaceSplit, string[] colonSplit, string fullRow) { if (spaceSplit.Count() == 4) { //Nick Change var nickChangeUser = Service.GetUser(spaceSplit[0]) as User; if (nickChangeUser == null) { Service.AddLog("Nick change from unknown user " + spaceSplit[0]); return; } string newnick = spaceSplit[2]; if (Service.NickExists(newnick)) { Service.AddLog("Nick " + newnick + " already exists"); return; } nickChangeUser.Nick = newnick; Service.SendActionToPlugins( p => p.OnUserChangeNick(nickChangeUser), nickChangeUser.Plugin ); } spaceSplit = colonSplit[0].Split(' '); if (spaceSplit.Count() < 8) { return; } Server server = Service.GetServer(spaceSplit[0]); if (server == null) { Service.AddLog("N from unknown server " + spaceSplit[0]); return; } string userNumeric = spaceSplit[spaceSplit.Count() - 2]; if (server.ContainsNumeric(userNumeric)) { Service.AddLog("Numeric collision: client " + userNumeric + " already exists on " + server.Name); return; } if (Service.NickExists(spaceSplit[2])) { Service.AddLog("Nick collision: " + spaceSplit[2]); return; } string userName = StringHelper.JoinArray(colonSplit, ":", 1); User user = new User(server, userNumeric, spaceSplit[2], spaceSplit[5], spaceSplit[6], userName, new UnixTimestamp(Convert.ToInt32(spaceSplit[4])), spaceSplit[spaceSplit.Count() - 3]); if (spaceSplit[7][0] == '+') { if (spaceSplit[7].Contains('o')) { user.IsOper = true; } if (spaceSplit[7].Contains('k')) { user.IsService = true; } int nextdata = 8; if (spaceSplit[7].Contains('r')) { user.Login = spaceSplit[nextdata]; nextdata += 1; } if (spaceSplit[7].Contains('h')) { string[] fakeIH = spaceSplit[nextdata].Split('@'); if (fakeIH.Count() > 1) { user.FakeIdent = fakeIH[0]; user.FakeHost = fakeIH[1]; } } } server.AddUser(user); if (Service.Status == ServiceStatus.BurstCompleted) { Service.SendActionToPlugins(p => p.OnNewUser(user)); } }
/// <summary> /// Checks if the ban matches a user /// </summary> /// <param name="user"></param> /// <returns>TRUE if the ban matches the user</returns> public bool Match(User user) { bool nickMatch = WildCardHelper.WildCardMatch(Nick, user.Nick); bool identMatch = WildCardHelper.WildCardMatch(Ident, user.Ident); bool hostMatch = WildCardHelper.WildCardMatch(Host, user.Host); if (nickMatch) { if ( ! identMatch) { if (user.FakeIdent.Length > 0) { identMatch = WildCardHelper.WildCardMatch(Ident, user.FakeIdent); } } if (identMatch) { if ( ! hostMatch) { if (user.FakeHost.Length > 0) { hostMatch = WildCardHelper.WildCardMatch(Host, user.FakeHost); } if ( ! hostMatch) { hostMatch = WildCardHelper.WildCardMatch( Host, user.IP.ToString() ); } if ( ! hostMatch && user.Login.Length > 0) { hostMatch = WildCardHelper.WildCardMatch( Host, user.LoginHostString ); } } } } if (nickMatch == true && identMatch == true && hostMatch == true) { return true; } return false; }
/// <summary> /// Default constructor /// </summary> /// <param name="user"></param> public UserAction(IUser user) { if (user == null) { throw new ArgumentNullException("User"); } User = user as User; Server = user.Server; Plugin = user.Plugin; CheckPlugin(); }
/// <summary> /// Creates and adds a new user to the network /// </summary> /// <param name="server"></param> /// <param name="nick"></param> /// <param name="ident"></param> /// <param name="host"></param> /// <param name="name"></param> /// <param name="IP"></param> /// <returns>The new user if it is successfully created and added /// or null if not</returns> public IUser CreateUser(IServer server, string nick, string ident, string host, string name, IPAddress IP) { lock (lockObject) { if (server == null) { return null; } if (Service.NickExists(nick)) { return null; } var newUser = new User(server, FindFreeNumeric(server), nick, ident, host, name, UnixTimestamp.CurrentTimestamp(), IP, this); if (newUser == null) { return null; } (server as Server).AddUser(newUser); if (Service.BurstCompleted) { var command = Service.CommandFactory.CreateNewUserCommand(); command.User = newUser; Service.SendCommand(command, false); Service.SendActionToPlugins(p => p.OnNewUser(newUser), this); } return newUser; } }