Page MenuHomePhorge

D5445.1775215378.diff
No OneTemporary

Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None

D5445.1775215378.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,
+ `is_broken` tinyint(1) 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 `is_broken` tinyint(1) 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,14 @@
if ($this->_logger instanceof Zend_Log) {
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " This client is stuck on resending the same FolderSync synckey.");
}
+ if (!$this->_device->is_broken) {
+ $this->_device->is_broken = true;
+ $extraData = json_decode($this->_device->extraData, true);
+ $extraData['brokenTimestamp'] = new DateTime('now', new DateTimeZone('UTC'));
+ $extraData['brokenReason'] = "This client is stuck on resending the same FolderSync synckey";
+ $this->_device->extraData = json_encode($extraData);
+ $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,14 @@
if ($this->_logger instanceof Zend_Log) {
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " This client is stuck in a loop on Ping status $status");
}
+ if (!$this->_device->is_broken) {
+ $this->_device->is_broken = true;
+ $extraData = json_decode($this->_device->extraData, true);
+ $extraData['brokenTimestamp'] = new DateTime('now', new DateTimeZone('UTC'));
+ $extraData['brokenReason'] = "This client is stuck in a loop on Ping status $status";
+ $this->_device->extraData = json_encode($extraData);
+ $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/Model/IDevice.php b/lib/ext/Syncroton/Model/IDevice.php
--- a/lib/ext/Syncroton/Model/IDevice.php
+++ b/lib/ext/Syncroton/Model/IDevice.php
@@ -39,6 +39,7 @@
* @property string $lastsynccollection
* @property DateTime $lastping
* @property string $extraData JSON-encoded array
+ * @property bool $is_broken
*
* @phpstan-require-extends Syncroton_Model_Device
*/
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 ($device->is_broken) {
+ $extraData = json_decode($device->extraData, true);
+ if ($this->_logger instanceof Zend_Log) {
+ $this->_logger->notice(__METHOD__ . '::' . __LINE__ . " This device is in a broken state: " . $extraData['brokenReason']);
+ }
+ 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
Fri, Apr 3, 11:22 AM (17 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18789519
Default Alt Text
D5445.1775215378.diff (6 KB)

Event Timeline