From 60866a6da2dd18cad4b12ccc761a4c9c7b1044be Mon Sep 17 00:00:00 2001 From: centurion Date: Fri, 20 Mar 2026 19:21:49 -0300 Subject: [PATCH] feat: impl new core_api_http_timeout_ms option --- src/mtp_config.erl | 3 ++- src/mtproto_proxy.app.src | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mtp_config.erl b/src/mtp_config.erl index b2420fb..4a6ddfc 100644 --- a/src/mtp_config.erl +++ b/src/mtp_config.erl @@ -270,8 +270,9 @@ http_get(Url) -> UserAgent = ("MTProtoProxy/" ++ Vsn ++ " OTP-" ++ OtpVersion ++ " (+https://github.com/seriyps/mtproto_proxy)"), Headers = [{"User-Agent", UserAgent}], + Timeout = application:get_env(mtproto_proxy, core_api_http_timeout_ms, 3000), {ok, {{_, 200, _}, _, Body}} = - httpc:request(get, {Url, Headers}, [{timeout, 3000}], ?OPTS), + httpc:request(get, {Url, Headers}, [{timeout, Timeout}], ?OPTS), {ok, Body}. random_choice(L) -> diff --git a/src/mtproto_proxy.app.src b/src/mtproto_proxy.app.src index 91709f2..1cbad35 100644 --- a/src/mtproto_proxy.app.src +++ b/src/mtproto_proxy.app.src @@ -119,7 +119,7 @@ %% Remove items used for the last time more than `max_age_minutes` %% minutes ago. %% Less than 10 minutes doesn't make much sense - max_age_minutes => 360}} + max_age_minutes => 360}}, %% Should be module with function `notify/4' exported. %% See mtp_metric:notify/4 for details @@ -138,6 +138,8 @@ %% Mostly used to testing %% {proxy_secret_url, "https://core.telegram.org/getProxySecret"}, %% {proxy_config_url, "https://core.telegram.org/getProxyConfig"}, + %% HTTP timeout (ms) for fetching proxy config/secret + {core_api_http_timeout_ms, 3000} %% Upstream self-healthchecks tuning %% {upstream_healthchecks,