void OnPlayerDataReceived(ref HookContext ctx, ref HookArgs.PlayerDataReceived args) { ctx.SetKick("Malfunction during login process, try again."); if (!args.NameChecked) { string error; if (!args.CheckName(out error)) { ctx.SetKick(error); return; } } var player = ctx.Player; if (player == null) { ProgramLog.Error.Log("Null player passed to Restrict.OnPlayerDataReceived."); return; } var name = args.Name; var pname = NameTransform(name); var oname = OldNameTransform(name); string entry = null; lock (users) { entry = users.getValue(pname) ?? users.getValue(oname); } if (entry == null) { if (allowGuests) { ctx.SetResult(HookResult.DEFAULT); player.AuthenticatedAs = null; ctx.Connection.DesiredQueue = 0; //(int)LoginPriority.QUEUE_LOW_PRIO; ProgramLog.Log("<Restrict> Letting user {0} from {1} in as guest.", name, player.IPAddress); } else { ProgramLog.Log("<Restrict> Unregistered user {0} from {1} attempted to connect.", name, player.IPAddress); ctx.SetKick("Only registered users are allowed."); return; } return; } ProgramLog.Log("<Restrict> Expecting password for user {0} from {1}.", name, player.IPAddress); ctx.SetResult(HookResult.ASK_PASS); }
void OnInventoryItemReceived(ref HookContext ctx, ref HookArgs.InventoryItemReceived args) { #if TDSMSever if (Server.ItemRejections.Count > 0) { if (args.Item != null) { if (Server.ItemRejections.Contains(args.Item.name) || Server.ItemRejections.Contains(args.Item.type.ToString())) { if (!String.IsNullOrEmpty(args.Item.name)) { ctx.SetKick(args.Item.name + " is not allowed on this server."); } else { ctx.SetKick("Item type " + args.Item.type.ToString() + " is not allowed on this server."); } } } } #endif }
void OnPlayerDataReceived(ref HookContext ctx, ref TDSMHookArgs.PlayerDataReceived args) { // //If the player is not authenticated, then ensure they are reset // if (!AllowSSCGuestInfo && !ctx.Player.IsAuthenticated) // { // // } if (Config.WhitelistEnabled) { var name = WhiteListCommand.Prefix_WhitelistName + args.Name; var ip = WhiteListCommand.Prefix_WhitelistIp + ctx.Client.RemoteIPAddress(); if (!Whitelist.Contains(name) && !Whitelist.Contains(ip)) { ctx.SetKick(args.Name + ", You are not whitelisted"); } } }
void OnPlayerPassReceived(ref HookContext ctx, ref HookArgs.PlayerPassReceived args) { ctx.SetKick("Malfunction during login process, try again."); var player = ctx.Player; if (player == null) { ProgramLog.Error.Log("Null player passed to Restrict.OnPlayerPassReceived."); return; } var name = player.Name; var pname = NameTransform(name); var oname = OldNameTransform(name); string entry = null; lock (users) { entry = users.getValue(pname) ?? users.getValue(oname); } if (entry == null) { if (allowGuests) { ctx.SetResult(HookResult.DEFAULT); player.AuthenticatedAs = null; ctx.Connection.DesiredQueue = 0; } else { ctx.SetKick("Only registered users are allowed."); } return; } var split = entry.Split(':'); var hash = split[0]; var hash2 = Hash(name, args.Password); String.Format("User: {0}, Pass: {1}, Hash: {3}, Hash2: {2}", name, args.Password, hash2, hash); if (hash != hash2) { ctx.SetKick("Incorrect password for user: "******"op") { player.Op = true; ctx.Connection.DesiredQueue = 3; } else { ctx.Connection.DesiredQueue = 1; } player.AuthenticatedAs = name; ctx.SetResult(HookResult.DEFAULT); }