Exemplo n.º 1
0
        private static void LogPlayer(DayzClient client)
        {
            // call insert to log function
            string connStr = string.Format("server={0};user={1};database={2};port={3};password={4};", dzwlSettings.dbHost, dzwlSettings.dbUser, dzwlSettings.dbDatabase, dzwlSettings.dbPort, dzwlSettings.dbPass);

            MySqlConnection conn = new MySqlConnection(connStr);
            MySqlCommand    cmd  = new MySqlCommand();

            string queryString = string.Format("call proc_CheckWhiteList('{0}')", client.GUID);

            try
            {
                conn.Open();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "proc_LogWhiteList";

                cmd.Parameters.Add(new MySqlParameter("p_name", client.UserName));
                cmd.Parameters.Add(new MySqlParameter("p_GUID", client.GUID));
                cmd.Parameters.Add(new MySqlParameter("p_logtype", Convert.ToInt32(client.logType)));

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                conn.Close();
                conn = null;
                cmd  = null;
            }
        }
Exemplo n.º 2
0
 private static void KickPlayer(DayzClient client)
 {
     if (dzwlSettings.beWhiteListEnabled == true)
     {
         b.SendCommandPacket(EBattlEyeCommand.Kick, string.Format(@"{0} Client not whitelisted! Visit {1} for whitelisting", client.playerNo.ToString(), dzwlSettings.URL));
     }
     Console.WriteLine(string.Format("Kicked Player {0} : {1} - {2}", client.playerNo.ToString(), client.GUID.ToString(), client.UserName.ToString()));
 }
Exemplo n.º 3
0
        private static void WelcomeMessage(DayzClient client)
        {
            if (dzwlSettings.WelcomeMessageEnabled == true)
            {
                b.SendCommandPacket(EBattlEyeCommand.Say, string.Format("-1 Welcome: {0}", client.UserName));
            }

            Console.WriteLine(string.Format("Verified Player {0}: {1} - {2}", client.playerNo.ToString(), client.GUID.ToString(), client.UserName.ToString()));
        }
Exemplo n.º 4
0
        private static void DumpMessage(BattlEyeMessageEventArgs args)
        {
            // echo message to console
            //Console.WriteLine(args.Message);

            try
            {
                Match matchString;

                // Grab the user data if it matches our regular expresion - Thanks to mmmmk for this Regex!
                matchString = Regex.Match(args.Message, @"Player #(?<player_id>[0-9]{1,3})\s(?<user>.+) - GUID: (?<guid>.+)\W\D\S", RegexOptions.IgnoreCase);
                if (matchString.Success)
                {
                    // new client obj
                    DayzClient client = new DayzClient();

                    client.GUID     = matchString.Groups["guid"].Value.Trim(); // thanks DeanHyde
                    client.playerNo = Convert.ToInt32(matchString.Groups["player_id"].Value);
                    client.UserName = matchString.Groups["user"].Value;

                    // did we get a valid result? verify
                    if (client.GUID != null && client.UserName != null)
                    {
                        if (VerifyWhiteList(client) == false)
                        {
                            // user is not white listed kick and send message
                            KickPlayer(client);

                            // log event
                            client.logType = DayzClient.LogTypes.Kick;
                            LogPlayer(client);
                        }
                        else
                        {
                            // display welcome message
                            WelcomeMessage(client);

                            // log event
                            client.logType = DayzClient.LogTypes.Success;
                            LogPlayer(client);
                        }
                    }

                    // destroy client obj
                    client = null;
                }
            }
            catch (Exception ex)
            {
                // do nothing
            }
        }
