diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 66843b91c..0b67b509a 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -330,6 +330,22 @@ ActorOwn<> get_simple_config_firebase_remote_config(Promise {}, prefer_ipv6, std::move(get_config), payload, "application/json"); } +ActorOwn<> get_simple_config_firebase_realtime(Promise promise, const ConfigShared *shared_config, + bool is_test, int32 scheduler_id) { + if (is_test) { + promise.set_error(Status::Error(400, "Test config is not supported")); + return ActorOwn<>(); + } + + string url = "https://reserve-5a846.firebaseio.com/ipconfigv3.json"; + const bool prefer_ipv6 = shared_config == nullptr ? false : shared_config->get_option_boolean("prefer_ipv6"); + auto get_config = [](HttpQuery &http_query) -> Result { + return http_query.get_arg("content").str(); + }; + return get_simple_config_impl(std::move(promise), scheduler_id, std::move(url), "reserve-5a846.firebaseio.com", {}, + prefer_ipv6, std::move(get_config)); +} + ActorOwn<> get_full_config(DcOption option, Promise promise, ActorShared<> parent) { class SessionCallback : public Session::Callback { public: @@ -755,6 +771,8 @@ class ConfigRecoverer : public Actor { return get_simple_config_azure; case 3: return get_simple_config_firebase_remote_config; + case 4: + return get_simple_config_firebase_realtime; case 0: return get_simple_config_google_dns; case 1: diff --git a/td/telegram/ConfigManager.h b/td/telegram/ConfigManager.h index 04e2e8bb2..b7cdcaad4 100644 --- a/td/telegram/ConfigManager.h +++ b/td/telegram/ConfigManager.h @@ -48,6 +48,9 @@ ActorOwn<> get_simple_config_firebase_remote_config(Promise const ConfigShared *shared_config, bool is_test, int32 scheduler_id); +ActorOwn<> get_simple_config_firebase_realtime(Promise promise, const ConfigShared *shared_config, + bool is_test, int32 scheduler_id); + class HttpDate { static bool is_leap(int32 year) { return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); diff --git a/tdnet/td/net/HttpReader.cpp b/tdnet/td/net/HttpReader.cpp index 223bebdc4..36b6aebf2 100644 --- a/tdnet/td/net/HttpReader.cpp +++ b/tdnet/td/net/HttpReader.cpp @@ -590,6 +590,18 @@ Status HttpReader::parse_json_parameters(MutableSlice parameters) { Parser parser(parameters); parser.skip_whitespaces(); + if (parser.peek_char() == '"') { + auto r_value = json_string_decode(parser); + if (r_value.is_error()) { + return Status::Error(400, PSLICE() << "Bad Request: can't parse string content: " << r_value.error().message()); + } + if (!parser.empty()) { + return Status::Error(400, "Bad Request: extra data after string"); + } + query_->container_.emplace_back(BufferSlice("content")); + query_->args_.emplace_back(query_->container_.back().as_slice(), r_value.move_as_ok()); + return Status::OK(); + } parser.skip('{'); if (parser.status().is_error()) { return Status::Error(400, "Bad Request: JSON object expected"); diff --git a/test/mtproto.cpp b/test/mtproto.cpp index 63e325f21..d3503406b 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -171,6 +171,7 @@ TEST(Mtproto, config) { run(get_simple_config_google_dns, true); run(get_simple_config_mozilla_dns, true); run(get_simple_config_firebase_remote_config, false); + run(get_simple_config_firebase_realtime, false); } cnt--; sched.start();