Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/internal/sio_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ namespace sio
this->sockets_invoke_void(&sio::socket::on_close);
sync_close();
}

void client_impl::set_proxy_basic_auth(const std::string& uri, const std::string& username, const std::string& password)
{
m_proxy_base_url = uri;
m_proxy_basic_username = username;
m_proxy_basic_password = password;
}

void client_impl::connect(const string& uri, const map<string,string>& query, const map<string, string>& headers, const message::ptr& auth)
{
Expand Down Expand Up @@ -263,6 +270,23 @@ namespace sio
for( auto&& header: m_http_headers ) {
con->replace_header(header.first, header.second);
}

if (!m_proxy_base_url.empty()) {
con->set_proxy(m_proxy_base_url, ec);
if (ec) {
m_client.get_alog().write(websocketpp::log::alevel::app,
"Set Proxy Error: " + ec.message());
break;
}
if (!m_proxy_basic_username.empty()) {
con->set_proxy_basic_auth(m_proxy_basic_username, m_proxy_basic_password, ec);
if (ec) {
m_client.get_alog().write(websocketpp::log::alevel::app,
"Set Proxy Basic Auth Error: " + ec.message());
break;
}
}
}

m_client.connect(con);
return;
Expand Down
5 changes: 5 additions & 0 deletions src/internal/sio_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ namespace sio
void set_logs_quiet();

void set_logs_verbose();

void set_proxy_basic_auth(const std::string& uri, const std::string& username, const std::string& password);

protected:
void send(packet& p);
Expand Down Expand Up @@ -203,6 +205,9 @@ namespace sio
std::string m_query_string;
std::map<std::string, std::string> m_http_headers;
message::ptr m_auth;
std::string m_proxy_base_url;
std::string m_proxy_basic_username;
std::string m_proxy_basic_password;

unsigned int m_ping_interval;
unsigned int m_ping_timeout;
Expand Down
5 changes: 5 additions & 0 deletions src/sio_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ namespace sio
{
m_impl->clear_socket_listeners();
}

void client::set_proxy_basic_auth(const std::string& uri, const std::string& username, const std::string& password)
{
m_impl->set_proxy_basic_auth(uri, username, password);
}

void client::connect(const std::string& uri)
{
Expand Down
2 changes: 2 additions & 0 deletions src/sio_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ namespace sio

void sync_close();

void set_proxy_basic_auth(const std::string& uri, const std::string& username, const std::string& password);

bool opened() const;

std::string const& get_sessionid() const;
Expand Down