Exemplo n.º 1
0
        private void btnAddToWhitelist_Click(object sender, EventArgs e)
        {
            DayzClient client = new DayzClient();

            client.UserName = txtNewName.Text;
            client.email    = txtNewEmail.Text;
            client.GUID     = txtNewGUID.Text;

            parentForm.addPlayer(client);

            lblResult.Text = client.UserName + " added to whitelist.";

            txtNewName.Text  = "";
            txtNewEmail.Text = "";
            txtNewGUID.Text  = "";

            client = null;
        }
Exemplo n.º 2
0
        private void WelcomeMessage(DayzClient client)
        {
            if (showWelcomeMsg == true)
            {
                b.SendCommandPacket(EBattlEyeCommand.Say, string.Format("-1 Welcome: {0}", client.UserName));
            }

            this.rtbDisplay.AppendText(string.Format(" Verified Player {0}: {1} - {2}\n", client.playerNo.ToString(), client.GUID.ToString(), client.UserName.ToString()));
        }
Exemplo n.º 3
0
        private void LogPlayer(DayzClient client)
        {
            // call insert to log function
            string connStr = string.Format("server={0};user={1};database={2};port={3};password={4};", dbHost, dbUser, dbDatabase, dbPort, dbPassword);

            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)
            {
                this.rtbDisplay.AppendText(ex.ToString());
            }
            finally
            {
                conn.Close();
                conn = null;
                cmd = null;
            }
        }
Exemplo n.º 4
0
 private void KickPlayer(DayzClient client)
 {
     if (whiteListEnabled == true)
     {
         b.SendCommandPacket(EBattlEyeCommand.Kick, string.Format(@"{0} not whitelisted! Signup @ {1}", client.playerNo.ToString(), serverURL));
         this.rtbDisplay.AppendText(string.Format(" Kicked Player {0} : {1} - {2}\n", client.playerNo.ToString(), client.GUID.ToString(), client.UserName.ToString()));
     }
     else if (addNewPlayersWhenDisabled == true)
     {
         addPlayer(client);
     }
 }
Exemplo n.º 5
0
        private void doDumpMessage(String msg)
        {
            setTextColor(msg);

            if (this.rtbDisplay.InvokeRequired)
            {
                DumpMessageCallback d = new DumpMessageCallback(doDumpMessage);
                this.Invoke(d, new object[] { msg });
            }
            else
            {
                // Show chat messages if enabled
                if (showChat == true)
                {
                    this.rtbDisplay.AppendText(msg, bgcolor);
                }

                try
                {
                    Match matchString;

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

                        client.GUID = matchString.Groups["guid"].Value.Trim();
                        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);
                                //addPlayer(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;

                        //Console.WriteLine(matchString.Groups["player_id"].Value + "*" + matchString.Groups["guid"].Value + "*" + matchString.Groups["user"].Value);
                    }
                }
                catch (Exception ex)
                {
                    // do nothing
                }

            }
        }
Exemplo n.º 6
0
        /* WHITELIST FUNCTIONS */
        private static bool VerifyWhiteList(DayzClient client)
        {
            bool returnVal = false;

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

            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.º 7
0
        public void removePlayer(DayzClient client)
        {
            // call insert to log function
            string connStr = string.Format("server={0};user={1};database={2};port={3};password={4};", dbHost, dbUser, dbDatabase, dbPort, dbPassword);

            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_SetWhitelistedStatus";

                cmd.Parameters.Add(new MySqlParameter("p_GUID", client.GUID));
                cmd.Parameters.Add(new MySqlParameter("p_whitelisted", 0));

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                this.rtbDisplay.AppendText(ex.ToString());
            }
            finally
            {
                conn.Close();
                conn = null;
                cmd = null;
            }
            this.rtbDisplay.AppendText(string.Format(" Removed Player from whitelist - {0}\n", client.GUID.ToString()));
        }