Exemplo n.º 5
0
        private static bool VerifyWhiteList(DayzClient client)
        {
            bool returnVal = false;

            string connStr = string.Format("server={0};user={1};database={2};port={3};password={4};", dzwlSettings.dbHost, dzwlSettings.dbUser, dzwlSettings.dbDatabase, dzwlSettings.dbPort, dzwlSettings.dbPass);

            MySqlConnection conn = new MySqlConnection(connStr);
            MySqlCommand    cmd  = new MySqlCommand();
            MySqlDataReader rdr  = null;

            try
            {
                conn.Open();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "proc_CheckWhiteList";

                cmd.Parameters.Add(new MySqlParameter("p_guid", client.GUID));

                rdr = cmd.ExecuteReader();

                if (rdr.HasRows == true)
                {
                    returnVal = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                rdr.Close();
                conn.Close();
                rdr  = null;
                conn = null;
                cmd  = null;
            }
            return(returnVal);
        }
Exemplo n.º 6
0
 private static void WelcomeMessage(DayzClient client)
 {
     if (dzwlSettings.beWhiteListEnabled == true)
     {
         Console.WriteLine(string.Format("Verified Player {0}: {1}", client.playerNo.ToString(), client.GUID.ToString()));
     }
 }
Exemplo n.º 7
0
        private static bool VerifyWhiteList(DayzClient client)
        {
            bool returnVal = false;

            string connStr = string.Format("server={0};user={1};database={2};port={3};password={4};", dzwlSettings.dbHost, dzwlSettings.dbUser, dzwlSettings.dbDatabase, dzwlSettings.dbPort, dzwlSettings.dbPass);

            MySqlConnection conn = new MySqlConnection(connStr);
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataReader rdr = null;

            try
            {
                conn.Open();
                cmd.Connection = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "proc_CheckWhiteList";

                cmd.Parameters.Add(new MySqlParameter("p_guid", client.GUID));

                rdr = cmd.ExecuteReader();

                if (rdr.HasRows == true)
                {
                    returnVal = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                rdr.Close();
                conn.Close();
                rdr = null;
                conn = null;
                cmd = null;

            }
            return returnVal;
        }
Exemplo n.º 8
0
        private static void LogPlayer(DayzClient client)
        {
            // call insert to log function
            string connStr = string.Format("server={0};user={1};database={2};port={3};password={4};", dzwlSettings.dbHost, dzwlSettings.dbUser, dzwlSettings.dbDatabase, dzwlSettings.dbPort, dzwlSettings.dbPass);

            MySqlConnection conn = new MySqlConnection(connStr);
            MySqlCommand cmd = new MySqlCommand();

            string queryString = string.Format("call proc_CheckWhiteList('{0}')", client.GUID);

            try
            {
                conn.Open();
                cmd.Connection = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "proc_LogWhiteList";

                cmd.Parameters.Add(new MySqlParameter("p_name", client.UserName));
                cmd.Parameters.Add(new MySqlParameter("p_GUID", client.GUID));
                cmd.Parameters.Add(new MySqlParameter("p_logtype", Convert.ToInt32(client.logType)));

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                conn.Close();
                conn = null;
                cmd = null;
            }
        }
Exemplo n.º 9
0
 private static void KickPlayer(DayzClient client)
 {
     if (dzwlSettings.beWhiteListEnabled == true)
     {
         b.SendCommandPacket(EBattlEyeCommand.Kick, string.Format(@"{0} Client not whitelisted! Visit {1} for whitelisting", client.playerNo.ToString(), dzwlSettings.URL));
         Console.WriteLine(string.Format("Kicked Player {0}", client.playerNo.ToString()));
     }
 }
Exemplo n.º 10
0
        private static void DumpMessage(BattlEyeMessageEventArgs args)
        {
            // new clien tobj
            DayzClient client = new DayzClient();

            // echo message to console
            Console.WriteLine(args.Message);

            try
            {
                Match matchString;

                // Grab the user data if it matches our regular expresion - Thanks to mmmmmkay for this Regex!
                matchString = Regex.Match(args.Message, @"Verified GUID\s\W(?<guid>.+)\W\sof player #(?<player_id>[0-9]{1,3})\s(?<user>.+)", RegexOptions.IgnoreCase);
                if (matchString.Success)
                {
                    client.GUID = matchString.Groups["guid"].Value;
                    client.playerNo = Convert.ToInt32(matchString.Groups["player_id"].Value);
                    client.UserName = matchString.Groups["user"].Value;

                    // did we get a valid result? verify
                    if (client.GUID != null && client.UserName != null)
                    {
                        if (VerifyWhiteList(client) == false)
                        {
                            // user is not white listed kick and send message
                            KickPlayer(client);

                            // log event
                            client.logType = DayzClient.LogTypes.Kick;
                            LogPlayer(client);
                        }
                        else
                        {
                            // display welcome message
                            WelcomeMessage(client);

                            // log event;
                            client.logType = DayzClient.LogTypes.Success;
                            LogPlayer(client);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // do nothing
            }
            finally
            {
                client = null;
            }
        }
Exemplo n.º 11
0
        private static void WelcomeMessage(DayzClient client)
        {
            if (dzwlSettings.WelcomeMessageEnabled == true)
            {
                b.SendCommandPacket(EBattlEyeCommand.Say, string.Format("-1 Welcome: {0}", client.UserName));
            }

                Console.WriteLine(string.Format("Verified Player {0}: {1} - {2}", client.playerNo.ToString(), client.GUID.ToString(), client.UserName.ToString()));
        }