Пример #1
0
        public void AddTrackClient(UpDownClient toadd)
        {
            DeletedClient pResult = null;

            if (trackedClientsList_.ContainsKey(toadd.IP))
            {
                pResult = trackedClientsList_[toadd.IP];
                pResult.m_dwInserted = MpdUtilities.GetTickCount();
                for (int i = 0; i != pResult.m_ItemsList.Count; i++)
                {
                    if (pResult.m_ItemsList[i].nPort == toadd.UserPort)
                    {
                        // already tracked, update
                        pResult.m_ItemsList[i].pHash = toadd.Credits;
                        return;
                    }
                }
                PORTANDHASH porthash = new PORTANDHASH(toadd.UserPort, toadd.Credits);
                pResult.m_ItemsList.Add(porthash);
            }
            else
            {
                trackedClientsList_[toadd.IP] = new DeletedClient(toadd);
            }
        }
Пример #2
0
        public uint GetBadRequests(UpDownClient upcClient)
        {
            DeletedClient pResult = null;

            if (upcClient.IP == 0)
            {
                return(0);
            }
            if (trackedClientsList_.ContainsKey(upcClient.IP))
            {
                pResult = trackedClientsList_[upcClient.IP];
                return(pResult.m_cBadRequest);
            }
            else
            {
                return(0);
            }
        }
Пример #3
0
        public void TrackBadRequest(UpDownClient upcClient, int nIncreaseCounter)
        {
            DeletedClient pResult = null;

            if (upcClient.IP == 0)
            {
                Debug.Assert(false);
                return;
            }
            if (trackedClientsList_.ContainsKey(upcClient.IP))
            {
                pResult = trackedClientsList_[upcClient.IP];
                pResult.m_dwInserted   = MpdUtilities.GetTickCount();
                pResult.m_cBadRequest += (uint)nIncreaseCounter;
            }
            else
            {
                DeletedClient ccToAdd = new DeletedClient(upcClient);
                ccToAdd.m_cBadRequest             = (uint)nIncreaseCounter;
                trackedClientsList_[upcClient.IP] = ccToAdd;
            }
        }
Пример #4
0
        public bool ComparePriorUserhash(uint dwIP, ushort nPort, byte[] pNewHash)
        {
            DeletedClient pResult = null;

            if (trackedClientsList_.ContainsKey(dwIP))
            {
                pResult = trackedClientsList_[dwIP];
                for (int i = 0; i != pResult.m_ItemsList.Count; i++)
                {
                    if (pResult.m_ItemsList[i].nPort == nPort)
                    {
                        if (pResult.m_ItemsList[i].pHash != pNewHash)
                        {
                            return(false);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return(true);
        }