Page MenuHomePhorge

D5445.1774854529.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D5445.1774854529.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/Server.php b/lib/ext/Syncroton/Server.php
--- a/lib/ext/Syncroton/Server.php
+++ b/lib/ext/Syncroton/Server.php
@@ -134,6 +134,17 @@
// get user device
$device = $this->_getUserDevice($this->_userId, $requestParameters);
+ if ($device && ($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']);
+ }
+ // TODO enable this to block all devices once we're confident this works as expected.
+ // 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 {

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 30, 7:08 AM (3 d, 10 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18795441
Default Alt Text
D5445.1774854529.diff (3 KB)

Event Timeline