mirror of
https://github.com/abraunegg/onedrive
synced 2026-03-14 14:35:46 +01:00
Update PR
* Add capability to disable websocket support
This commit is contained in:
parent
04282f0380
commit
dea6e7a1b3
3 changed files with 62 additions and 33 deletions
|
|
@ -329,6 +329,19 @@ _**CLI Option Use:**_ `--disable-upload-validation`
|
|||
> [!CAUTION]
|
||||
> If you're uploading data to SharePoint or OneDrive Business Shared Folders, you might find it necessary to activate this option. It's important to note that any issues encountered aren't due to a problem with this client; instead, they should be regarded as issues with the Microsoft OneDrive technology stack. Enabling this option disables all upload integrity checks.
|
||||
|
||||
|
||||
### disable_websocket_support
|
||||
_**Description:**_ This option disables the built-in WebSocket support that leverages RFC6455 to communicate with the Microsoft Graph API Service, providing near real-time notifications of online changes.
|
||||
|
||||
_**Value Type:**_ Boolean
|
||||
|
||||
_**Default Value:**_ False
|
||||
|
||||
_**Config Example:**_ `disable_websocket_support = "false"` or `disable_websocket_support = "true"`
|
||||
|
||||
_**CLI Option Use:**_ *None - this is a config file option only*
|
||||
|
||||
|
||||
### display_running_config
|
||||
_**Description:**_ This option will include the running config of the application at application startup. This may be desirable to enable when running in containerised environments so that any application logging that is occurring, will have the application configuration being consumed at startup, written out to any applicable log file.
|
||||
|
||||
|
|
|
|||
|
|
@ -418,6 +418,9 @@ class ApplicationConfig {
|
|||
longValues["webhook_renewal_interval"] = 300;
|
||||
longValues["webhook_retry_interval"] = 60;
|
||||
|
||||
// WebSocket Feature Options
|
||||
boolValues["disable_websocket_support"] = false;
|
||||
|
||||
// GUI File Transfer and Deletion Notifications
|
||||
boolValues["notify_file_actions"] = false;
|
||||
|
||||
|
|
@ -1626,6 +1629,7 @@ class ApplicationConfig {
|
|||
addLogEntry("Config option 'monitor_interval' = " ~ to!string(getValueLong("monitor_interval")));
|
||||
addLogEntry("Config option 'monitor_log_frequency' = " ~ to!string(getValueLong("monitor_log_frequency")));
|
||||
addLogEntry("Config option 'monitor_fullscan_frequency' = " ~ to!string(getValueLong("monitor_fullscan_frequency")));
|
||||
addLogEntry("Config option 'disable_websocket_support' = " ~ to!string(getValueBool("disable_websocket_support")));
|
||||
|
||||
// sync process and method
|
||||
addLogEntry("Config option 'read_only_auth_scope' = " ~ to!string(getValueBool("read_only_auth_scope")));
|
||||
|
|
|
|||
78
src/main.d
78
src/main.d
|
|
@ -961,22 +961,28 @@ int main(string[] cliArgs) {
|
|||
|
||||
// If we are doing --upload-only however .. we need to 'ignore' online change
|
||||
if (!appConfig.getValueBool("upload_only")) {
|
||||
// Log that we are attempting to enable WebSocket Support
|
||||
addLogEntry("Attempting to enable WebSocket support to monitor Microsoft Graph API changes in near real-time.");
|
||||
|
||||
// Obtain the WebSocket Notification URL from the API endpoint
|
||||
syncEngineInstance.obtainWebSocketNotificationURL();
|
||||
|
||||
// Were we able to correctly obtain the endpoint response and build the socket.io WS endpoint
|
||||
if (appConfig.websocketNotificationUrlAvailable) {
|
||||
// Notification URL is available
|
||||
if (oneDriveSocketIo is null) {
|
||||
oneDriveSocketIo = new OneDriveSocketIo(thisTid, appConfig);
|
||||
oneDriveSocketIo.start();
|
||||
// Did the user configure to disable 'websocket' support?
|
||||
if (!appConfig.getValueBool("disable_websocket_support")) {
|
||||
// Log that we are attempting to enable WebSocket Support
|
||||
addLogEntry("Attempting to enable WebSocket support to monitor Microsoft Graph API changes in near real-time.");
|
||||
|
||||
// Obtain the WebSocket Notification URL from the API endpoint
|
||||
syncEngineInstance.obtainWebSocketNotificationURL();
|
||||
|
||||
// Were we able to correctly obtain the endpoint response and build the socket.io WS endpoint
|
||||
if (appConfig.websocketNotificationUrlAvailable) {
|
||||
// Notification URL is available
|
||||
if (oneDriveSocketIo is null) {
|
||||
oneDriveSocketIo = new OneDriveSocketIo(thisTid, appConfig);
|
||||
oneDriveSocketIo.start();
|
||||
}
|
||||
addLogEntry("Enabled WebSocket support to monitor Microsoft Graph API changes in near real-time.");
|
||||
} else {
|
||||
addLogEntry("ERROR: Unable to configure WebSocket support to monitor Microsoft Graph API changes in near real-time.");
|
||||
}
|
||||
addLogEntry("Enabled WebSocket support to monitor Microsoft Graph API changes in near real-time.");
|
||||
} else {
|
||||
addLogEntry("ERROR: Unable to configure WebSocket support to monitor Microsoft Graph API changes in near real-time.");
|
||||
// WebSocket Support has been disabled
|
||||
addLogEntry("WebSocket support has been disabled by user configuration.");
|
||||
}
|
||||
} else {
|
||||
// --upload only being used
|
||||
|
|
@ -1130,18 +1136,21 @@ int main(string[] cliArgs) {
|
|||
} else {
|
||||
// WebSocket support is enabled by default, but only if the version of libcurl supports it
|
||||
if (appConfig.curlSupportsWebSockets) {
|
||||
// Do we need to renew the notification URL?
|
||||
auto renewEarly = dur!"seconds"(120);
|
||||
if (appConfig.websocketNotificationUrlAvailable && appConfig.websocketUrlExpiry.length) {
|
||||
auto expiry = SysTime.fromISOExtString(appConfig.websocketUrlExpiry);
|
||||
auto now = Clock.currTime(UTC());
|
||||
if (expiry - now <= renewEarly) {
|
||||
try {
|
||||
// Obtain the WebSocket Notification URL from the API endpoint
|
||||
syncEngineInstance.obtainWebSocketNotificationURL();
|
||||
if (debugLogging) addLogEntry("Refreshed WebSocket notification URL prior to expiry", ["debug"]);
|
||||
} catch (Exception e) {
|
||||
if (debugLogging) addLogEntry("Failed to refresh WebSocket notification URL: " ~ e.msg, ["debug"]);
|
||||
// Did the user configure to disable 'websocket' support?
|
||||
if (!appConfig.getValueBool("disable_websocket_support")) {
|
||||
// Do we need to renew the notification URL?
|
||||
auto renewEarly = dur!"seconds"(120);
|
||||
if (appConfig.websocketNotificationUrlAvailable && appConfig.websocketUrlExpiry.length) {
|
||||
auto expiry = SysTime.fromISOExtString(appConfig.websocketUrlExpiry);
|
||||
auto now = Clock.currTime(UTC());
|
||||
if (expiry - now <= renewEarly) {
|
||||
try {
|
||||
// Obtain the WebSocket Notification URL from the API endpoint
|
||||
syncEngineInstance.obtainWebSocketNotificationURL();
|
||||
if (debugLogging) addLogEntry("Refreshed WebSocket notification URL prior to expiry", ["debug"]);
|
||||
} catch (Exception e) {
|
||||
if (debugLogging) addLogEntry("Failed to refresh WebSocket notification URL: " ~ e.msg, ["debug"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1333,13 +1342,16 @@ int main(string[] cliArgs) {
|
|||
// Webhook Notification reset to false for this loop
|
||||
notificationReceived = false;
|
||||
} else {
|
||||
// WebSocket support is enabled by default, but only if the version of libcurl supports it
|
||||
if (appConfig.curlSupportsWebSockets) {
|
||||
// Update sleep time based on renew interval
|
||||
Duration nextWebsocketCheckDuration = oneDriveSocketIo.getNextExpirationCheckDuration();
|
||||
if (nextWebsocketCheckDuration < sleepTime) {
|
||||
sleepTime = nextWebsocketCheckDuration;
|
||||
if (debugLogging) {addLogEntry("Update sleeping time (based on WebSocket next expiration check) to " ~ to!string(sleepTime), ["debug"]);}
|
||||
// Did the user configure to disable 'websocket' support?
|
||||
if (!appConfig.getValueBool("disable_websocket_support")) {
|
||||
// WebSocket support is enabled by default, but only if the version of libcurl supports it
|
||||
if (appConfig.curlSupportsWebSockets) {
|
||||
// Update sleep time based on renew interval
|
||||
Duration nextWebsocketCheckDuration = oneDriveSocketIo.getNextExpirationCheckDuration();
|
||||
if (nextWebsocketCheckDuration < sleepTime) {
|
||||
sleepTime = nextWebsocketCheckDuration;
|
||||
if (debugLogging) {addLogEntry("Update sleeping time (based on WebSocket next expiration check) to " ~ to!string(sleepTime), ["debug"]);}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue