public void Disconnect(string reason = "") { try { disconnected = true; SendKick(reason); if (loggedIn) { Server.s.Log("Remote Console user " + name + " disconnected."); Player.GlobalMessageAdmins("To Admins: Remote Console user &a" + name + Server.DefaultColor + " disconnected."); remotes.Remove(this); } else { Server.s.Log("Remote Console at " + ip + " disconnected."); } RemoteServer.RemoteListUpdate(); } catch (Exception ex) { Server.ErrorLog(ex); } }
public void HandleLogin(byte[] message) { try { if (loggedIn) { return; } byte version = message[0]; username = enc.GetString(message, 1, 64).Trim(); password = enc.GetString(message, 65, 64).Trim(); string key = enc.GetString(message, 129, 64).Trim(); name = enc.GetString(message, 193, 64).Trim(); if (String.IsNullOrEmpty(name)) { name = "Alive"; } loggedIn = true; if (version != RemoteServer.rcProtocolVersion) { Disconnect("Wrong Protocol Version!"); return; } if (key != Hash(RemoteServer.rcpass)) { Disconnect("Wrong server password!"); return; } int found = 0; foreach (RemoteServer.User ru in RemoteServer.rcusers) { if (ru.name.ToLower() == username.ToLower()) { found++; if (Hash(ru.password) != password.ToLower()) { Disconnect("Wrong user password!"); return; } } } if (found <= 0 || found > 1) { Disconnect("Remote user not found."); return; } foreach (Remote r in remotes) { if (r.name.ToLower().Trim() == name.ToLower().Trim()) { Disconnect("Already logged in!"); return; } } remotes.Add(this); RemoteServer.RemoteListUpdate(); if (!Server.useMaxMind) { Server.s.Log("Remote Console user " + name + " connected."); Player.GlobalMessageAdmins("To Admins: Remote Console user &a" + name + "&g connected."); } else { Server.s.Log("Remote Console user " + name + " connected from " + Server.iploopup.getCountry(IPAddress.Parse(ip)).getName() + "."); Player.GlobalMessageAdmins("To Admins: Remote Console user &a" + name + "&g connected from " + Server.iploopup.getCountry(IPAddress.Parse(ip)).getName() + "."); } Server.s.OnLog += SendMessage; Server.s.OnCommand += SendMessage; Server.s.OnError += SendMessage; SendMessage("Remote Console connected!"); } catch (Exception ex) { Server.ErrorLog(ex); } }