/* * Copyright (C) 2023-present ScyllaDB */ /* * SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0 */ #pragma once #include #include #include #include #include "seastarx.hh" #include "utils/log.hh" namespace utils::http { future> system_trust_credentials(); class dns_connection_factory : public seastar::http::experimental::connection_factory { protected: std::string _host; int _port; logging::logger& _logger; semaphore _init_semaphore{1}; bool _creds_init = false; std::optional> _addr_list; shared_ptr _creds; uint16_t _addr_pos{0}; bool _use_https; std::chrono::seconds _address_ttl{0}; timer _addr_update_timer; future<> init_credentials(); future get_address(); future> get_creds(); future connect(net::inet_address address); public: dns_connection_factory(dns_connection_factory&&) = default; dns_connection_factory(std::string host, int port, bool use_https, logging::logger& logger, shared_ptr = {}); dns_connection_factory(std::string endpoint_url, logging::logger& logger, shared_ptr = {}); virtual future make(abort_source*) override; future<> close() override; }; // simple URL parser, just enough to handle required aspects for normal endpoint usage // could use boost::url, but this requires additional libraries being added to // install-dependencies etc. struct url_info { std::string scheme; std::string host; std::string path; uint16_t port; bool is_https() const; }; url_info parse_simple_url(std::string_view uri); } // namespace utils::http