Compare commits
6 Commits
feature/te
...
feature/or
Author | SHA1 | Date | |
---|---|---|---|
|
4027f9282b | ||
|
eb9a7bed76 | ||
|
d20864d7d1 | ||
|
f184a7adef | ||
|
dc7b986e10 | ||
|
1e3560014f |
@@ -287,8 +287,8 @@ if (IXWEBSOCKET_INSTALL)
|
|||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ixwebsocket/
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ixwebsocket/
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/ixwebsocket-config.cmake.in" "${CMAKE_BINARY_DIR}/ixwebsocket-config.cmake" @ONLY)
|
configure_file("${CMAKE_CURRENT_LIST_DIR}/ixwebsocket-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ixwebsocket-config.cmake" @ONLY)
|
||||||
install(FILES "${CMAKE_BINARY_DIR}/ixwebsocket-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ixwebsocket")
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ixwebsocket-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ixwebsocket")
|
||||||
|
|
||||||
install(EXPORT ixwebsocket
|
install(EXPORT ixwebsocket
|
||||||
FILE ixwebsocket-targets.cmake
|
FILE ixwebsocket-targets.cmake
|
||||||
|
@@ -209,6 +209,12 @@ namespace ix
|
|||||||
ss << "User-Agent: " << userAgent() << "\r\n";
|
ss << "User-Agent: " << userAgent() << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set an origin header if missing
|
||||||
|
if (args->extraHeaders.find("Origin") == args->extraHeaders.end())
|
||||||
|
{
|
||||||
|
ss << "Origin: " << protocol << "://" << host << ":" << port << "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (verb == kPost || verb == kPut || verb == kPatch || _forceBody)
|
if (verb == kPost || verb == kPut || verb == kPatch || _forceBody)
|
||||||
{
|
{
|
||||||
// Set request compression header
|
// Set request compression header
|
||||||
|
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
@@ -219,6 +219,10 @@ namespace ix
|
|||||||
if (_gcThread.joinable())
|
if (_gcThread.joinable())
|
||||||
{
|
{
|
||||||
_stopGc = true;
|
_stopGc = true;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock{ _conditionVariableMutexGC };
|
||||||
|
_canContinueGC = true;
|
||||||
|
}
|
||||||
_conditionVariableGC.notify_one();
|
_conditionVariableGC.notify_one();
|
||||||
_gcThread.join();
|
_gcThread.join();
|
||||||
_stopGc = false;
|
_stopGc = false;
|
||||||
@@ -451,7 +455,10 @@ namespace ix
|
|||||||
if (!_stopGc)
|
if (!_stopGc)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(_conditionVariableMutexGC);
|
std::unique_lock<std::mutex> lock(_conditionVariableMutexGC);
|
||||||
_conditionVariableGC.wait(lock);
|
if(!_canContinueGC) {
|
||||||
|
_conditionVariableGC.wait(lock, [this]{ return _canContinueGC; });
|
||||||
|
}
|
||||||
|
_canContinueGC = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,6 +472,10 @@ namespace ix
|
|||||||
{
|
{
|
||||||
// a connection got terminated, we can run the connection thread GC,
|
// a connection got terminated, we can run the connection thread GC,
|
||||||
// so wake up the thread responsible for that
|
// so wake up the thread responsible for that
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock{ _conditionVariableMutexGC };
|
||||||
|
_canContinueGC = true;
|
||||||
|
}
|
||||||
_conditionVariableGC.notify_one();
|
_conditionVariableGC.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -126,5 +126,6 @@ namespace ix
|
|||||||
// as a connection
|
// as a connection
|
||||||
std::condition_variable _conditionVariableGC;
|
std::condition_variable _conditionVariableGC;
|
||||||
std::mutex _conditionVariableMutexGC;
|
std::mutex _conditionVariableMutexGC;
|
||||||
|
bool _canContinueGC{ false };
|
||||||
};
|
};
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@@ -87,6 +87,7 @@ namespace ix
|
|||||||
WebSocketInitResult WebSocketHandshake::clientHandshake(
|
WebSocketInitResult WebSocketHandshake::clientHandshake(
|
||||||
const std::string& url,
|
const std::string& url,
|
||||||
const WebSocketHttpHeaders& extraHeaders,
|
const WebSocketHttpHeaders& extraHeaders,
|
||||||
|
const std::string& protocol,
|
||||||
const std::string& host,
|
const std::string& host,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
int port,
|
int port,
|
||||||
@@ -125,6 +126,12 @@ namespace ix
|
|||||||
ss << "User-Agent: " << userAgent() << "\r\n";
|
ss << "User-Agent: " << userAgent() << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set an origin header if missing
|
||||||
|
if (extraHeaders.find("Origin") == extraHeaders.end())
|
||||||
|
{
|
||||||
|
ss << "Origin: " << protocol << "://" << host << ":" << port << "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& it : extraHeaders)
|
for (auto& it : extraHeaders)
|
||||||
{
|
{
|
||||||
ss << it.first << ": " << it.second << "\r\n";
|
ss << it.first << ": " << it.second << "\r\n";
|
||||||
|
@@ -31,6 +31,7 @@ namespace ix
|
|||||||
|
|
||||||
WebSocketInitResult clientHandshake(const std::string& url,
|
WebSocketInitResult clientHandshake(const std::string& url,
|
||||||
const WebSocketHttpHeaders& extraHeaders,
|
const WebSocketHttpHeaders& extraHeaders,
|
||||||
|
const std::string& protocol,
|
||||||
const std::string& host,
|
const std::string& host,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
int port,
|
int port,
|
||||||
|
@@ -71,10 +71,10 @@ namespace ix
|
|||||||
, _closingTimePoint(std::chrono::steady_clock::now())
|
, _closingTimePoint(std::chrono::steady_clock::now())
|
||||||
, _enablePong(kDefaultEnablePong)
|
, _enablePong(kDefaultEnablePong)
|
||||||
, _pingIntervalSecs(kDefaultPingIntervalSecs)
|
, _pingIntervalSecs(kDefaultPingIntervalSecs)
|
||||||
|
, _pongReceived(false)
|
||||||
, _setCustomMessage(false)
|
, _setCustomMessage(false)
|
||||||
, _kPingMessage("ixwebsocket::heartbeat")
|
, _kPingMessage("ixwebsocket::heartbeat")
|
||||||
, _pingType(SendMessageKind::Ping)
|
, _pingType(SendMessageKind::Ping)
|
||||||
, _pongReceived(false)
|
|
||||||
, _pingCount(0)
|
, _pingCount(0)
|
||||||
, _lastSendPingTimePoint(std::chrono::steady_clock::now())
|
, _lastSendPingTimePoint(std::chrono::steady_clock::now())
|
||||||
{
|
{
|
||||||
@@ -140,7 +140,7 @@ namespace ix
|
|||||||
_enablePerMessageDeflate);
|
_enablePerMessageDeflate);
|
||||||
|
|
||||||
result = webSocketHandshake.clientHandshake(
|
result = webSocketHandshake.clientHandshake(
|
||||||
remoteUrl, headers, host, path, port, timeoutSecs);
|
remoteUrl, headers, protocol, host, path, port, timeoutSecs);
|
||||||
|
|
||||||
if (result.http_status >= 300 && result.http_status < 400)
|
if (result.http_status >= 300 && result.http_status < 400)
|
||||||
{
|
{
|
||||||
@@ -700,6 +700,7 @@ namespace ix
|
|||||||
if (_readyState != ReadyState::CLOSING)
|
if (_readyState != ReadyState::CLOSING)
|
||||||
{
|
{
|
||||||
// send back the CLOSE frame
|
// send back the CLOSE frame
|
||||||
|
setReadyState(ReadyState::CLOSING);
|
||||||
sendCloseFrame(code, reason);
|
sendCloseFrame(code, reason);
|
||||||
|
|
||||||
wakeUpFromPoll(SelectInterrupt::kCloseRequest);
|
wakeUpFromPoll(SelectInterrupt::kCloseRequest);
|
||||||
@@ -1072,7 +1073,10 @@ namespace ix
|
|||||||
else if (ret <= 0)
|
else if (ret <= 0)
|
||||||
{
|
{
|
||||||
closeSocket();
|
closeSocket();
|
||||||
|
if (_readyState != ReadyState::CLOSING)
|
||||||
|
{
|
||||||
setReadyState(ReadyState::CLOSED);
|
setReadyState(ReadyState::CLOSED);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -13,16 +13,24 @@ all: brew
|
|||||||
|
|
||||||
install: brew
|
install: brew
|
||||||
|
|
||||||
|
-DCMAKE_INSTALL_PREFIX=/opt/homebrew
|
||||||
|
|
||||||
# Use -DCMAKE_INSTALL_PREFIX= to install into another location
|
# Use -DCMAKE_INSTALL_PREFIX= to install into another location
|
||||||
# on osx it is good practice to make /usr/local user writable
|
# on osx it is good practice to make /usr/local user writable
|
||||||
# sudo chown -R `whoami`/staff /usr/local
|
# sudo chown -R `whoami`/staff /usr/local
|
||||||
#
|
#
|
||||||
|
# Those days (since Apple Silicon mac shipped), on macOS homebrew installs in /opt/homebrew, and /usr/local is readonly
|
||||||
|
#
|
||||||
# Release, Debug, MinSizeRel, RelWithDebInfo are the build types
|
# Release, Debug, MinSizeRel, RelWithDebInfo are the build types
|
||||||
#
|
#
|
||||||
# Default rule does not use python as that requires first time users to have Python3 installed
|
# Default rule does not use python as that requires first time users to have Python3 installed
|
||||||
#
|
#
|
||||||
brew:
|
brew:
|
||||||
|
ifeq ($(shell uname),Darwin)
|
||||||
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_PREFIX=/opt/homebrew -DCMAKE_UNITY_BUILD=OFF -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; ninja install)
|
||||||
|
else
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=OFF -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=OFF -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; ninja install)
|
||||||
|
endif
|
||||||
|
|
||||||
# Docker default target. We've had problems with OpenSSL and TLS 1.3 (on the
|
# Docker default target. We've had problems with OpenSSL and TLS 1.3 (on the
|
||||||
# server side ?) and I can't work-around it easily, so we're using mbedtls on
|
# server side ?) and I can't work-around it easily, so we're using mbedtls on
|
||||||
|
@@ -24,14 +24,13 @@ set (TEST_TARGET_NAMES
|
|||||||
# IXWebSocketBroadcastTest ## FIXME was depending on cobra / take a broadcast server from ws
|
# IXWebSocketBroadcastTest ## FIXME was depending on cobra / take a broadcast server from ws
|
||||||
IXStrCaseCompareTest
|
IXStrCaseCompareTest
|
||||||
IXExponentialBackoffTest
|
IXExponentialBackoffTest
|
||||||
|
IXWebSocketCloseTest
|
||||||
)
|
)
|
||||||
|
|
||||||
# Some unittest don't work on windows yet
|
# Some unittest don't work on windows yet
|
||||||
# Windows without TLS does not have hmac yet
|
# Windows without TLS does not have hmac yet
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
list(APPEND TEST_TARGET_NAMES
|
list(APPEND TEST_TARGET_NAMES
|
||||||
IXWebSocketCloseTest
|
|
||||||
|
|
||||||
# Fail on Windows in CI probably because the pathing is wrong and
|
# Fail on Windows in CI probably because the pathing is wrong and
|
||||||
# some resource files cannot be found
|
# some resource files cannot be found
|
||||||
IXHttpServerTest
|
IXHttpServerTest
|
||||||
|
Reference in New Issue
Block a user