Ejemplo n.º 1
0
        protected void OnPunkbusterMessage(FrostbiteClient sender, string strPunkbusterMessage) {

            strPunkbusterMessage = strPunkbusterMessage.TrimEnd('\r', '\n');

            // PunkBuster Server: ([0-9]+)[ ]? ([A-Za-z0-9]+)\(.*?\) ([0-9\.:]+).*?\(.*?\) "(.*?)"
            // PunkBuster Server: 1  2c90591ce08a5f799622705d7ba1155c(-) 192.168.1.3:52460 OK   1 3.0 0 (W) "(U3)Phogue"
            //Match mMatch = Regex.Match(strPunkbusterMessage, @":[ ]+?(?<slotid>[0-9]+)[ ]+?(?<guid>[A-Za-z0-9]+)\(.*?\)[ ]+?(?<ip>[0-9\.:]+).*?\(.*?\)[ ]+?""(?<name>.*?)\""", RegexOptions.IgnoreCase);
            Match mMatch = this.Parent.RegexMatchPunkbusterPlist.Match(strPunkbusterMessage);
            // If it is a punkbuster pb_plist update
            if (mMatch.Success == true && mMatch.Groups.Count >= 5) {

                CPunkbusterInfo newPbInfo = new CPunkbusterInfo(mMatch.Groups["slotid"].Value, mMatch.Groups["name"].Value, mMatch.Groups["guid"].Value, mMatch.Groups["ip"].Value, this.Parent.GetCountryName(mMatch.Groups["ip"].Value), this.Parent.GetCountryCode(mMatch.Groups["ip"].Value));

                if (this.PunkbusterPlayerInfo != null) {
                    FrostbiteConnection.RaiseEvent(this.PunkbusterPlayerInfo.GetInvocationList(), this, newPbInfo);
                }
            }

            mMatch = this.Parent.RegexMatchPunkbusterBeginPlist.Match(strPunkbusterMessage);
            if (mMatch.Success == true && this.PunkbusterBeginPlayerInfo != null) {
                FrostbiteConnection.RaiseEvent(this.PunkbusterBeginPlayerInfo.GetInvocationList(), this);
            }

            mMatch = this.Parent.RegexMatchPunkbusterEndPlist.Match(strPunkbusterMessage);
            if (mMatch.Success == true && this.PunkbusterEndPlayerInfo != null) {
                FrostbiteConnection.RaiseEvent(this.PunkbusterEndPlayerInfo.GetInvocationList(), this);
            }

            // PunkBuster Server: Player Guid Computed ([A-Za-z0-9]+)\(.*?\) \(slot #([0-9]+)\) ([0-9\.:]+) (.*)
            // PunkBuster Server: Player Guid Computed 2c90591ce08a5f799622705d7ba1155c(-) (slot #1) 192.168.1.3:52581 (U3)Phogue
            //mMatch = Regex.Match(strPunkbusterMessage, @": Player Guid Computed[ ]+?(?<guid>[A-Za-z0-9]+)\(.*?\)[ ]+?\(slot #(?<slotid>[0-9]+)\)[ ]+?(?<ip>[0-9\.:]+)[ ]+?(?<name>.*)", RegexOptions.IgnoreCase);
            mMatch = this.Parent.RegexMatchPunkbusterGuidComputed.Match(strPunkbusterMessage);
            // If it is a new connection, technically its a resolved guid type command but stil..
            if (mMatch.Success == true && mMatch.Groups.Count >= 5) {

                CPunkbusterInfo newPbInfo = new CPunkbusterInfo(mMatch.Groups["slotid"].Value, mMatch.Groups["name"].Value, mMatch.Groups["guid"].Value, mMatch.Groups["ip"].Value, this.Parent.GetCountryName(mMatch.Groups["ip"].Value), this.Parent.GetCountryCode(mMatch.Groups["ip"].Value));

                if (this.PunkbusterPlayerInfo != null) {
                    FrostbiteConnection.RaiseEvent(this.PunkbusterPlayerInfo.GetInvocationList(), this, newPbInfo);
                }
            }

            //mMatch = Regex.Match(strPunkbusterMessage, @":[ ]+?(?<banid>[0-9]+)[ ]+?(?<guid>[A-Za-z0-9]+)[ ]+?{(?<remaining>[0-9\-]+)/(?<banlength>[0-9\-]+)}[ ]+?""(?<name>.+?)""[ ]+?""(?<ip>.+?)""[ ]+?(?<reason>.*)", RegexOptions.IgnoreCase);
            mMatch = this.Parent.RegexMatchPunkbusterBanlist.Match(strPunkbusterMessage);
            if (mMatch.Success == true && mMatch.Groups.Count >= 5) {

                //IPAddress ipOut;
                string strIP = String.Empty;
                string[] a_strIP;

                if (mMatch.Groups["ip"].Value.Length > 0 && (a_strIP = mMatch.Groups["ip"].Value.Split(':')).Length > 0) {
                    strIP = a_strIP[0];
                }

                CBanInfo newPbBanInfo = new CBanInfo(mMatch.Groups["name"].Value, mMatch.Groups["guid"].Value, mMatch.Groups["ip"].Value, new TimeoutSubset(mMatch.Groups["banlength"].Value, mMatch.Groups["remaining"].Value), mMatch.Groups["reason"].Value);

                if (this.PunkbusterPlayerBanned != null) {
                    FrostbiteConnection.RaiseEvent(this.PunkbusterPlayerBanned.GetInvocationList(), this, newPbBanInfo);
                }
            }
            
            //PunkBuster Server: Kick/Ban Command Issued (testing) for (slot#1) xxx.xxx.xxx.xxx:yyyy GUID name
            mMatch = this.Parent.RegexMatchPunkbusterKickBanCmd.Match(strPunkbusterMessage);
            if (mMatch.Success == true && mMatch.Groups.Count >= 5)
            {
                //IPAddress ipOut;
                string strIP = String.Empty;
                string[] a_strIP;

                if (mMatch.Groups["ip"].Value.Length > 0 && (a_strIP = mMatch.Groups["ip"].Value.Split(':')).Length > 0)
                {
                    strIP = a_strIP[0];
                }

                TimeoutSubset kb_timeoutSubset;
                if (String.Compare(mMatch.Groups["kb_type"].ToString(), "Kick/Ban", true) == 0) {
                    kb_timeoutSubset = new TimeoutSubset(new List<string>() { "perm", "" });
                }
                else {
                    kb_timeoutSubset = new TimeoutSubset(new List<string>() { "seconds", "120" });
                }

                //CBanInfo newPbBanInfo = new CBanInfo(mMatch.Groups["name"].Value, mMatch.Groups["guid"].Value, mMatch.Groups["ip"].Value, new TimeoutSubset("perm",""), mMatch.Groups["reason"].Value);
                CBanInfo newPbBanInfo = new CBanInfo(mMatch.Groups["name"].Value, mMatch.Groups["guid"].Value, mMatch.Groups["ip"].Value, kb_timeoutSubset, mMatch.Groups["reason"].Value);

                if (this.PunkbusterPlayerBanned != null)
                {
                    FrostbiteConnection.RaiseEvent(this.PunkbusterPlayerBanned.GetInvocationList(), this, newPbBanInfo);
                }
            }
            
            //mMatch = Regex.Match(strPunkbusterMessage, @":[ ]+?Guid[ ]+?(?<guid>[A-Za-z0-9]+)[ ]+?has been Unbanned", RegexOptions.IgnoreCase);
            mMatch = this.Parent.RegexMatchPunkbusterUnban.Match(strPunkbusterMessage);
            // If it is a new connection, technically its a resolved guid type command but stil..
            if (mMatch.Success == true && mMatch.Groups.Count >= 2) {
                CBanInfo cbiUnbannedPlayer = new CBanInfo(String.Empty, mMatch.Groups["guid"].Value, String.Empty, new TimeoutSubset(TimeoutSubset.TimeoutSubsetType.None), String.Empty);

                if (this.PunkbusterPlayerUnbanned != null) {
                    FrostbiteConnection.RaiseEvent(this.PunkbusterPlayerUnbanned.GetInvocationList(), this, cbiUnbannedPlayer);
                }
            }

            //mMatch = Regex.Match(strPunkbusterMessage, @": Ban Added to Ban List", RegexOptions.IgnoreCase);
            mMatch = this.Parent.RegexMatchPunkbusterBanAdded.Match(strPunkbusterMessage);
            if (mMatch.Success == true && mMatch.Groups.Count >= 5) {
                this.SendRequest(new List<string>() { "punkBuster.pb_sv_command", this.Variables.GetVariable<string>("PUNKBUSTER_BANLIST_REFRESH", "pb_sv_banlist BC2! ") });
            }
        }
