예제 #1
0
        // Token: 0x06000558 RID: 1368 RVA: 0x0001F11C File Offset: 0x0001D31C
        public void RecordNewUserAgent(string newUserAgent)
        {
            EnhancedTimeSpan behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.UserAgentsChanges).BehaviorTypeIncidenceDuration;

            lock (this.instanceLock)
            {
                if (newUserAgent != null && !this.userAgentStrings.Contains(newUserAgent))
                {
                    ExDateTime utcNow          = ExDateTime.UtcNow;
                    ExDateTime windowStartTime = utcNow - behaviorTypeIncidenceDuration;
                    DeviceBehavior.ClearOldRecords(windowStartTime, this.userAgentTimes, this.userAgentStrings);
                    this.userAgentTimes.Add(utcNow);
                    this.userAgentStrings.Add(newUserAgent);
                    this.SaveDeviceBehavior(false);
                    int behaviorTypeIncidenceLimit = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.UserAgentsChanges).BehaviorTypeIncidenceLimit;
                    if (behaviorTypeIncidenceLimit > 0 && this.userAgentTimes.Count > behaviorTypeIncidenceLimit)
                    {
                        this.BlockDevice(AutoblockThresholdType.UserAgentsChanges);
                    }
                    else if (utcNow > this.blockTime && utcNow < this.nextUnblockTime)
                    {
                        this.UnblockDevice();
                    }
                }
            }
        }
예제 #2
0
        // Token: 0x0600055C RID: 1372 RVA: 0x0001F55C File Offset: 0x0001D75C
        public void RecordOutOfBudget()
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "RecordOutOfBudget");
            ExDateTime utcNow = ExDateTime.UtcNow;
            DeviceAutoBlockThreshold autoBlockThreshold = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.OutOfBudgets);
            ExDateTime windowStartTime = utcNow - autoBlockThreshold.BehaviorTypeIncidenceDuration;

            lock (this.instanceLock)
            {
                DeviceBehavior.ClearOldRecords(windowStartTime, this.outOfBudgets);
                this.outOfBudgets.Add(utcNow);
                this.SaveDeviceBehavior(false);
                int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit;
                if (behaviorTypeIncidenceLimit > 0 && this.outOfBudgets.Count > behaviorTypeIncidenceLimit)
                {
                    this.BlockDevice(AutoblockThresholdType.OutOfBudgets);
                }
            }
        }
예제 #3
0
        // Token: 0x0600055A RID: 1370 RVA: 0x0001F358 File Offset: 0x0001D558
        public void RecordCommand(int commandHashcode)
        {
            AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "RecordCommand HC:{0}", commandHashcode);
            ExDateTime utcNow = ExDateTime.UtcNow;
            DeviceAutoBlockThreshold autoBlockThreshold            = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.RecentCommands);
            EnhancedTimeSpan         behaviorTypeIncidenceDuration = autoBlockThreshold.BehaviorTypeIncidenceDuration;

            if (behaviorTypeIncidenceDuration < ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration)
            {
                behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration;
            }
            ExDateTime exDateTime = utcNow - behaviorTypeIncidenceDuration;

            lock (this.instanceLock)
            {
                DeviceBehavior.ClearOldRecords(exDateTime, this.recentCommandTimes, this.recentCommandHashCodes);
                this.recentCommandTimes.Add(utcNow);
                this.recentCommandHashCodes.Add(commandHashcode);
                this.SaveDeviceBehavior(false);
                if (this.ProtocolLogger != null)
                {
                    this.ProtocolLogger.SetValue(ProtocolLoggerData.CommandHashCode, commandHashcode);
                }
                if (!this.BlockOnFrequency())
                {
                    exDateTime = utcNow - autoBlockThreshold.BehaviorTypeIncidenceDuration;
                    int num = 0;
                    for (int i = 0; i < this.recentCommandTimes.Count; i++)
                    {
                        if (!(this.recentCommandTimes[i] < exDateTime) && this.recentCommandHashCodes[i] == commandHashcode)
                        {
                            num++;
                        }
                    }
                    int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit;
                    if (behaviorTypeIncidenceLimit > 0 && num > behaviorTypeIncidenceLimit)
                    {
                        this.BlockDevice(AutoblockThresholdType.RecentCommands);
                    }
                }
            }
        }
예제 #4
0
        // Token: 0x06000568 RID: 1384 RVA: 0x0001FEDC File Offset: 0x0001E0DC
        private void RecordSyncCommand(ExDateTime syncAttemptTime)
        {
            AirSyncDiagnostics.TraceInfo <ExDateTime>(ExTraceGlobals.RequestsTracer, this, "RecordSyncCommand syncAttemptTime:{0:o}", syncAttemptTime);
            ExDateTime       utcNow = ExDateTime.UtcNow;
            EnhancedTimeSpan behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands).BehaviorTypeIncidenceDuration;

            if (behaviorTypeIncidenceDuration < ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration)
            {
                behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration;
            }
            ExDateTime windowStartTime = utcNow - behaviorTypeIncidenceDuration;

            lock (this.instanceLock)
            {
                DeviceBehavior.ClearOldRecords(windowStartTime, this.syncTimes, this.syncKeys);
                this.syncTimes.Add(syncAttemptTime);
                this.syncKeys.Add(0);
                this.SaveDeviceBehavior(false);
            }
        }
예제 #5
0
 // Token: 0x06000565 RID: 1381 RVA: 0x0001FCF7 File Offset: 0x0001DEF7
 private static void ClearOldRecords(ExDateTime windowStartTime, List <ExDateTime> times)
 {
     DeviceBehavior.ClearOldRecords(windowStartTime, times, null);
 }