Skip to content
Draft
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ set( IXWEBSOCKET_SOURCES
ixwebsocket/IXWebSocketProxyServer.cpp
ixwebsocket/IXWebSocketServer.cpp
ixwebsocket/IXWebSocketTransport.cpp
ixwebsocket/IXProxyOptions.cpp
ixwebsocket/IXProxySocket.cpp
)

set( IXWEBSOCKET_HEADERS
Expand Down Expand Up @@ -117,6 +119,8 @@ set( IXWEBSOCKET_HEADERS
ixwebsocket/IXWebSocketServer.h
ixwebsocket/IXWebSocketTransport.h
ixwebsocket/IXWebSocketVersion.h
ixwebsocket/IXProxyOptions.h
ixwebsocket/IXProxySocket.h
)

option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
Expand Down
9 changes: 8 additions & 1 deletion ixwebsocket/IXHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ namespace ix
_tlsOptions = tlsOptions;
}

void HttpClient::setProxyOptions(const ProxyOptions& proxyOptions)
{
_proxyOptions = proxyOptions;
}

void HttpClient::setForceBody(bool value)
{
_forceBody = value;
Expand Down Expand Up @@ -158,7 +163,9 @@ namespace ix

bool tls = protocol == "https";
std::string errorMsg;
_socket = createSocket(tls, -1, errorMsg, _tlsOptions);

bool proxy = !_proxyOptions.host.empty();
_socket = createSocket(tls, -1, errorMsg, _tlsOptions, proxy, _proxyOptions);

if (!_socket)
{
Expand Down
5 changes: 5 additions & 0 deletions ixwebsocket/IXHttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include "IXHttp.h"
#include "IXProxyOptions.h"
#include "IXSocket.h"
#include "IXSocketTLSOptions.h"
#include "IXWebSocketHttpHeaders.h"
Expand Down Expand Up @@ -80,6 +81,9 @@ namespace ix
// TLS
void setTLSOptions(const SocketTLSOptions& tlsOptions);

// Proxy
void setProxyOptions(const ProxyOptions& proxyOptions);

std::string serializeHttpParameters(const HttpParameters& httpParameters);

std::string serializeHttpFormDataParameters(
Expand Down Expand Up @@ -117,6 +121,7 @@ namespace ix
// might be called recursively to follow HTTP redirections

SocketTLSOptions _tlsOptions;
ProxyOptions _proxyOptions;

bool _forceBody;
};
Expand Down
1 change: 1 addition & 0 deletions ixwebsocket/IXProxyOptions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "IXProxyOptions.h"
23 changes: 23 additions & 0 deletions ixwebsocket/IXProxyOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <string>

enum class SocksVersion
{
SOCKS4 = 0,
SOCKS4a = 1,
SOCKS5 = 2,
SOCKS5h = 3,
};

struct ProxyOptions
{
public:
std::string host;
unsigned short port;
SocksVersion socksVersion;
std::string userId;
std::string username;
std::string password;
bool auth;
};
Loading