Ejemplo n.º 2
0
        protected virtual void DispatchBanListAddRequest(ILayerConnection sender, Packet request)
        {
            if (request.Words.Count >= 4)
            {
                CBanInfo newBan = new CBanInfo(request.Words[1], request.Words[2], new TimeoutSubset(request.Words.GetRange(3, TimeoutSubset.RequiredLength(request.Words[3]))), request.Words.Count >= (4 + TimeoutSubset.RequiredLength(request.Words[3])) ? request.Words[(3 + TimeoutSubset.RequiredLength(request.Words[3]))] : "");

                var handler = this.RequestBanListAddRecieved;
                if (handler != null)
                {
                    handler(this, request, newBan);
                }
            }
        }
Ejemplo n.º 3
0
        protected virtual void DispatchBanListAddRequest(FrostbiteLayerConnection sender, Packet cpRecievedPacket)
        {
            if (cpRecievedPacket.Words.Count >= 4)
            {
                CBanInfo newBan = new CBanInfo(cpRecievedPacket.Words[1], cpRecievedPacket.Words[2], new TimeoutSubset(cpRecievedPacket.Words.GetRange(3, TimeoutSubset.RequiredLength(cpRecievedPacket.Words[3]))), cpRecievedPacket.Words.Count >= (4 + TimeoutSubset.RequiredLength(cpRecievedPacket.Words[3])) ? cpRecievedPacket.Words[(3 + TimeoutSubset.RequiredLength(cpRecievedPacket.Words[3]))] : "");

                if (this.RequestBanListAddRecieved != null)
                {
                    FrostbiteConnection.RaiseEvent(this.RequestBanListAddRecieved.GetInvocationList(), this, cpRecievedPacket, newBan);
                }
            }
        }