Page MenuHomePhorge

D5445.1775352840.diff
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

D5445.1775352840.diff

diff --git a/docs/SQL/mysql.initial.sql b/docs/SQL/mysql.initial.sql
--- a/docs/SQL/mysql.initial.sql
+++ b/docs/SQL/mysql.initial.sql
@@ -32,6 +32,7 @@
`tasksfilter_id` varchar(40) DEFAULT NULL,
`emailfilter_id` varchar(40) DEFAULT NULL,
`extra_data` longblob DEFAULT NULL,
+ `broken` longblob DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `owner_id--deviceid` (`owner_id`, `deviceid`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
@@ -129,4 +130,4 @@
PRIMARY KEY (`name`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
-INSERT INTO `system` (`name`, `value`) VALUES ('syncroton-version', '2025070300');
+INSERT INTO `system` (`name`, `value`) VALUES ('syncroton-version', '2025070301');
diff --git a/docs/SQL/mysql/2025070301.sql b/docs/SQL/mysql/2025070301.sql
new file mode 100644
--- /dev/null
+++ b/docs/SQL/mysql/2025070301.sql
@@ -0,0 +1,2 @@
+
+ALTER TABLE `syncroton_device` ADD `broken` longblob DEFAULT NULL;
diff --git a/lib/ext/Syncroton/Command/FolderSync.php b/lib/ext/Syncroton/Command/FolderSync.php
--- a/lib/ext/Syncroton/Command/FolderSync.php
+++ b/lib/ext/Syncroton/Command/FolderSync.php
@@ -124,6 +124,11 @@
if ($this->_logger instanceof Zend_Log) {
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " This client is stuck on resending the same FolderSync synckey.");
}
+ $this->_device->broken = json_encode([
+ 'timestamp' => new DateTime('now', new DateTimeZone('UTC')),
+ 'reason' => "This client is stuck on resending the same FolderSync synckey"
+ ]);
+ $this->_device = $this->_deviceBackend->update($this->_device); // @phpstan-ignore-line
call_user_func(Syncroton_Registry::getSleepCallback());
sleep(10);
header('X-MS-ASThrottle: CommandFrequency');
diff --git a/lib/ext/Syncroton/Command/Ping.php b/lib/ext/Syncroton/Command/Ping.php
--- a/lib/ext/Syncroton/Command/Ping.php
+++ b/lib/ext/Syncroton/Command/Ping.php
@@ -126,6 +126,11 @@
if ($this->_logger instanceof Zend_Log) {
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " This client is stuck in a loop on Ping status $status");
}
+ $this->_device->broken = json_encode([
+ 'timestamp' => new DateTime('now', new DateTimeZone('UTC')),
+ 'reason' => "This client is stuck in a loop on Ping status $status"
+ ]);
+ $this->_device = $this->_deviceBackend->update($this->_device); // @phpstan-ignore-line
call_user_func(Syncroton_Registry::getSleepCallback());
sleep(10);
header('X-MS-ASThrottle: CommandFrequency');
diff --git a/lib/ext/Syncroton/Registry.php b/lib/ext/Syncroton/Registry.php
--- a/lib/ext/Syncroton/Registry.php
+++ b/lib/ext/Syncroton/Registry.php
@@ -42,6 +42,7 @@
public const SESSION_VALIDATOR = 'session_validator';
public const MAX_COLLECTIONS = 'max_collections';
public const MAX_PING_INTERVAL = 'max_ping_interval';
+ public const BLOCK_BROKEN_DEVICES = 'block_broken_devices';
public const DATABASE = 'database';
public const TRANSACTIONMANAGER = 'transactionmanager';
diff --git a/lib/ext/Syncroton/Server.php b/lib/ext/Syncroton/Server.php
--- a/lib/ext/Syncroton/Server.php
+++ b/lib/ext/Syncroton/Server.php
@@ -134,6 +134,18 @@
// get user device
$device = $this->_getUserDevice($this->_userId, $requestParameters);
+ if ($broken = $device->broken) {
+ $brokenState = json_decode($broken, true);
+ if ($this->_logger instanceof Zend_Log) {
+ $this->_logger->notice(__METHOD__ . '::' . __LINE__ . " This device is in a broken state: " . $brokenState['reason']);
+ }
+ if (Syncroton_Registry::get(Syncroton_Registry::BLOCK_BROKEN_DEVICES)) {
+ header('X-MS-ASThrottle: CommandFrequency');
+ header('HTTP/1.1 503 Service Unavailable');
+ return;
+ }
+ }
+
if ($requestParameters['contentType'] == 'application/vnd.ms-sync.wbxml' || $requestParameters['contentType'] == 'application/vnd.ms-sync') {
// decode wbxml request
try {
diff --git a/lib/kolab_sync.php b/lib/kolab_sync.php
--- a/lib/kolab_sync.php
+++ b/lib/kolab_sync.php
@@ -176,6 +176,7 @@
Syncroton_Registry::set(Syncroton_Registry::PING_INTERVAL, (int) $this->config->get('activesync_ping_interval', 15 * 60));
Syncroton_Registry::set(Syncroton_Registry::QUIET_TIME, (int) $this->config->get('activesync_quiet_time', 3 * 60));
Syncroton_Registry::set(Syncroton_Registry::MAX_COLLECTIONS, (int) $this->config->get('activesync_max_folders', 100));
+ Syncroton_Registry::set(Syncroton_Registry::BLOCK_BROKEN_DEVICES, (bool) $this->config->get('activesync_block_broken_devices', false));
// The above is dominated by the $storage->connect call in authenticate(), and makes up ~50%
// for a FolderSync of the overall processing time.

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 1:34 AM (1 d, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18831849
Default Alt Text
D5445.1775352840.diff (5 KB)

Event Timeline