|
@@ -3848,6 +3848,7 @@ public:
|
|
|
void set_socket_options(SocketOptions socket_options);
|
|
void set_socket_options(SocketOptions socket_options);
|
|
|
void set_connection_timeout(time_t sec, time_t usec = 0);
|
|
void set_connection_timeout(time_t sec, time_t usec = 0);
|
|
|
void set_interface(const std::string &intf);
|
|
void set_interface(const std::string &intf);
|
|
|
|
|
+ void set_hostname_addr_map(std::map<std::string, std::string> addr_map);
|
|
|
|
|
|
|
|
#ifdef CPPHTTPLIB_SSL_ENABLED
|
|
#ifdef CPPHTTPLIB_SSL_ENABLED
|
|
|
void set_ca_cert_path(const std::string &path);
|
|
void set_ca_cert_path(const std::string &path);
|
|
@@ -3882,6 +3883,9 @@ private:
|
|
|
time_t connection_timeout_usec_ = CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND;
|
|
time_t connection_timeout_usec_ = CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND;
|
|
|
std::string interface_;
|
|
std::string interface_;
|
|
|
|
|
|
|
|
|
|
+ // Hostname-IP map
|
|
|
|
|
+ std::map<std::string, std::string> addr_map_;
|
|
|
|
|
+
|
|
|
#ifdef CPPHTTPLIB_SSL_ENABLED
|
|
#ifdef CPPHTTPLIB_SSL_ENABLED
|
|
|
bool is_ssl_ = false;
|
|
bool is_ssl_ = false;
|
|
|
tls::ctx_t tls_ctx_ = nullptr;
|
|
tls::ctx_t tls_ctx_ = nullptr;
|
|
@@ -20326,9 +20330,14 @@ inline bool WebSocketClient::connect() {
|
|
|
if (!is_valid_) { return false; }
|
|
if (!is_valid_) { return false; }
|
|
|
shutdown_and_close();
|
|
shutdown_and_close();
|
|
|
|
|
|
|
|
|
|
+ // Check is custom IP specified for host_
|
|
|
|
|
+ std::string ip;
|
|
|
|
|
+ auto it = addr_map_.find(host_);
|
|
|
|
|
+ if (it != addr_map_.end()) { ip = it->second; }
|
|
|
|
|
+
|
|
|
Error error;
|
|
Error error;
|
|
|
sock_ = detail::create_client_socket(
|
|
sock_ = detail::create_client_socket(
|
|
|
- host_, std::string(), port_, address_family_, tcp_nodelay_, ipv6_v6only_,
|
|
|
|
|
|
|
+ host_, ip, port_, address_family_, tcp_nodelay_, ipv6_v6only_,
|
|
|
socket_options_, connection_timeout_sec_, connection_timeout_usec_,
|
|
socket_options_, connection_timeout_sec_, connection_timeout_usec_,
|
|
|
read_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
|
|
read_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
|
|
|
write_timeout_usec_, interface_, error);
|
|
write_timeout_usec_, interface_, error);
|
|
@@ -20423,6 +20432,11 @@ inline void WebSocketClient::set_interface(const std::string &intf) {
|
|
|
interface_ = intf;
|
|
interface_ = intf;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+inline void WebSocketClient::set_hostname_addr_map(
|
|
|
|
|
+ std::map<std::string, std::string> addr_map) {
|
|
|
|
|
+ addr_map_ = std::move(addr_map);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
#ifdef CPPHTTPLIB_SSL_ENABLED
|
|
#ifdef CPPHTTPLIB_SSL_ENABLED
|
|
|
|
|
|
|
|
inline void WebSocketClient::set_ca_cert_path(const std::string &path) {
|
|
inline void WebSocketClient::set_ca_cert_path(const std::string &path) {
|