From d5259c230e75e0a7e77fad507b2daf9d0c5cb5df Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 17 Jan 2019 16:37:16 +0100 Subject: [PATCH] Open more PublicAPI interfaces --- ArchiSteamFarm/BotConfig.cs | 6 +++--- ArchiSteamFarm/GlobalConfig.cs | 12 ++++++------ ArchiSteamFarm/WebBrowser.cs | 27 ++++++++++++++------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index a672c0ad8..6cb69e644 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -145,6 +145,9 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] public readonly bool UseLoginKeys = DefaultUseLoginKeys; + [JsonProperty(Required = Required.DisallowNull)] + public ulong SteamMasterClanID { get; private set; } = DefaultSteamMasterClanID; + [JsonExtensionData] internal Dictionary AdditionalProperties { get; @@ -199,9 +202,6 @@ namespace ArchiSteamFarm { } } - [JsonProperty(Required = Required.DisallowNull)] - internal ulong SteamMasterClanID { get; private set; } = DefaultSteamMasterClanID; - [JsonProperty] internal string SteamParentalCode { get => _SteamParentalCode; diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index 5831ab691..dda02f85c 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -186,6 +186,12 @@ namespace ArchiSteamFarm { } } + [JsonProperty(Required = Required.DisallowNull)] + public ulong SteamOwnerID { get; private set; } = DefaultSteamOwnerID; + + [JsonProperty(Required = Required.DisallowNull)] + public ProtocolTypes SteamProtocols { get; private set; } = DefaultSteamProtocols; + [JsonExtensionData] internal Dictionary AdditionalProperties { get; @@ -197,12 +203,6 @@ namespace ArchiSteamFarm { internal bool ShouldSerializeEverything { private get; set; } = true; internal bool ShouldSerializeHelperProperties { private get; set; } = true; - [JsonProperty(Required = Required.DisallowNull)] - internal ulong SteamOwnerID { get; private set; } = DefaultSteamOwnerID; - - [JsonProperty(Required = Required.DisallowNull)] - internal ProtocolTypes SteamProtocols { get; private set; } = DefaultSteamProtocols; - [JsonProperty] internal string WebProxyPassword { get => _WebProxyPassword; diff --git a/ArchiSteamFarm/WebBrowser.cs b/ArchiSteamFarm/WebBrowser.cs index 70025e9b2..5e0255762 100644 --- a/ArchiSteamFarm/WebBrowser.cs +++ b/ArchiSteamFarm/WebBrowser.cs @@ -74,6 +74,20 @@ namespace ArchiSteamFarm { HttpClientHandler.Dispose(); } + [NotNull] + [PublicAPI] + public HttpClient GenerateDisposableHttpClient(bool extendedTimeout = false) { + HttpClient result = new HttpClient(HttpClientHandler) { + Timeout = TimeSpan.FromSeconds(extendedTimeout ? ExtendedTimeoutMultiplier * ASF.GlobalConfig.ConnectionTimeout : ASF.GlobalConfig.ConnectionTimeout) + }; + + // Most web services expect that UserAgent is set, so we declare it globally + // If you by any chance came here with a very "clever" idea of hiding your ass by changing default ASF user-agent then here is a very good advice from me: don't, for your own safety - you've been warned + result.DefaultRequestHeaders.UserAgent.ParseAdd(SharedInfo.PublicIdentifier + "/" + SharedInfo.Version + " (+" + SharedInfo.ProjectURL + ")"); + + return result; + } + [ItemCanBeNull] [PublicAPI] public async Task UrlGetToHtmlDocument(string request, string referer = null, byte maxTries = MaxTries) { @@ -275,19 +289,6 @@ namespace ArchiSteamFarm { return null; } - [NotNull] - internal HttpClient GenerateDisposableHttpClient(bool extendedTimeout = false) { - HttpClient result = new HttpClient(HttpClientHandler) { - Timeout = TimeSpan.FromSeconds(extendedTimeout ? ExtendedTimeoutMultiplier * ASF.GlobalConfig.ConnectionTimeout : ASF.GlobalConfig.ConnectionTimeout) - }; - - // Most web services expect that UserAgent is set, so we declare it globally - // If you by any chance came here with a very "clever" idea of hiding your ass by changing default ASF user-agent then here is a very good advice from me: don't, for your own safety - you've been warned - result.DefaultRequestHeaders.UserAgent.ParseAdd(SharedInfo.PublicIdentifier + "/" + SharedInfo.Version + " (+" + SharedInfo.ProjectURL + ")"); - - return result; - } - internal static void Init() { // Set max connection limit from default of 2 to desired value ServicePointManager.DefaultConnectionLimit = MaxConnections;