diff --git a/dotnet-app/APIL/Startup.cs b/dotnet-app/APIL/Startup.cs index 668a7a4..6f415fe 100644 --- a/dotnet-app/APIL/Startup.cs +++ b/dotnet-app/APIL/Startup.cs @@ -30,8 +30,6 @@ public Startup(IConfiguration configuration) _appConfig = new AppConfiguration(Configuration); - IWebProxy proxy = null; - if (_appConfig.UseSocks5) { var httpClientHandler = new HttpClientHandler diff --git a/dotnet-app/Common/WordCounterBot.Common.Logging/TelegramMessengerLogger.cs b/dotnet-app/Common/WordCounterBot.Common.Logging/TelegramMessengerLogger.cs index 9c090bd..02ec999 100644 --- a/dotnet-app/Common/WordCounterBot.Common.Logging/TelegramMessengerLogger.cs +++ b/dotnet-app/Common/WordCounterBot.Common.Logging/TelegramMessengerLogger.cs @@ -1,4 +1,5 @@ using System; +using System.Net.Http; using Microsoft.Extensions.Logging; using MihaZupan; using Telegram.Bot; @@ -18,15 +19,19 @@ public TelegramMessengerLogger(string name, TelegramMessengerLoggerConfiguration _name = name; _config = config; - HttpToSocks5Proxy proxy = null; if (_config.UseSocks5) { - proxy = new HttpToSocks5Proxy(_config.Socks5Host, _config.Socks5Port); + var httpClientHandler = new HttpClientHandler + { + Proxy = new HttpToSocks5Proxy(_config.Socks5Host, _config.Socks5Port), + UseProxy = true + }; + var httpClient = new HttpClient(httpClientHandler); + + _botClient = new TelegramBotClient(_config.TelegramToken, httpClient); } - _botClient = new TelegramBotClient( - _config.TelegramToken, - proxy); + _botClient = new TelegramBotClient(_config.TelegramToken); } public IDisposable BeginScope(TState state) => null;