(cobra connection and bots) set an HTTP header when connecting to help with debugging bots

This commit is contained in:
Benjamin Sergeant
2020-09-18 15:11:12 -07:00
parent 39c84c7d51
commit d525c28907
7 changed files with 17 additions and 4 deletions

View File

@ -8,6 +8,7 @@
#include <ixwebsocket/IXSocketTLSOptions.h>
#include <ixwebsocket/IXWebSocketPerMessageDeflateOptions.h>
#include <ixwebsocket/IXWebSocketHttpHeaders.h>
namespace ix
{
@ -19,6 +20,7 @@ namespace ix
std::string rolesecret;
WebSocketPerMessageDeflateOptions webSocketPerMessageDeflateOptions;
SocketTLSOptions socketTLSOptions;
WebSocketHttpHeaders headers;
CobraConfig(const std::string& a = std::string(),
const std::string& e = std::string(),

View File

@ -255,7 +255,8 @@ namespace ix
const std::string& rolename,
const std::string& rolesecret,
const WebSocketPerMessageDeflateOptions& webSocketPerMessageDeflateOptions,
const SocketTLSOptions& socketTLSOptions)
const SocketTLSOptions& socketTLSOptions,
const WebSocketHttpHeaders& headers)
{
_roleName = rolename;
_roleSecret = rolesecret;
@ -269,6 +270,7 @@ namespace ix
_webSocket->setUrl(url);
_webSocket->setPerMessageDeflateOptions(webSocketPerMessageDeflateOptions);
_webSocket->setTLSOptions(socketTLSOptions);
_webSocket->setExtraHeaders(headers);
// Send a websocket ping every N seconds (N = 30) now
// This should keep the connection open and prevent some load balancers such as
@ -283,7 +285,8 @@ namespace ix
config.rolename,
config.rolesecret,
config.webSocketPerMessageDeflateOptions,
config.socketTLSOptions);
config.socketTLSOptions,
config.headers);
}
//

View File

@ -56,7 +56,8 @@ namespace ix
const std::string& rolename,
const std::string& rolesecret,
const WebSocketPerMessageDeflateOptions& webSocketPerMessageDeflateOptions,
const SocketTLSOptions& socketTLSOptions);
const SocketTLSOptions& socketTLSOptions,
const WebSocketHttpHeaders& headers);
void configure(const ix::CobraConfig& config);