Compare commits
6 Commits
bsergean-p
...
v11.3.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f2955ef78 | ||
|
|
882081536c | ||
|
|
74bb85efe9 | ||
|
|
e66437b560 | ||
|
|
97aa1f956a | ||
|
|
3f1fc6906c |
@@ -1,5 +1,8 @@
|
|||||||
find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h)
|
find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h)
|
||||||
|
|
||||||
|
# mbedtls-3.0 changed headers files, and we need to ifdef'out a few things
|
||||||
|
find_path(MBEDTLS_VERSION_GREATER_THAN_3 mbedtls/build_info.h)
|
||||||
|
|
||||||
find_library(MBEDTLS_LIBRARY mbedtls)
|
find_library(MBEDTLS_LIBRARY mbedtls)
|
||||||
find_library(MBEDX509_LIBRARY mbedx509)
|
find_library(MBEDX509_LIBRARY mbedx509)
|
||||||
find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
|
find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
|
||||||
|
|||||||
@@ -195,6 +195,11 @@ if (USE_TLS)
|
|||||||
# This MBEDTLS_FOUND check is to help find a cmake manually configured MbedTLS
|
# This MBEDTLS_FOUND check is to help find a cmake manually configured MbedTLS
|
||||||
if (NOT MBEDTLS_FOUND)
|
if (NOT MBEDTLS_FOUND)
|
||||||
find_package(MbedTLS REQUIRED)
|
find_package(MbedTLS REQUIRED)
|
||||||
|
|
||||||
|
if (MBEDTLS_VERSION_GREATER_THAN_3)
|
||||||
|
target_compile_definitions(ixwebsocket PRIVATE IXWEBSOCKET_USE_MBED_TLS_MIN_VERSION_3)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(ixwebsocket PUBLIC $<BUILD_INTERFACE:${MBEDTLS_INCLUDE_DIRS}>)
|
target_include_directories(ixwebsocket PUBLIC $<BUILD_INTERFACE:${MBEDTLS_INCLUDE_DIRS}>)
|
||||||
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})
|
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})
|
||||||
|
|||||||
22
appveyor.yml
22
appveyor.yml
@@ -1,22 +0,0 @@
|
|||||||
image:
|
|
||||||
- Visual Studio 2017
|
|
||||||
|
|
||||||
install:
|
|
||||||
- cd C:\Tools\vcpkg
|
|
||||||
- git pull
|
|
||||||
- .\bootstrap-vcpkg.bat
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
- cmd: call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
|
||||||
- vcpkg install zlib:x64-windows
|
|
||||||
- vcpkg install mbedtls:x64-windows
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DUSE_WS=1 -DUSE_TEST=1 -DUSE_TLS=1 -G"NMake Makefiles" ..
|
|
||||||
- nmake
|
|
||||||
- cd ..
|
|
||||||
- cd test
|
|
||||||
- ..\build\test\ixwebsocket_unittest.exe
|
|
||||||
|
|
||||||
cache: c:\tools\vcpkg\installed\
|
|
||||||
|
|
||||||
build: off
|
|
||||||
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [11.3.2] - 2021-11-24
|
||||||
|
|
||||||
|
(server) Add getters for basic Servers properties (like port, host, etc...) (#327) + fix one compiler warning
|
||||||
|
|
||||||
|
## [11.3.1] - 2021-10-22
|
||||||
|
|
||||||
|
(library/cmake) Compatible with MbedTLS 3 + fix a bug on Windows where the incorrect remote port is computed (#320)
|
||||||
|
|
||||||
## [11.3.0] - 2021-09-20
|
## [11.3.0] - 2021-09-20
|
||||||
|
|
||||||
(library/cmake) Only find OpenSSL, MbedTLS, zlib if they have not already been found, make CMake install optional (#317) + Use GNUInstallDirs in cmake (#318)
|
(library/cmake) Only find OpenSSL, MbedTLS, zlib if they have not already been found, make CMake install optional (#317) + Use GNUInstallDirs in cmake (#318)
|
||||||
|
|||||||
@@ -226,4 +226,10 @@ namespace ix
|
|||||||
200, "OK", HttpErrorCode::Ok, headers, std::string("OK"));
|
200, "OK", HttpErrorCode::Ok, headers, std::string("OK"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int HttpServer::getTimeoutSecs()
|
||||||
|
{
|
||||||
|
return _timeoutSecs;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace ix
|
|||||||
|
|
||||||
void makeDebugServer();
|
void makeDebugServer();
|
||||||
|
|
||||||
|
int getTimeoutSecs();
|
||||||
private:
|
private:
|
||||||
// Member variables
|
// Member variables
|
||||||
OnConnectionCallback _onConnectionCallback;
|
OnConnectionCallback _onConnectionCallback;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "IXNetSystem.h"
|
#include "IXNetSystem.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
@@ -278,4 +280,17 @@ namespace ix
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert network bytes to host bytes. Copied from the ASIO library
|
||||||
|
unsigned short network_to_host_short(unsigned short value)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
unsigned char* value_p = reinterpret_cast<unsigned char*>(&value);
|
||||||
|
unsigned short result = (static_cast<unsigned short>(value_p[0]) << 8)
|
||||||
|
| static_cast<unsigned short>(value_p[1]);
|
||||||
|
return result;
|
||||||
|
#else // defined(_WIN32)
|
||||||
|
return ntohs(value);
|
||||||
|
#endif // defined(_WIN32)
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
// Define our own poll on Windows, as a wrapper on top of select
|
// Define our own poll on Windows, as a wrapper on top of select
|
||||||
typedef unsigned long int nfds_t;
|
typedef unsigned long int nfds_t;
|
||||||
|
|
||||||
// mingw does not know about poll so mock it
|
// pollfd is not defined by some versions of mingw64 since _WIN32_WINNT is too low
|
||||||
#if defined(__GNUC__)
|
#if _WIN32_WINNT < 0x0600
|
||||||
struct pollfd
|
struct pollfd
|
||||||
{
|
{
|
||||||
int fd; /* file descriptor */
|
int fd; /* file descriptor */
|
||||||
@@ -81,4 +81,6 @@ namespace ix
|
|||||||
|
|
||||||
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
|
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
|
||||||
int inet_pton(int af, const char* src, void* dst);
|
int inet_pton(int af, const char* src, void* dst);
|
||||||
|
|
||||||
|
unsigned short network_to_host_short(unsigned short value);
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
|||||||
@@ -132,7 +132,11 @@ namespace ix
|
|||||||
errMsg = "Cannot parse cert file '" + _tlsOptions.certFile + "'";
|
errMsg = "Cannot parse cert file '" + _tlsOptions.certFile + "'";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#ifdef IXWEBSOCKET_USE_MBED_TLS_MIN_VERSION_3
|
||||||
|
if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "", mbedtls_ctr_drbg_random, &_ctr_drbg) < 0)
|
||||||
|
#else
|
||||||
if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "") < 0)
|
if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "") < 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
errMsg = "Cannot parse key file '" + _tlsOptions.keyFile + "'";
|
errMsg = "Cannot parse key file '" + _tlsOptions.keyFile + "'";
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include <mbedtls/debug.h>
|
#include <mbedtls/debug.h>
|
||||||
#include <mbedtls/entropy.h>
|
#include <mbedtls/entropy.h>
|
||||||
#include <mbedtls/error.h>
|
#include <mbedtls/error.h>
|
||||||
#include <mbedtls/net.h>
|
#include <mbedtls/net_sockets.h>
|
||||||
#include <mbedtls/platform.h>
|
#include <mbedtls/platform.h>
|
||||||
#include <mbedtls/x509.h>
|
#include <mbedtls/x509.h>
|
||||||
#include <mbedtls/x509_crt.h>
|
#include <mbedtls/x509_crt.h>
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ namespace ix
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
remotePort = client.sin_port;
|
remotePort = ix::network_to_host_short(client.sin_port);
|
||||||
remoteIp = remoteIp4;
|
remoteIp = remoteIp4;
|
||||||
}
|
}
|
||||||
else // AF_INET6
|
else // AF_INET6
|
||||||
@@ -371,7 +371,7 @@ namespace ix
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
remotePort = client.sin_port;
|
remotePort = ix::network_to_host_short(client.sin_port);
|
||||||
remoteIp = remoteIp6;
|
remoteIp = remoteIp6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,4 +461,29 @@ namespace ix
|
|||||||
// so wake up the thread responsible for that
|
// so wake up the thread responsible for that
|
||||||
_conditionVariableGC.notify_one();
|
_conditionVariableGC.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SocketServer::getPort()
|
||||||
|
{
|
||||||
|
return _port;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SocketServer::getHost()
|
||||||
|
{
|
||||||
|
return _host;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SocketServer::getBacklog()
|
||||||
|
{
|
||||||
|
return _backlog;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t SocketServer::getMaxConnections()
|
||||||
|
{
|
||||||
|
return _maxConnections;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SocketServer::getAddressFamily()
|
||||||
|
{
|
||||||
|
return _addressFamily;
|
||||||
|
}
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
|||||||
@@ -60,6 +60,11 @@ namespace ix
|
|||||||
|
|
||||||
void setTLSOptions(const SocketTLSOptions& socketTLSOptions);
|
void setTLSOptions(const SocketTLSOptions& socketTLSOptions);
|
||||||
|
|
||||||
|
int getPort();
|
||||||
|
std::string getHost();
|
||||||
|
int getBacklog();
|
||||||
|
std::size_t getMaxConnections();
|
||||||
|
int getAddressFamily();
|
||||||
protected:
|
protected:
|
||||||
// Logging
|
// Logging
|
||||||
void logError(const std::string& str);
|
void logError(const std::string& str);
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ namespace ix
|
|||||||
size_t wireSize,
|
size_t wireSize,
|
||||||
bool decompressionError,
|
bool decompressionError,
|
||||||
WebSocketTransport::MessageKind messageKind) {
|
WebSocketTransport::MessageKind messageKind) {
|
||||||
WebSocketMessageType webSocketMessageType;
|
WebSocketMessageType webSocketMessageType{WebSocketMessageType::Error};
|
||||||
switch (messageKind)
|
switch (messageKind)
|
||||||
{
|
{
|
||||||
case WebSocketTransport::MessageKind::MSG_TEXT:
|
case WebSocketTransport::MessageKind::MSG_TEXT:
|
||||||
|
|||||||
@@ -211,4 +211,19 @@ namespace ix
|
|||||||
start();
|
start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WebSocketServer::getHandshakeTimeoutSecs()
|
||||||
|
{
|
||||||
|
return _handshakeTimeoutSecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebSocketServer::isPongEnabled()
|
||||||
|
{
|
||||||
|
return _enablePong;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebSocketServer::isPerMessageDeflateEnabled()
|
||||||
|
{
|
||||||
|
return _enablePerMessageDeflate;
|
||||||
|
}
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ namespace ix
|
|||||||
|
|
||||||
const static int kDefaultHandShakeTimeoutSecs;
|
const static int kDefaultHandShakeTimeoutSecs;
|
||||||
|
|
||||||
|
int getHandshakeTimeoutSecs();
|
||||||
|
bool isPongEnabled();
|
||||||
|
bool isPerMessageDeflateEnabled();
|
||||||
private:
|
private:
|
||||||
// Member variables
|
// Member variables
|
||||||
int _handshakeTimeoutSecs;
|
int _handshakeTimeoutSecs;
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "11.3.0"
|
#define IX_WEBSOCKET_VERSION "11.3.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user