Skip to content

Commit

Permalink
Plugin useragent can be redefined via UserAgent config key
Browse files Browse the repository at this point in the history
  • Loading branch information
pozitronik committed Apr 5, 2020
1 parent 9c0ad3c commit 97a7602
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMLHTTP.pas
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ constructor TCloudMailRuHTTP.Create(Settings: TConnectionSettings; ExternalProgr
self.Throttle.SendBitsPerSec := Settings.UploadBPS;
end;

HTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36/TCWFX(' + PlatformX + ')';
HTTP.Request.UserAgent := Settings.UserAgent;
HTTP.Request.Connection := EmptyWideStr;
end;

Expand Down
6 changes: 0 additions & 6 deletions CMLTypes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
interface

const
{$IFDEF WIN64}
PlatformX = 'x64';
{$ENDIF}
{$IFDEF WIN32}
PlatformX = 'x32';
{$ENDIF}
PUBLIC_ACCESS_URL = 'https://cloud.mail.ru/public/';
OAUTH_TOKEN_URL = 'https://o2.mail.ru/token';
TOKEN_URL = 'https://cloud.mail.ru/?from=promo&from=authpopup';
Expand Down
10 changes: 10 additions & 0 deletions Settings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ interface
uses Classes, Windows, SysUtils, IniFiles, System.Variants, System.IOUtils, Plugin_Types, MRC_Helper, VCL.Controls, System.RegularExpressions;

const
{$IFDEF WIN64}
PlatformX = 'x64';
{$ENDIF}
{$IFDEF WIN32}
PlatformX = 'x32';
{$ENDIF}
ProxyNone = 0;
ProxySocks5 = 1;
ProxySocks4 = 2;
Expand Down Expand Up @@ -59,6 +65,8 @@ interface

StreamingPrefix = 'Streaming:';

DEFAULT_USERAGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36/TCWFX(' + PlatformX + ')';

type
{Account-related options set}
TAccountSettings = record
Expand Down Expand Up @@ -94,6 +102,7 @@ TConnectionSettings = record
SocketTimeout: integer;
UploadBPS: integer;
DownloadBPS: integer;
UserAgent: WideString;
end;

{Global plugin options}
Expand Down Expand Up @@ -215,6 +224,7 @@ function GetPluginSettings(IniFilePath: WideString): TPluginSettings;
GetPluginSettings.ConnectionSettings.ProxySettings.user := IniFile.ReadString('Main', 'ProxyUser', EmptyWideStr);
GetPluginSettings.ConnectionSettings.ProxySettings.use_tc_password_manager := IniFile.ReadBool('Main', 'ProxyTCPwdMngr', false);
GetPluginSettings.ConnectionSettings.ProxySettings.password := IniFile.ReadString('Main', 'ProxyPassword', EmptyWideStr);
GetPluginSettings.ConnectionSettings.UserAgent := IniFile.ReadString('Main', 'UserAgent', DEFAULT_USERAGENT);
GetPluginSettings.DownloadLinksEncode := IniFile.ReadBool('Main', 'DownloadLinksEncode', true);
GetPluginSettings.AutoUpdateDownloadListing := IniFile.ReadBool('Main', 'AutoUpdateDownloadListing', true);
GetPluginSettings.ShowTrashFolders := IniFile.ReadBool('Main', 'ShowTrashFolders', true);
Expand Down

0 comments on commit 97a7602

Please sign in to comment.