Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a3ffcb098 |
@@ -11,7 +11,7 @@ AlignTrailingComments: true
|
|||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
AllowShortBlocksOnASingleLine: false
|
AllowShortBlocksOnASingleLine: false
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
AllowShortFunctionsOnASingleLine: false
|
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||||
AllowShortIfStatementsOnASingleLine: true
|
AllowShortIfStatementsOnASingleLine: true
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
AlwaysBreakTemplateDeclarations: true
|
AlwaysBreakTemplateDeclarations: true
|
||||||
@@ -42,6 +42,5 @@ NamespaceIndentation: All
|
|||||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
SpaceAfterTemplateKeyword: false
|
SpaceAfterTemplateKeyword: false
|
||||||
SpaceAfterCStyleCast: true
|
|
||||||
Standard: Cpp11
|
Standard: Cpp11
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
|||||||
@@ -5,3 +5,8 @@ repos:
|
|||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
|
|
||||||
|
- repo: https://github.com/pocc/pre-commit-hooks
|
||||||
|
rev: ''
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ set (CMAKE_CXX_STANDARD 14)
|
|||||||
set (CXX_STANDARD_REQUIRED ON)
|
set (CXX_STANDARD_REQUIRED ON)
|
||||||
set (CMAKE_CXX_EXTENSIONS OFF)
|
set (CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
if (UNIX)
|
# -Wshorten-64-to-32 does not work with clang
|
||||||
|
if (NOT WIN32)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -114,7 +115,10 @@ endif()
|
|||||||
|
|
||||||
set(USE_OPEN_SSL FALSE)
|
set(USE_OPEN_SSL FALSE)
|
||||||
if (USE_TLS)
|
if (USE_TLS)
|
||||||
|
add_definitions(-DIXWEBSOCKET_USE_TLS)
|
||||||
|
|
||||||
if (USE_MBED_TLS)
|
if (USE_MBED_TLS)
|
||||||
|
add_definitions(-DIXWEBSOCKET_USE_MBED_TLS)
|
||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketMbedTLS.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketMbedTLS.h)
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketMbedTLS.cpp)
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketMbedTLS.cpp)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
@@ -124,6 +128,7 @@ if (USE_TLS)
|
|||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketSChannel.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketSChannel.h)
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketSChannel.cpp)
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketSChannel.cpp)
|
||||||
else()
|
else()
|
||||||
|
add_definitions(-DIXWEBSOCKET_USE_OPEN_SSL)
|
||||||
set(USE_OPEN_SSL TRUE)
|
set(USE_OPEN_SSL TRUE)
|
||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketOpenSSL.cpp)
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketOpenSSL.cpp)
|
||||||
@@ -135,17 +140,6 @@ add_library( ixwebsocket STATIC
|
|||||||
${IXWEBSOCKET_HEADERS}
|
${IXWEBSOCKET_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (USE_TLS)
|
|
||||||
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_TLS)
|
|
||||||
if (USE_MBED_TLS)
|
|
||||||
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_MBED_TLS)
|
|
||||||
elseif (APPLE)
|
|
||||||
elseif (WIN32)
|
|
||||||
else()
|
|
||||||
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_OPEN_SSL)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (APPLE AND USE_TLS AND NOT USE_MBED_TLS)
|
if (APPLE AND USE_TLS AND NOT USE_MBED_TLS)
|
||||||
target_link_libraries(ixwebsocket "-framework foundation" "-framework security")
|
target_link_libraries(ixwebsocket "-framework foundation" "-framework security")
|
||||||
endif()
|
endif()
|
||||||
@@ -177,7 +171,7 @@ if (USE_TLS AND USE_MBED_TLS)
|
|||||||
target_link_libraries(ixwebsocket mbedtls)
|
target_link_libraries(ixwebsocket mbedtls)
|
||||||
else()
|
else()
|
||||||
find_package(MbedTLS REQUIRED)
|
find_package(MbedTLS REQUIRED)
|
||||||
target_include_directories(ixwebsocket PUBLIC ${MBEDTLS_INCLUDE_DIRS})
|
include_directories(${MBEDTLS_INCLUDE_DIRS})
|
||||||
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})
|
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -210,15 +204,6 @@ install(TARGETS ixwebsocket
|
|||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ixwebsocket/
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ixwebsocket/
|
||||||
)
|
)
|
||||||
|
|
||||||
if (USE_WS OR USE_TEST)
|
if (USE_WS)
|
||||||
add_subdirectory(ixcore)
|
add_subdirectory(ws)
|
||||||
add_subdirectory(ixcrypto)
|
|
||||||
add_subdirectory(ixcobra)
|
|
||||||
|
|
||||||
if (USE_WS)
|
|
||||||
add_subdirectory(ws)
|
|
||||||
endif()
|
|
||||||
if (USE_TEST)
|
|
||||||
add_subdirectory(test)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
6.2.1
|
6.1.0
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
## Hello world
|
## Hello world
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
IXWebSocket is a C++ library for WebSocket client and server development. It has minimal dependencies (no boost), is very simple to use and support everything you'll likely need for websocket dev (SSL, deflate compression, compiles on most platforms, etc...). HTTP client and server code is also available, but it hasn't received as much testing.
|
IXWebSocket is a C++ library for WebSocket client and server development. It has minimal dependencies (no boost), is very simple to use and support everything you'll likely need for websocket dev (SSL, deflate compression, compiles on most platforms, etc...). HTTP client and server code is also available, but it hasn't received as much testing.
|
||||||
|
|
||||||
|
|||||||
16
appveyor.yml
16
appveyor.yml
@@ -2,21 +2,13 @@ image:
|
|||||||
- Visual Studio 2017
|
- Visual Studio 2017
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- cd C:\Tools\vcpkg
|
- ls -al
|
||||||
- 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"
|
- cmd: call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
- vcpkg install zlib:x64-windows
|
- cd test
|
||||||
- vcpkg install mbedtls:x64-windows
|
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd 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" ..
|
- cmake -G"NMake Makefiles" ..
|
||||||
- nmake
|
- nmake
|
||||||
- cd ..
|
- ixwebsocket_unittest.exe
|
||||||
- cd test
|
|
||||||
- ..\build\test\ixwebsocket_unittest.exe
|
|
||||||
|
|
||||||
cache: c:\tools\vcpkg\installed\
|
|
||||||
|
|
||||||
build: off
|
build: off
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## [6.2.1] - 2019-09-17
|
|
||||||
|
|
||||||
- On error while doing a client handshake, additionally display port number next to the host name
|
|
||||||
|
|
||||||
## [6.2.0] - 2019-09-09
|
|
||||||
|
|
||||||
- websocket and http server: server does not close the bound client socket in many cases
|
|
||||||
- improve some websocket error messages
|
|
||||||
- add a utility function with unittest to parse status line and stop using scanf which triggers warnings on Windows
|
|
||||||
- update ws CLI11 (our command line argument parsing library) to the latest, which fix a compiler bug about optional
|
|
||||||
|
|
||||||
## [6.1.0] - 2019-09-08
|
## [6.1.0] - 2019-09-08
|
||||||
|
|
||||||
- move poll wrapper on top of select (only used on Windows) to the ix namespace
|
- move poll wrapper on top of select (only used on Windows) to the ix namespace
|
||||||
@@ -79,7 +68,7 @@ Close connections when reserved bits are used (fix autobahn test: 3.X Reserved B
|
|||||||
- add utf-8 validation code, not hooked up properly yet
|
- add utf-8 validation code, not hooked up properly yet
|
||||||
- Ping received with a payload too large (> 125 bytes) trigger a connection closure
|
- Ping received with a payload too large (> 125 bytes) trigger a connection closure
|
||||||
- cobra / add tracking about published messages
|
- cobra / add tracking about published messages
|
||||||
- cobra / publish returns a message id, that can be used when
|
- cobra / publish returns a message id, that can be used when
|
||||||
- cobra / new message type in the message received handler when publish/ok is received (can be used to implement an ack system).
|
- cobra / new message type in the message received handler when publish/ok is received (can be used to implement an ack system).
|
||||||
|
|
||||||
## [5.0.9] - 2019-08-30
|
## [5.0.9] - 2019-08-30
|
||||||
@@ -93,7 +82,7 @@ ws connect --max_wait 5000 ws://example.com # will only wait 5 seconds max betwe
|
|||||||
|
|
||||||
## [5.0.7] - 2019-08-23
|
## [5.0.7] - 2019-08-23
|
||||||
- WebSocket: add new option to pass in extra HTTP headers when connecting.
|
- WebSocket: add new option to pass in extra HTTP headers when connecting.
|
||||||
- `ws connect` add new option (-H, works like [curl](https://stackoverflow.com/questions/356705/how-to-send-a-header-using-a-http-request-through-a-curl-call)) to pass in extra HTTP headers when connecting
|
- `ws connect` add new option (-H, works like [curl](https://stackoverflow.com/questions/356705/how-to-send-a-header-using-a-http-request-through-a-curl-call)) to pass in extra HTTP headers when connecting
|
||||||
|
|
||||||
If you run against `ws echo_server` you will see the headers being received printed in the terminal.
|
If you run against `ws echo_server` you will see the headers being received printed in the terminal.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ Options for building:
|
|||||||
* `-DUSE_MBED_TLS=1` will use [mbedlts](https://tls.mbed.org/) for the TLS support (default on Windows)
|
* `-DUSE_MBED_TLS=1` will use [mbedlts](https://tls.mbed.org/) for the TLS support (default on Windows)
|
||||||
* `-DUSE_WS=1` will build the ws interactive command line tool
|
* `-DUSE_WS=1` will build the ws interactive command line tool
|
||||||
|
|
||||||
If you are on Windows, look at the [appveyor](https://github.com/machinezone/IXWebSocket/blob/master/appveyor.yml) file that has instructions for building dependencies.
|
|
||||||
|
|
||||||
### vcpkg
|
### vcpkg
|
||||||
|
|
||||||
It is possible to get IXWebSocket through Microsoft [vcpkg](https://github.com/microsoft/vcpkg).
|
It is possible to get IXWebSocket through Microsoft [vcpkg](https://github.com/microsoft/vcpkg).
|
||||||
@@ -33,7 +31,7 @@ vcpkg install ixwebsocket
|
|||||||
|
|
||||||
### Conan
|
### Conan
|
||||||
|
|
||||||
Support for building with conan was contributed by Olivia Zoe (thanks !). The package name to reference is `IXWebSocket/5.0.0@LunarWatcher/stable`. The package is in the process to be published to the official conan package repo, but in the meantime, it can be accessed by adding a new remote
|
Support for building with conan was contributed by Olivia Zoe (thanks !). The package name to reference is `IXWebSocket/5.0.0@LunarWatcher/stable`. The package is in the process to be published to the official conan package repo, but in the meantime, it can be accessed by adding a new remote
|
||||||
|
|
||||||
```
|
```
|
||||||
conan remote add remote_name_here https://api.bintray.com/conan/oliviazoe0/conan-packages
|
conan remote add remote_name_here https://api.bintray.com/conan/oliviazoe0/conan-packages
|
||||||
@@ -59,3 +57,6 @@ app@ca2340eb9106:~$ ws --help
|
|||||||
ws is a websocket tool
|
ws is a websocket tool
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ Wait time(ms): 10000
|
|||||||
The waiting time is capped by default at 10s between 2 attempts, but that value can be changed and queried.
|
The waiting time is capped by default at 10s between 2 attempts, but that value can be changed and queried.
|
||||||
|
|
||||||
```
|
```
|
||||||
webSocket.setMaxWaitBetweenReconnectionRetries(5 * 1000); // 5000ms = 5s
|
webSocket.setMaxWaitBetweenReconnectionRetries(5 * 1000); // 5000ms = 5s
|
||||||
uint32_t m = webSocket.getMaxWaitBetweenReconnectionRetries();
|
uint32_t m = webSocket.getMaxWaitBetweenReconnectionRetries();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
#
|
|
||||||
# Author: Benjamin Sergeant
|
|
||||||
# Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
|
|
||||||
set (IXCOBRA_SOURCES
|
|
||||||
ixcobra/IXCobraConnection.cpp
|
|
||||||
ixcobra/IXCobraMetricsThreadedPublisher.cpp
|
|
||||||
ixcobra/IXCobraMetricsPublisher.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set (IXCOBRA_HEADERS
|
|
||||||
ixcobra/IXCobraConnection.h
|
|
||||||
ixcobra/IXCobraMetricsThreadedPublisher.h
|
|
||||||
ixcobra/IXCobraMetricsPublisher.h
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(ixcobra STATIC
|
|
||||||
${IXCOBRA_SOURCES}
|
|
||||||
${IXCOBRA_HEADERS}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(IXCOBRA_INCLUDE_DIRS
|
|
||||||
.
|
|
||||||
..
|
|
||||||
../ixcore
|
|
||||||
../ixcrypto
|
|
||||||
../third_party)
|
|
||||||
|
|
||||||
target_include_directories( ixcobra PUBLIC ${IXCOBRA_INCLUDE_DIRS} )
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#
|
|
||||||
# Author: Benjamin Sergeant
|
|
||||||
# Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
|
|
||||||
set (IXCORE_SOURCES
|
|
||||||
ixcore/utils/IXCoreLogger.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set (IXCORE_HEADERS
|
|
||||||
ixcore/utils/IXCoreLogger.h
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(ixcore STATIC
|
|
||||||
${IXCORE_SOURCES}
|
|
||||||
${IXCORE_HEADERS}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories( ixcore PUBLIC . )
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
#
|
|
||||||
# Author: Benjamin Sergeant
|
|
||||||
# Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../CMake;${CMAKE_MODULE_PATH}")
|
|
||||||
|
|
||||||
set (IXCRYPTO_SOURCES
|
|
||||||
ixcrypto/IXHMac.cpp
|
|
||||||
ixcrypto/IXBase64.cpp
|
|
||||||
ixcrypto/IXUuid.cpp
|
|
||||||
ixcrypto/IXHash.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set (IXCRYPTO_HEADERS
|
|
||||||
ixcrypto/IXHMac.h
|
|
||||||
ixcrypto/IXBase64.h
|
|
||||||
ixcrypto/IXUuid.h
|
|
||||||
ixcrypto/IXHash.h
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(ixcrypto STATIC
|
|
||||||
${IXCRYPTO_SOURCES}
|
|
||||||
${IXCRYPTO_HEADERS}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(IXCRYPTO_INCLUDE_DIRS
|
|
||||||
.
|
|
||||||
../ixcore)
|
|
||||||
|
|
||||||
target_include_directories( ixcrypto PUBLIC ${IXCRYPTO_INCLUDE_DIRS} )
|
|
||||||
|
|
||||||
# hmac computation needs a crypto library
|
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
set(USE_MBED_TLS TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_definitions(ixcrypto PUBLIC IXCRYPTO_USE_TLS)
|
|
||||||
if (USE_MBED_TLS)
|
|
||||||
find_package(MbedTLS REQUIRED)
|
|
||||||
target_include_directories(ixcrypto PUBLIC ${MBEDTLS_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(ixcrypto ${MBEDTLS_LIBRARIES})
|
|
||||||
target_compile_definitions(ixcrypto PUBLIC IXCRYPTO_USE_MBED_TLS)
|
|
||||||
elseif (APPLE)
|
|
||||||
elseif (WIN32)
|
|
||||||
else()
|
|
||||||
find_package(OpenSSL REQUIRED)
|
|
||||||
add_definitions(${OPENSSL_DEFINITIONS})
|
|
||||||
message(STATUS "OpenSSL: " ${OPENSSL_VERSION})
|
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
||||||
target_link_libraries(ixcrypto ${OPENSSL_LIBRARIES})
|
|
||||||
target_compile_definitions(ixcrypto PUBLIC IXCRYPTO_USE_OPEN_SSL)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ namespace ix
|
|||||||
int port = _port;
|
int port = _port;
|
||||||
std::string hostname(_hostname);
|
std::string hostname(_hostname);
|
||||||
|
|
||||||
// We make the background thread doing the work a shared pointer
|
// We make the background thread doing the work a shared pointer
|
||||||
// instead of a member variable, because it can keep running when
|
// instead of a member variable, because it can keep running when
|
||||||
// this object goes out of scope, in case of cancellation
|
// this object goes out of scope, in case of cancellation
|
||||||
auto t = std::make_shared<std::thread>(&DNSLookup::run, this, self, hostname, port);
|
auto t = std::make_shared<std::thread>(&DNSLookup::run, this, self, hostname, port);
|
||||||
|
|||||||
@@ -27,36 +27,6 @@ namespace ix
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, int> Http::parseStatusLine(const std::string& line)
|
|
||||||
{
|
|
||||||
// Request-Line = Method SP Request-URI SP HTTP-Version CRLF
|
|
||||||
std::string token;
|
|
||||||
std::stringstream tokenStream(line);
|
|
||||||
std::vector<std::string> tokens;
|
|
||||||
|
|
||||||
// Split by ' '
|
|
||||||
while (std::getline(tokenStream, token, ' '))
|
|
||||||
{
|
|
||||||
tokens.push_back(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string httpVersion;
|
|
||||||
if (tokens.size() >= 1)
|
|
||||||
{
|
|
||||||
httpVersion = trim(tokens[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int statusCode = -1;
|
|
||||||
if (tokens.size() >= 2)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << trim(tokens[1]);
|
|
||||||
ss >> statusCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::make_pair(httpVersion, statusCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::tuple<std::string, std::string, std::string> Http::parseRequestLine(const std::string& line)
|
std::tuple<std::string, std::string, std::string> Http::parseRequestLine(const std::string& line)
|
||||||
{
|
{
|
||||||
// Request-Line = Method SP Request-URI SP HTTP-Version CRLF
|
// Request-Line = Method SP Request-URI SP HTTP-Version CRLF
|
||||||
|
|||||||
@@ -115,8 +115,6 @@ namespace ix
|
|||||||
std::shared_ptr<Socket> socket);
|
std::shared_ptr<Socket> socket);
|
||||||
static bool sendResponse(HttpResponsePtr response, std::shared_ptr<Socket> socket);
|
static bool sendResponse(HttpResponsePtr response, std::shared_ptr<Socket> socket);
|
||||||
|
|
||||||
static std::pair<std::string, int> parseStatusLine(
|
|
||||||
const std::string& line);
|
|
||||||
static std::tuple<std::string, std::string, std::string> parseRequestLine(
|
static std::tuple<std::string, std::string, std::string> parseRequestLine(
|
||||||
const std::string& line);
|
const std::string& line);
|
||||||
static std::string trim(const std::string& str);
|
static std::string trim(const std::string& str);
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ namespace ix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connectionState->setTerminated();
|
connectionState->setTerminated();
|
||||||
Socket::closeSocket(fd);
|
|
||||||
|
|
||||||
_connectedClientsCount--;
|
_connectedClientsCount--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace ix
|
|||||||
int ret = select(maxfd + 1, &readfds, &writefds, &errorfds,
|
int ret = select(maxfd + 1, &readfds, &writefds, &errorfds,
|
||||||
timeout != -1 ? &tv : NULL);
|
timeout != -1 ? &tv : NULL);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace ix
|
|||||||
// which crash in FD_SET as they are larger than FD_SETSIZE.
|
// which crash in FD_SET as they are larger than FD_SETSIZE.
|
||||||
// Switching to ::poll does fix that.
|
// Switching to ::poll does fix that.
|
||||||
//
|
//
|
||||||
// However poll isn't as portable as select and has bugs on Windows, so we should write a
|
// However poll isn't as portable as select and has bugs on Windows, so we should write a
|
||||||
// shim to fallback to select on those platforms.
|
// shim to fallback to select on those platforms.
|
||||||
// See https://github.com/mpv-player/mpv/pull/5203/files for such a select wrapper.
|
// See https://github.com/mpv-player/mpv/pull/5203/files for such a select wrapper.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -164,26 +164,23 @@ namespace ix
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate status
|
// Validate status
|
||||||
auto statusLine = Http::parseStatusLine(line);
|
int status;
|
||||||
std::string httpVersion = statusLine.first;
|
|
||||||
int status = statusLine.second;
|
|
||||||
|
|
||||||
// HTTP/1.0 is too old.
|
// HTTP/1.0 is too old.
|
||||||
if (httpVersion != "HTTP/1.1")
|
if (sscanf(line.c_str(), "HTTP/1.0 %d", &status) == 1)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Expecting HTTP/1.1, got " << httpVersion << ". "
|
ss << "Server version is HTTP/1.0. Rejecting connection to " << host
|
||||||
<< "Rejecting connection to " << host << ":" << port
|
|
||||||
<< ", status: " << status
|
<< ", status: " << status
|
||||||
<< ", HTTP Status line: " << line;
|
<< ", HTTP Status line: " << line;
|
||||||
return WebSocketInitResult(false, status, ss.str());
|
return WebSocketInitResult(false, status, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want an 101 HTTP status
|
// We want an 101 HTTP status
|
||||||
if (status != 101)
|
if (sscanf(line.c_str(), "HTTP/1.1 %d", &status) != 1 || status != 101)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Got bad status connecting to " << host << ":" << port
|
ss << "Got bad status connecting to " << host
|
||||||
<< ", status: " << status
|
<< ", status: " << status
|
||||||
<< ", HTTP Status line: " << line;
|
<< ", HTTP Status line: " << line;
|
||||||
return WebSocketInitResult(false, status, ss.str());
|
return WebSocketInitResult(false, status, ss.str());
|
||||||
@@ -298,15 +295,9 @@ namespace ix
|
|||||||
return sendErrorResponse(400, "Missing Sec-WebSocket-Key value");
|
return sendErrorResponse(400, "Missing Sec-WebSocket-Key value");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headers.find("upgrade") == headers.end())
|
|
||||||
{
|
|
||||||
return sendErrorResponse(400, "Missing Upgrade header");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!insensitiveStringCompare(headers["upgrade"], "WebSocket"))
|
if (!insensitiveStringCompare(headers["upgrade"], "WebSocket"))
|
||||||
{
|
{
|
||||||
return sendErrorResponse(400, "Invalid Upgrade header, "
|
return sendErrorResponse(400, "Invalid or missing Upgrade header");
|
||||||
"need WebSocket, got " + headers["upgrade"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headers.find("sec-websocket-version") == headers.end())
|
if (headers.find("sec-websocket-version") == headers.end())
|
||||||
@@ -323,7 +314,7 @@ namespace ix
|
|||||||
if (version != 13)
|
if (version != 13)
|
||||||
{
|
{
|
||||||
return sendErrorResponse(400, "Invalid Sec-WebSocket-Version, "
|
return sendErrorResponse(400, "Invalid Sec-WebSocket-Version, "
|
||||||
"need 13, got " + ss.str());
|
"need 13, got" + ss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace ix
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "WebSocketServer::handleConnection() HTTP status: "
|
ss << "WebSocketServer::handleConnection() error: "
|
||||||
<< status.http_status
|
<< status.http_status
|
||||||
<< " error: "
|
<< " error: "
|
||||||
<< status.errorStr;
|
<< status.errorStr;
|
||||||
@@ -111,8 +111,6 @@ namespace ix
|
|||||||
|
|
||||||
logInfo("WebSocketServer::handleConnection() done");
|
logInfo("WebSocketServer::handleConnection() done");
|
||||||
connectionState->setTerminated();
|
connectionState->setTerminated();
|
||||||
|
|
||||||
Socket::closeSocket(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::shared_ptr<WebSocket>> WebSocketServer::getClients()
|
std::set<std::shared_ptr<WebSocket>> WebSocketServer::getClients()
|
||||||
|
|||||||
@@ -681,12 +681,8 @@ namespace ix
|
|||||||
reason = WebSocketCloseConstants::kInvalidFramePayloadDataMessage;
|
reason = WebSocketCloseConstants::kInvalidFramePayloadDataMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Validate close codes. Autobahn 7.9.*
|
// Validate close codes. Autobahn 7.9.*
|
||||||
// 1014, 1015 are debattable. The firefox MSDN has a description for them.
|
// 1014, 1015 are debattable. The firefox MSDN has a description for them
|
||||||
// Full list of status code and status range is defined in the dedicated
|
|
||||||
// RFC section at https://tools.ietf.org/html/rfc6455#page-45
|
|
||||||
//
|
|
||||||
if (code < 1000 || code == 1004 || code == 1006 ||
|
if (code < 1000 || code == 1004 || code == 1006 ||
|
||||||
(code > 1013 && code < 3000))
|
(code > 1013 && code < 3000))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "6.2.1"
|
#define IX_WEBSOCKET_VERSION "6.1.0"
|
||||||
|
|||||||
9
makefile
9
makefile
@@ -9,7 +9,7 @@ install: brew
|
|||||||
# 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
|
||||||
brew:
|
brew:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j install)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j install)
|
||||||
|
|
||||||
ws:
|
ws:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j)
|
||||||
@@ -47,9 +47,9 @@ trail:
|
|||||||
sh third_party/remote_trailing_whitespaces.sh
|
sh third_party/remote_trailing_whitespaces.sh
|
||||||
|
|
||||||
format:
|
format:
|
||||||
clang-format -i `find test ixwebsocket ws -name '*.cpp' -o -name '*.h'`
|
find test ixwebsocket ws -name '*.cpp' -o -name '*.h' -exec clang-format -i {} \;
|
||||||
|
|
||||||
# That target is used to start a node server, but isn't required as we have
|
# That target is used to start a node server, but isn't required as we have
|
||||||
# a builtin C++ server started in the unittest now
|
# a builtin C++ server started in the unittest now
|
||||||
test_server:
|
test_server:
|
||||||
(cd test && npm i ws && node broadcast-server.js)
|
(cd test && npm i ws && node broadcast-server.js)
|
||||||
@@ -58,8 +58,7 @@ test_server:
|
|||||||
# env TEST=Websocket_chat make test
|
# env TEST=Websocket_chat make test
|
||||||
# env TEST=heartbeat make test
|
# env TEST=heartbeat make test
|
||||||
test:
|
test:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j)
|
python2.7 test/run.py
|
||||||
(cd test ; python2.7 run.py -r)
|
|
||||||
|
|
||||||
ws_test: ws
|
ws_test: ws
|
||||||
(cd ws ; env DEBUG=1 PATH=../ws/build:$$PATH bash test_ws.sh)
|
(cd ws ; env DEBUG=1 PATH=../ws/build:$$PATH bash test_ws.sh)
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ if (MAC)
|
|||||||
option(USE_TLS "Add TLS support" ON)
|
option(USE_TLS "Add TLS support" ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(${PROJECT_SOURCE_DIR}/.. ixwebsocket)
|
||||||
|
|
||||||
set (WS ../ws)
|
set (WS ../ws)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
@@ -27,13 +29,24 @@ include_directories(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Shared sources
|
# Shared sources
|
||||||
set (SOURCES
|
set (SOURCES
|
||||||
test_runner.cpp
|
test_runner.cpp
|
||||||
IXTest.cpp
|
IXTest.cpp
|
||||||
IXGetFreePort.cpp
|
IXGetFreePort.cpp
|
||||||
../third_party/msgpack11/msgpack11.cpp
|
../third_party/msgpack11/msgpack11.cpp
|
||||||
../third_party/jsoncpp/jsoncpp.cpp
|
../third_party/jsoncpp/jsoncpp.cpp
|
||||||
|
|
||||||
|
${WS}/ixcore/utils/IXCoreLogger.cpp
|
||||||
|
|
||||||
|
${WS}/ixcrypto/IXBase64.cpp
|
||||||
|
${WS}/ixcrypto/IXHash.cpp
|
||||||
|
${WS}/ixcrypto/IXUuid.cpp
|
||||||
|
${WS}/ixcrypto/IXHMac.cpp
|
||||||
|
|
||||||
|
${WS}/ixcobra/IXCobraConnection.cpp
|
||||||
|
${WS}/ixcobra/IXCobraMetricsPublisher.cpp
|
||||||
|
${WS}/ixcobra/IXCobraMetricsThreadedPublisher.cpp
|
||||||
|
|
||||||
${WS}/snake/IXSnakeServer.cpp
|
${WS}/snake/IXSnakeServer.cpp
|
||||||
${WS}/snake/IXSnakeProtocol.cpp
|
${WS}/snake/IXSnakeProtocol.cpp
|
||||||
${WS}/snake/IXAppConfig.cpp
|
${WS}/snake/IXAppConfig.cpp
|
||||||
@@ -49,17 +62,16 @@ set (SOURCES
|
|||||||
IXHttpClientTest.cpp
|
IXHttpClientTest.cpp
|
||||||
IXHttpServerTest.cpp
|
IXHttpServerTest.cpp
|
||||||
IXUnityBuildsTest.cpp
|
IXUnityBuildsTest.cpp
|
||||||
IXHttpTest.cpp
|
IXCobraChatTest.cpp
|
||||||
|
IXCobraMetricsPublisherTest.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Some unittest don't work on windows yet
|
# Some unittest don't work on windows yet
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
list(APPEND SOURCES
|
list(APPEND SOURCES
|
||||||
IXDNSLookupTest.cpp
|
IXDNSLookupTest.cpp
|
||||||
IXWebSocketChatTest.cpp
|
cmd_websocket_chat.cpp
|
||||||
IXWebSocketCloseTest.cpp
|
IXWebSocketCloseTest.cpp
|
||||||
IXCobraChatTest.cpp
|
|
||||||
IXCobraMetricsPublisherTest.cpp
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -86,9 +98,5 @@ if (APPLE AND USE_TLS)
|
|||||||
target_link_libraries(ixwebsocket_unittest "-framework foundation" "-framework security")
|
target_link_libraries(ixwebsocket_unittest "-framework foundation" "-framework security")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(ixwebsocket_unittest ixcore)
|
|
||||||
target_link_libraries(ixwebsocket_unittest ixcrypto)
|
|
||||||
target_link_libraries(ixwebsocket_unittest ixcobra)
|
|
||||||
target_link_libraries(ixwebsocket_unittest ixwebsocket)
|
target_link_libraries(ixwebsocket_unittest ixwebsocket)
|
||||||
|
|
||||||
install(TARGETS ixwebsocket_unittest DESTINATION bin)
|
install(TARGETS ixwebsocket_unittest DESTINATION bin)
|
||||||
|
|||||||
@@ -135,12 +135,12 @@ namespace
|
|||||||
if (!msg.isMember("user")) return;
|
if (!msg.isMember("user")) return;
|
||||||
if (!msg.isMember("text")) return;
|
if (!msg.isMember("text")) return;
|
||||||
if (!msg.isMember("session")) return;
|
if (!msg.isMember("session")) return;
|
||||||
|
|
||||||
std::string msg_user = msg["user"].asString();
|
std::string msg_user = msg["user"].asString();
|
||||||
std::string msg_text = msg["text"].asString();
|
std::string msg_text = msg["text"].asString();
|
||||||
std::string msg_session = msg["session"].asString();
|
std::string msg_session = msg["session"].asString();
|
||||||
|
|
||||||
// We are not interested in messages
|
// We are not interested in messages
|
||||||
// from a different session.
|
// from a different session.
|
||||||
if (msg_session != _session) return;
|
if (msg_session != _session) return;
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ namespace
|
|||||||
_receivedQueue.push(msg);
|
_receivedQueue.push(msg);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::endl
|
ss << std::endl
|
||||||
<< msg_user << " > " << msg_text
|
<< msg_user << " > " << msg_text
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< _user << " > ";
|
<< _user << " > ";
|
||||||
@@ -246,7 +246,7 @@ namespace
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Sending msg [" << text << "]";
|
ss << "Sending msg [" << text << "]";
|
||||||
log(ss.str());
|
log(ss.str());
|
||||||
|
|
||||||
Json::Value channels;
|
Json::Value channels;
|
||||||
channels.append(channel);
|
channels.append(channel);
|
||||||
_conn.publish(channels, msg);
|
_conn.publish(channels, msg);
|
||||||
@@ -260,7 +260,7 @@ namespace
|
|||||||
|
|
||||||
ix::msleep(50);
|
ix::msleep(50);
|
||||||
_conn.disconnect();
|
_conn.disconnect();
|
||||||
|
|
||||||
_conn.setEventCallback([]
|
_conn.setEventCallback([]
|
||||||
(ix::CobraConnectionEventType eventType,
|
(ix::CobraConnectionEventType eventType,
|
||||||
const std::string& errMsg,
|
const std::string& errMsg,
|
||||||
@@ -305,11 +305,10 @@ TEST_CASE("Cobra_chat", "[cobra_chat]")
|
|||||||
{
|
{
|
||||||
if (chatA.isReady() && chatB.isReady()) break;
|
if (chatA.isReady() && chatB.isReady()) break;
|
||||||
ix::msleep(10);
|
ix::msleep(10);
|
||||||
|
|
||||||
timeout -= 10;
|
timeout -= 10;
|
||||||
if (timeout <= 0)
|
if (timeout <= 0)
|
||||||
{
|
{
|
||||||
snakeServer.stop();
|
|
||||||
REQUIRE(false); // timeout
|
REQUIRE(false); // timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,11 +328,10 @@ TEST_CASE("Cobra_chat", "[cobra_chat]")
|
|||||||
while (chatA.hasPendingMessages() || chatB.hasPendingMessages())
|
while (chatA.hasPendingMessages() || chatB.hasPendingMessages())
|
||||||
{
|
{
|
||||||
ix::msleep(10);
|
ix::msleep(10);
|
||||||
|
|
||||||
timeout -= 10;
|
timeout -= 10;
|
||||||
if (timeout <= 0)
|
if (timeout <= 0)
|
||||||
{
|
{
|
||||||
snakeServer.stop();
|
|
||||||
REQUIRE(false); // timeout
|
REQUIRE(false); // timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,13 +137,13 @@ TEST_CASE("Cobra_Metrics_Publisher", "[cobra]")
|
|||||||
std::thread bgThread(&startSubscriber, endpoint);
|
std::thread bgThread(&startSubscriber, endpoint);
|
||||||
|
|
||||||
int timeout = 10 * 1000; // 10s
|
int timeout = 10 * 1000; // 10s
|
||||||
|
|
||||||
// Wait until the subscriber is ready (authenticated + subscription successful)
|
// Wait until the subscriber is ready (authenticated + subscription successful)
|
||||||
while (!gSubscriberConnectedAndSubscribed)
|
while (!gSubscriberConnectedAndSubscribed)
|
||||||
{
|
{
|
||||||
std::chrono::duration<double, std::milli> duration(10);
|
std::chrono::duration<double, std::milli> duration(10);
|
||||||
std::this_thread::sleep_for(duration);
|
std::this_thread::sleep_for(duration);
|
||||||
|
|
||||||
timeout -= 10;
|
timeout -= 10;
|
||||||
if (timeout <= 0)
|
if (timeout <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace ix
|
|||||||
|
|
||||||
int getAnyFreePort()
|
int getAnyFreePort()
|
||||||
{
|
{
|
||||||
|
int defaultPort = 8090;
|
||||||
int sockfd;
|
int sockfd;
|
||||||
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
{
|
{
|
||||||
@@ -88,3 +89,5 @@ namespace ix
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* IXHttpTest.cpp
|
|
||||||
* Author: Benjamin Sergeant
|
|
||||||
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <ixwebsocket/IXHttp.h>
|
|
||||||
|
|
||||||
#include "catch.hpp"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
namespace ix
|
|
||||||
{
|
|
||||||
|
|
||||||
TEST_CASE("http", "[http]")
|
|
||||||
{
|
|
||||||
SECTION("Normal case")
|
|
||||||
{
|
|
||||||
std::string line = "HTTP/1.1 200";
|
|
||||||
auto result = Http::parseStatusLine(line);
|
|
||||||
|
|
||||||
REQUIRE(result.first == "HTTP/1.1");
|
|
||||||
REQUIRE(result.second == 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("http/1.0 case")
|
|
||||||
{
|
|
||||||
std::string line = "HTTP/1.0 200";
|
|
||||||
auto result = Http::parseStatusLine(line);
|
|
||||||
|
|
||||||
REQUIRE(result.first == "HTTP/1.0");
|
|
||||||
REQUIRE(result.second == 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("empty case")
|
|
||||||
{
|
|
||||||
std::string line = "";
|
|
||||||
auto result = Http::parseStatusLine(line);
|
|
||||||
|
|
||||||
REQUIRE(result.first == "");
|
|
||||||
REQUIRE(result.second == -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("empty case")
|
|
||||||
{
|
|
||||||
std::string line = "HTTP/1.1";
|
|
||||||
auto result = Http::parseStatusLine(line);
|
|
||||||
|
|
||||||
REQUIRE(result.first == "HTTP/1.1");
|
|
||||||
REQUIRE(result.second == -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,7 @@ namespace
|
|||||||
void stop();
|
void stop();
|
||||||
void stop(uint16_t code, const std::string& reason);
|
void stop(uint16_t code, const std::string& reason);
|
||||||
bool isReady() const;
|
bool isReady() const;
|
||||||
|
void sendMessage(const std::string& text);
|
||||||
|
|
||||||
uint16_t getCloseCode();
|
uint16_t getCloseCode();
|
||||||
const std::string& getCloseReason();
|
const std::string& getCloseReason();
|
||||||
@@ -170,6 +171,11 @@ namespace
|
|||||||
_webSocket.start();
|
_webSocket.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebSocketClient::sendMessage(const std::string& text)
|
||||||
|
{
|
||||||
|
_webSocket.send(text);
|
||||||
|
}
|
||||||
|
|
||||||
bool startServer(ix::WebSocketServer& server,
|
bool startServer(ix::WebSocketServer& server,
|
||||||
uint16_t& receivedCloseCode,
|
uint16_t& receivedCloseCode,
|
||||||
std::string& receivedCloseReason,
|
std::string& receivedCloseReason,
|
||||||
|
|||||||
@@ -112,8 +112,6 @@ TEST_CASE("Websocket_server", "[websocket_server]")
|
|||||||
|
|
||||||
auto lineResult = socket->readLine(isCancellationRequested);
|
auto lineResult = socket->readLine(isCancellationRequested);
|
||||||
auto lineValid = lineResult.first;
|
auto lineValid = lineResult.first;
|
||||||
REQUIRE(lineValid);
|
|
||||||
|
|
||||||
auto line = lineResult.second;
|
auto line = lineResult.second;
|
||||||
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
@@ -151,8 +149,6 @@ TEST_CASE("Websocket_server", "[websocket_server]")
|
|||||||
|
|
||||||
auto lineResult = socket->readLine(isCancellationRequested);
|
auto lineResult = socket->readLine(isCancellationRequested);
|
||||||
auto lineValid = lineResult.first;
|
auto lineValid = lineResult.first;
|
||||||
REQUIRE(lineValid);
|
|
||||||
|
|
||||||
auto line = lineResult.second;
|
auto line = lineResult.second;
|
||||||
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
@@ -194,8 +190,6 @@ TEST_CASE("Websocket_server", "[websocket_server]")
|
|||||||
|
|
||||||
auto lineResult = socket->readLine(isCancellationRequested);
|
auto lineResult = socket->readLine(isCancellationRequested);
|
||||||
auto lineValid = lineResult.first;
|
auto lineValid = lineResult.first;
|
||||||
REQUIRE(lineValid);
|
|
||||||
|
|
||||||
auto line = lineResult.second;
|
auto line = lineResult.second;
|
||||||
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|||||||
29
test/run.py
29
test/run.py
@@ -350,22 +350,21 @@ def generateXmlOutput(results, xmlOutput, testRunName, runTime):
|
|||||||
|
|
||||||
|
|
||||||
def run(testName, buildDir, sanitizer, xmlOutput,
|
def run(testName, buildDir, sanitizer, xmlOutput,
|
||||||
testRunName, buildOnly, useLLDB, cpuCount, runOnly):
|
testRunName, buildOnly, useLLDB, cpuCount):
|
||||||
'''Main driver. Run cmake, compiles, execute and validate the testsuite.'''
|
'''Main driver. Run cmake, compiles, execute and validate the testsuite.'''
|
||||||
|
|
||||||
# gen build files with CMake
|
# gen build files with CMake
|
||||||
if not runOnly:
|
runCMake(sanitizer, buildDir)
|
||||||
runCMake(sanitizer, buildDir)
|
|
||||||
|
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
# build with make -j
|
# build with make -j
|
||||||
runCommand('make -C {} -j 2'.format(buildDir))
|
runCommand('make -C {} -j 2'.format(buildDir))
|
||||||
elif platform.system() == 'Darwin':
|
elif platform.system() == 'Darwin':
|
||||||
# build with make
|
# build with make
|
||||||
runCommand('make -C {} -j 8'.format(buildDir))
|
runCommand('make -C {} -j 8'.format(buildDir))
|
||||||
else:
|
else:
|
||||||
# build with cmake on recent
|
# build with cmake on recent
|
||||||
runCommand('cmake --build --parallel {}'.format(buildDir))
|
runCommand('cmake --build --parallel {}'.format(buildDir))
|
||||||
|
|
||||||
if buildOnly:
|
if buildOnly:
|
||||||
return
|
return
|
||||||
@@ -455,8 +454,6 @@ def main():
|
|||||||
help='Validate XML output.')
|
help='Validate XML output.')
|
||||||
parser.add_argument('--build_only', '-b', action='store_true',
|
parser.add_argument('--build_only', '-b', action='store_true',
|
||||||
help='Stop after building. Do not run the unittest.')
|
help='Stop after building. Do not run the unittest.')
|
||||||
parser.add_argument('--run_only', '-r', action='store_true',
|
|
||||||
help='Only run the test, do not build anything.')
|
|
||||||
parser.add_argument('--output', '-o', help='Output XML file.')
|
parser.add_argument('--output', '-o', help='Output XML file.')
|
||||||
parser.add_argument('--lldb', action='store_true',
|
parser.add_argument('--lldb', action='store_true',
|
||||||
help='Run the test through lldb.')
|
help='Run the test through lldb.')
|
||||||
@@ -495,7 +492,7 @@ def main():
|
|||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
TEST_EXE_PATH = os.path.join(buildDir, BUILD_TYPE, 'ixwebsocket_unittest.exe')
|
TEST_EXE_PATH = os.path.join(buildDir, BUILD_TYPE, 'ixwebsocket_unittest.exe')
|
||||||
else:
|
else:
|
||||||
TEST_EXE_PATH = '../build/test/ixwebsocket_unittest'
|
TEST_EXE_PATH = os.path.join(buildDir, 'ixwebsocket_unittest')
|
||||||
|
|
||||||
if args.list:
|
if args.list:
|
||||||
# catch2 exit with a different error code when requesting the list of files
|
# catch2 exit with a different error code when requesting the list of files
|
||||||
@@ -514,7 +511,7 @@ def main():
|
|||||||
args.lldb = False
|
args.lldb = False
|
||||||
|
|
||||||
return run(args.test, buildDir, sanitizer, xmlOutput,
|
return run(args.test, buildDir, sanitizer, xmlOutput,
|
||||||
testRunName, args.build_only, args.lldb, args.cpu_count, args.run_only)
|
testRunName, args.build_only, args.lldb, args.cpu_count)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
3779
third_party/cli11/CLI11.hpp
vendored
3779
third_party/cli11/CLI11.hpp
vendored
File diff suppressed because it is too large
Load Diff
14
third_party/jsoncpp/json/json-forwards.h
vendored
14
third_party/jsoncpp/json/json-forwards.h
vendored
@@ -7,28 +7,28 @@
|
|||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The JsonCpp library's source code, including accompanying documentation,
|
The JsonCpp library's source code, including accompanying documentation,
|
||||||
tests and demonstration applications, are licensed under the following
|
tests and demonstration applications, are licensed under the following
|
||||||
conditions...
|
conditions...
|
||||||
|
|
||||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||||
this software is released into the Public Domain.
|
this software is released into the Public Domain.
|
||||||
|
|
||||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
||||||
released under the terms of the MIT License (see below).
|
released under the terms of the MIT License (see below).
|
||||||
|
|
||||||
In jurisdictions which recognize Public Domain property, the user of this
|
In jurisdictions which recognize Public Domain property, the user of this
|
||||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||||
Public Domain/MIT License conditions described here, as they choose.
|
Public Domain/MIT License conditions described here, as they choose.
|
||||||
|
|
||||||
The MIT License is about as close to Public Domain as a license can get, and is
|
The MIT License is about as close to Public Domain as a license can get, and is
|
||||||
described in clear, concise terms at:
|
described in clear, concise terms at:
|
||||||
|
|
||||||
http://en.wikipedia.org/wiki/MIT_License
|
http://en.wikipedia.org/wiki/MIT_License
|
||||||
|
|
||||||
The full text of the MIT License follows:
|
The full text of the MIT License follows:
|
||||||
|
|
||||||
========================================================================
|
========================================================================
|
||||||
|
|||||||
22
third_party/jsoncpp/json/json.h
vendored
22
third_party/jsoncpp/json/json.h
vendored
@@ -6,28 +6,28 @@
|
|||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The JsonCpp library's source code, including accompanying documentation,
|
The JsonCpp library's source code, including accompanying documentation,
|
||||||
tests and demonstration applications, are licensed under the following
|
tests and demonstration applications, are licensed under the following
|
||||||
conditions...
|
conditions...
|
||||||
|
|
||||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||||
this software is released into the Public Domain.
|
this software is released into the Public Domain.
|
||||||
|
|
||||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
||||||
released under the terms of the MIT License (see below).
|
released under the terms of the MIT License (see below).
|
||||||
|
|
||||||
In jurisdictions which recognize Public Domain property, the user of this
|
In jurisdictions which recognize Public Domain property, the user of this
|
||||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||||
Public Domain/MIT License conditions described here, as they choose.
|
Public Domain/MIT License conditions described here, as they choose.
|
||||||
|
|
||||||
The MIT License is about as close to Public Domain as a license can get, and is
|
The MIT License is about as close to Public Domain as a license can get, and is
|
||||||
described in clear, concise terms at:
|
described in clear, concise terms at:
|
||||||
|
|
||||||
http://en.wikipedia.org/wiki/MIT_License
|
http://en.wikipedia.org/wiki/MIT_License
|
||||||
|
|
||||||
The full text of the MIT License follows:
|
The full text of the MIT License follows:
|
||||||
|
|
||||||
========================================================================
|
========================================================================
|
||||||
@@ -390,7 +390,7 @@ public:
|
|||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
//Conditional NORETURN attribute on the throw functions would:
|
//Conditional NORETURN attribute on the throw functions would:
|
||||||
// a) suppress false positives from static code analysis
|
// a) suppress false positives from static code analysis
|
||||||
// b) possibly improve optimization opportunities.
|
// b) possibly improve optimization opportunities.
|
||||||
#if !defined(JSONCPP_NORETURN)
|
#if !defined(JSONCPP_NORETURN)
|
||||||
# if defined(_MSC_VER)
|
# if defined(_MSC_VER)
|
||||||
@@ -422,7 +422,7 @@ protected:
|
|||||||
/** Exceptions which the user cannot easily avoid.
|
/** Exceptions which the user cannot easily avoid.
|
||||||
*
|
*
|
||||||
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
||||||
*
|
*
|
||||||
* \remark derived from Json::Exception
|
* \remark derived from Json::Exception
|
||||||
*/
|
*/
|
||||||
class JSON_API RuntimeError : public Exception {
|
class JSON_API RuntimeError : public Exception {
|
||||||
@@ -433,7 +433,7 @@ public:
|
|||||||
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
||||||
*
|
*
|
||||||
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
||||||
*
|
*
|
||||||
* \remark derived from Json::Exception
|
* \remark derived from Json::Exception
|
||||||
*/
|
*/
|
||||||
class JSON_API LogicError : public Exception {
|
class JSON_API LogicError : public Exception {
|
||||||
@@ -1502,7 +1502,7 @@ public:
|
|||||||
- `"rejectDupKeys": false or true`
|
- `"rejectDupKeys": false or true`
|
||||||
- If true, `parse()` returns false when a key is duplicated within an object.
|
- If true, `parse()` returns false when a key is duplicated within an object.
|
||||||
- `"allowSpecialFloats": false or true`
|
- `"allowSpecialFloats": false or true`
|
||||||
- If true, special float values (NaNs and infinities) are allowed
|
- If true, special float values (NaNs and infinities) are allowed
|
||||||
and their values are lossfree restorable.
|
and their values are lossfree restorable.
|
||||||
|
|
||||||
You can examine 'settings_` yourself
|
You can examine 'settings_` yourself
|
||||||
|
|||||||
27
third_party/jsoncpp/jsoncpp.cpp
vendored
27
third_party/jsoncpp/jsoncpp.cpp
vendored
@@ -6,28 +6,28 @@
|
|||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The JsonCpp library's source code, including accompanying documentation,
|
The JsonCpp library's source code, including accompanying documentation,
|
||||||
tests and demonstration applications, are licensed under the following
|
tests and demonstration applications, are licensed under the following
|
||||||
conditions...
|
conditions...
|
||||||
|
|
||||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||||
this software is released into the Public Domain.
|
this software is released into the Public Domain.
|
||||||
|
|
||||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
||||||
released under the terms of the MIT License (see below).
|
released under the terms of the MIT License (see below).
|
||||||
|
|
||||||
In jurisdictions which recognize Public Domain property, the user of this
|
In jurisdictions which recognize Public Domain property, the user of this
|
||||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||||
Public Domain/MIT License conditions described here, as they choose.
|
Public Domain/MIT License conditions described here, as they choose.
|
||||||
|
|
||||||
The MIT License is about as close to Public Domain as a license can get, and is
|
The MIT License is about as close to Public Domain as a license can get, and is
|
||||||
described in clear, concise terms at:
|
described in clear, concise terms at:
|
||||||
|
|
||||||
http://en.wikipedia.org/wiki/MIT_License
|
http://en.wikipedia.org/wiki/MIT_License
|
||||||
|
|
||||||
The full text of the MIT License follows:
|
The full text of the MIT License follows:
|
||||||
|
|
||||||
========================================================================
|
========================================================================
|
||||||
@@ -209,7 +209,7 @@ static inline void fixNumericLocale(char* begin, char* end) {
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
||||||
#define snprintf sprintf_s
|
#define snprintf sprintf_s
|
||||||
#elif _MSC_VER >= 1900 // VC++ 14.0 and above
|
#elif _MSC_VER >= 1900 // VC++ 14.0 and above
|
||||||
#define snprintf std::snprintf
|
#define snprintf std::snprintf
|
||||||
@@ -3780,7 +3780,7 @@ Value& Path::make(Value& root) const {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
||||||
#define snprintf sprintf_s
|
#define snprintf sprintf_s
|
||||||
#elif _MSC_VER >= 1900 // VC++ 14.0 and above
|
#elif _MSC_VER >= 1900 // VC++ 14.0 and above
|
||||||
#define snprintf std::snprintf
|
#define snprintf std::snprintf
|
||||||
@@ -3793,7 +3793,7 @@ Value& Path::make(Value& root) const {
|
|||||||
#define snprintf std::snprintf
|
#define snprintf std::snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#define isfinite _finite
|
#define isfinite _finite
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
@@ -4856,7 +4856,7 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
|||||||
std::string cs_str = settings_["commentStyle"].asString();
|
std::string cs_str = settings_["commentStyle"].asString();
|
||||||
bool eyc = settings_["enableYAMLCompatibility"].asBool();
|
bool eyc = settings_["enableYAMLCompatibility"].asBool();
|
||||||
bool dnp = settings_["dropNullPlaceholders"].asBool();
|
bool dnp = settings_["dropNullPlaceholders"].asBool();
|
||||||
bool usf = settings_["useSpecialFloats"].asBool();
|
bool usf = settings_["useSpecialFloats"].asBool();
|
||||||
unsigned int pre = settings_["precision"].asUInt();
|
unsigned int pre = settings_["precision"].asUInt();
|
||||||
CommentStyle::Enum cs = CommentStyle::All;
|
CommentStyle::Enum cs = CommentStyle::All;
|
||||||
if (cs_str == "All") {
|
if (cs_str == "All") {
|
||||||
@@ -4945,3 +4945,8 @@ std::ostream& operator<<(std::ostream& sout, Value const& root) {
|
|||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
// End of content of file: src/lib_json/json_writer.cpp
|
// End of content of file: src/lib_json/json_writer.cpp
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
third_party/mbedtls/.github/issue_template.md
vendored
32
third_party/mbedtls/.github/issue_template.md
vendored
@@ -7,35 +7,35 @@ Note: This is just a template, so feel free to use/remove the unnecessary things
|
|||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
## Bug
|
## Bug
|
||||||
|
|
||||||
**OS**
|
**OS**
|
||||||
Mbed OS|linux|windows|
|
Mbed OS|linux|windows|
|
||||||
|
|
||||||
**mbed TLS build:**
|
**mbed TLS build:**
|
||||||
Version: x.x.x or git commit id
|
Version: x.x.x or git commit id
|
||||||
OS version: x.x.x
|
OS version: x.x.x
|
||||||
Configuration: please attach config.h file where possible
|
Configuration: please attach config.h file where possible
|
||||||
Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
|
Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
|
||||||
Additional environment information:
|
Additional environment information:
|
||||||
|
|
||||||
**Peer device TLS stack and version**
|
**Peer device TLS stack and version**
|
||||||
OpenSSL|GnuTls|Chrome|NSS(Firefox)|SecureChannel (IIS/Internet Explorer/Edge)|Other
|
OpenSSL|GnuTls|Chrome|NSS(Firefox)|SecureChannel (IIS/Internet Explorer/Edge)|Other
|
||||||
Version:
|
Version:
|
||||||
|
|
||||||
**Expected behavior**
|
**Expected behavior**
|
||||||
|
|
||||||
**Actual behavior**
|
**Actual behavior**
|
||||||
|
|
||||||
**Steps to reproduce**
|
**Steps to reproduce**
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
## Enhancement\Feature Request
|
## Enhancement\Feature Request
|
||||||
|
|
||||||
**Justification - why does the library need this feature?**
|
**Justification - why does the library need this feature?**
|
||||||
|
|
||||||
**Suggested enhancement**
|
**Suggested enhancement**
|
||||||
|
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
## Question
|
## Question
|
||||||
|
|
||||||
**Please first check for answers in the [Mbed TLS knowledge Base](https://tls.mbed.org/kb), and preferably file an issue in the [Mbed TLS support forum](https://forums.mbed.com/c/mbed-tls)**
|
**Please first check for answers in the [Mbed TLS knowledge Base](https://tls.mbed.org/kb), and preferably file an issue in the [Mbed TLS support forum](https://forums.mbed.com/c/mbed-tls)**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Notes:
|
Notes:
|
||||||
* Pull requests cannot be accepted until:
|
* Pull requests cannot be accepted until:
|
||||||
- The submitter has [accepted the online agreement here with a click through](https://developer.mbed.org/contributor_agreement/)
|
- The submitter has [accepted the online agreement here with a click through](https://developer.mbed.org/contributor_agreement/)
|
||||||
or for companies or those that do not wish to create an mbed account, a slightly different agreement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/)
|
or for companies or those that do not wish to create an mbed account, a slightly different agreement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/)
|
||||||
- The PR follows the [mbed TLS coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards)
|
- The PR follows the [mbed TLS coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards)
|
||||||
* This is just a template, so feel free to use/remove the unnecessary things
|
* This is just a template, so feel free to use/remove the unnecessary things
|
||||||
@@ -17,7 +17,7 @@ Changes do not have to be backported if:
|
|||||||
- This PR is a new feature\enhancement
|
- This PR is a new feature\enhancement
|
||||||
- This PR contains changes in the API. If this is true, and there is a need for the fix to be backported, the fix should be handled differently in the legacy branch
|
- This PR contains changes in the API. If this is true, and there is a need for the fix to be backported, the fix should be handled differently in the legacy branch
|
||||||
|
|
||||||
Yes | NO
|
Yes | NO
|
||||||
Which branch?
|
Which branch?
|
||||||
|
|
||||||
## Migrations
|
## Migrations
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
************************************** WARNING **************************************
|
************************************** WARNING **************************************
|
||||||
|
|
||||||
The ciarcom bot parses this header automatically. Any deviation from the
|
The ciarcom bot parses this header automatically. Any deviation from the
|
||||||
template may cause the bot to automatically correct this header or may result in a
|
template may cause the bot to automatically correct this header or may result in a
|
||||||
warning message, requesting updates.
|
warning message, requesting updates.
|
||||||
|
|
||||||
Please ensure that nothing follows the Issue request type section, all
|
Please ensure that nothing follows the Issue request type section, all
|
||||||
issue details are within the Description section and no changes are made to the
|
issue details are within the Description section and no changes are made to the
|
||||||
template format (as detailed below).
|
template format (as detailed below).
|
||||||
|
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
@@ -41,3 +41,4 @@
|
|||||||
[ ] Question
|
[ ] Question
|
||||||
[ ] Enhancement
|
[ ] Enhancement
|
||||||
[ ] Bug
|
[ ] Bug
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ This subdirectory mostly contains sample programs that illustrate specific featu
|
|||||||
|
|
||||||
## Symmetric cryptography (AES) examples
|
## Symmetric cryptography (AES) examples
|
||||||
|
|
||||||
* [`aes/aescrypt2.c`](aes/aescrypt2.c): file encryption and authentication with a key derived from a low-entropy secret, demonstrating the low-level AES interface, the digest interface and HMAC.
|
* [`aes/aescrypt2.c`](aes/aescrypt2.c): file encryption and authentication with a key derived from a low-entropy secret, demonstrating the low-level AES interface, the digest interface and HMAC.
|
||||||
Warning: this program illustrates how to use low-level functions in the library. It should not be taken as an example of how to build a secure encryption mechanism. To derive a key from a low-entropy secret such as a password, use a standard key stretching mechanism such as PBKDF2 (provided by the `pkcs5` module). To encrypt and authenticate data, use a standard mode such as GCM or CCM (both available as library module).
|
Warning: this program illustrates how to use low-level functions in the library. It should not be taken as an example of how to build a secure encryption mechanism. To derive a key from a low-entropy secret such as a password, use a standard key stretching mechanism such as PBKDF2 (provided by the `pkcs5` module). To encrypt and authenticate data, use a standard mode such as GCM or CCM (both available as library module).
|
||||||
|
|
||||||
* [`aes/crypt_and_hash.c`](aes/crypt_and_hash.c): file encryption and authentication, demonstrating the generic cipher interface and the generic hash interface.
|
* [`aes/crypt_and_hash.c`](aes/crypt_and_hash.c): file encryption and authentication, demonstrating the generic cipher interface and the generic hash interface.
|
||||||
@@ -54,7 +54,7 @@ This subdirectory mostly contains sample programs that illustrate specific featu
|
|||||||
|
|
||||||
## Random number generator (RNG) examples
|
## Random number generator (RNG) examples
|
||||||
|
|
||||||
* [`random/gen_entropy.c`](random/gen_entropy.c): shows how to use the default entropy sources to generate random data.
|
* [`random/gen_entropy.c`](random/gen_entropy.c): shows how to use the default entropy sources to generate random data.
|
||||||
Note: most applications should only use the entropy generator to seed a cryptographic pseudorandom generator, as illustrated by `random/gen_random_ctr_drbg.c`.
|
Note: most applications should only use the entropy generator to seed a cryptographic pseudorandom generator, as illustrated by `random/gen_random_ctr_drbg.c`.
|
||||||
|
|
||||||
* [`random/gen_random_ctr_drbg.c`](random/gen_random_ctr_drbg.c): shows how to use the default entropy sources to seed a pseudorandom generator, and how to use the resulting random generator to generate random data.
|
* [`random/gen_random_ctr_drbg.c`](random/gen_random_ctr_drbg.c): shows how to use the default entropy sources to seed a pseudorandom generator, and how to use the resulting random generator to generate random data.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ The mbed TLS git hooks are located in `<mbed TLS root>/tests/git-scripts` direct
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
Execute the following command to create a link on linux from the mbed TLS `.git/hooks` directory:
|
Execute the following command to create a link on linux from the mbed TLS `.git/hooks` directory:
|
||||||
`ln -s ../../tests/git-scripts/pre-push.sh pre-push`
|
`ln -s ../../tests/git-scripts/pre-push.sh pre-push`
|
||||||
|
|
||||||
**Note: Currently the mbed TLS git hooks work only on a GNU platform. If using a non-GNU platform, don't enable these hooks!**
|
**Note: Currently the mbed TLS git hooks work only on a GNU platform. If using a non-GNU platform, don't enable these hooks!**
|
||||||
|
|||||||
5
third_party/mbedtls/programs/README.md
vendored
5
third_party/mbedtls/programs/README.md
vendored
@@ -5,7 +5,7 @@ This subdirectory mostly contains sample programs that illustrate specific featu
|
|||||||
|
|
||||||
## Symmetric cryptography (AES) examples
|
## Symmetric cryptography (AES) examples
|
||||||
|
|
||||||
* [`aes/aescrypt2.c`](aes/aescrypt2.c): file encryption and authentication with a key derived from a low-entropy secret, demonstrating the low-level AES interface, the digest interface and HMAC.
|
* [`aes/aescrypt2.c`](aes/aescrypt2.c): file encryption and authentication with a key derived from a low-entropy secret, demonstrating the low-level AES interface, the digest interface and HMAC.
|
||||||
Warning: this program illustrates how to use low-level functions in the library. It should not be taken as an example of how to build a secure encryption mechanism. To derive a key from a low-entropy secret such as a password, use a standard key stretching mechanism such as PBKDF2 (provided by the `pkcs5` module). To encrypt and authenticate data, use a standard mode such as GCM or CCM (both available as library module).
|
Warning: this program illustrates how to use low-level functions in the library. It should not be taken as an example of how to build a secure encryption mechanism. To derive a key from a low-entropy secret such as a password, use a standard key stretching mechanism such as PBKDF2 (provided by the `pkcs5` module). To encrypt and authenticate data, use a standard mode such as GCM or CCM (both available as library module).
|
||||||
|
|
||||||
* [`aes/crypt_and_hash.c`](aes/crypt_and_hash.c): file encryption and authentication, demonstrating the generic cipher interface and the generic hash interface.
|
* [`aes/crypt_and_hash.c`](aes/crypt_and_hash.c): file encryption and authentication, demonstrating the generic cipher interface and the generic hash interface.
|
||||||
@@ -56,7 +56,7 @@ This subdirectory mostly contains sample programs that illustrate specific featu
|
|||||||
|
|
||||||
## Random number generator (RNG) examples
|
## Random number generator (RNG) examples
|
||||||
|
|
||||||
* [`random/gen_entropy.c`](random/gen_entropy.c): shows how to use the default entropy sources to generate random data.
|
* [`random/gen_entropy.c`](random/gen_entropy.c): shows how to use the default entropy sources to generate random data.
|
||||||
Note: most applications should only use the entropy generator to seed a cryptographic pseudorandom generator, as illustrated by `random/gen_random_ctr_drbg.c`.
|
Note: most applications should only use the entropy generator to seed a cryptographic pseudorandom generator, as illustrated by `random/gen_random_ctr_drbg.c`.
|
||||||
|
|
||||||
* [`random/gen_random_ctr_drbg.c`](random/gen_random_ctr_drbg.c): shows how to use the default entropy sources to seed a pseudorandom generator, and how to use the resulting random generator to generate random data.
|
* [`random/gen_random_ctr_drbg.c`](random/gen_random_ctr_drbg.c): shows how to use the default entropy sources to seed a pseudorandom generator, and how to use the resulting random generator to generate random data.
|
||||||
@@ -120,3 +120,4 @@ In addition to providing options for testing client-side features, the `ssl_clie
|
|||||||
* [`x509/crl_app.c`](x509/crl_app.c): loads and dumps a certificate revocation list (CRL).
|
* [`x509/crl_app.c`](x509/crl_app.c): loads and dumps a certificate revocation list (CRL).
|
||||||
|
|
||||||
* [`x509/req_app.c`](x509/req_app.c): loads and dumps a certificate signing request (CSR).
|
* [`x509/req_app.c`](x509/req_app.c): loads and dumps a certificate signing request (CSR).
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ The mbed TLS git hooks are located in `<mbed TLS root>/tests/git-scripts` direct
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
Execute the following command to create a link on linux from the mbed TLS `.git/hooks` directory:
|
Execute the following command to create a link on linux from the mbed TLS `.git/hooks` directory:
|
||||||
`ln -s ../../tests/git-scripts/pre-push.sh pre-push`
|
`ln -s ../../tests/git-scripts/pre-push.sh pre-push`
|
||||||
|
|
||||||
**Note: Currently the mbed TLS git hooks work only on a GNU platform. If using a non-GNU platform, don't enable these hooks!**
|
**Note: Currently the mbed TLS git hooks work only on a GNU platform. If using a non-GNU platform, don't enable these hooks!**
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ add_executable(ws
|
|||||||
../third_party/jsoncpp/jsoncpp.cpp
|
../third_party/jsoncpp/jsoncpp.cpp
|
||||||
${STATSD_CLIENT_SOURCES}
|
${STATSD_CLIENT_SOURCES}
|
||||||
|
|
||||||
|
ixcore/utils/IXCoreLogger.cpp
|
||||||
|
|
||||||
|
ixcrypto/IXBase64.cpp
|
||||||
|
ixcrypto/IXHash.cpp
|
||||||
|
ixcrypto/IXUuid.cpp
|
||||||
|
ixcrypto/IXHMac.cpp
|
||||||
|
|
||||||
|
ixcobra/IXCobraConnection.cpp
|
||||||
|
ixcobra/IXCobraMetricsPublisher.cpp
|
||||||
|
ixcobra/IXCobraMetricsThreadedPublisher.cpp
|
||||||
|
|
||||||
snake/IXSnakeServer.cpp
|
snake/IXSnakeServer.cpp
|
||||||
snake/IXSnakeProtocol.cpp
|
snake/IXSnakeProtocol.cpp
|
||||||
snake/IXAppConfig.cpp
|
snake/IXAppConfig.cpp
|
||||||
@@ -62,9 +73,6 @@ add_executable(ws
|
|||||||
ws_autobahn.cpp
|
ws_autobahn.cpp
|
||||||
ws.cpp)
|
ws.cpp)
|
||||||
|
|
||||||
target_link_libraries(ws ixcore)
|
|
||||||
target_link_libraries(ws ixcrypto)
|
|
||||||
target_link_libraries(ws ixcobra)
|
|
||||||
target_link_libraries(ws ixwebsocket)
|
target_link_libraries(ws ixwebsocket)
|
||||||
|
|
||||||
if(NOT APPLE AND NOT USE_MBED_TLS)
|
if(NOT APPLE AND NOT USE_MBED_TLS)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,14 +7,12 @@
|
|||||||
#include "IXHMac.h"
|
#include "IXHMac.h"
|
||||||
#include "IXBase64.h"
|
#include "IXBase64.h"
|
||||||
|
|
||||||
#if defined(IXCRYPTO_USE_MBED_TLS)
|
#if defined(IXWEBSOCKET_USE_MBED_TLS)
|
||||||
# include <mbedtls/md.h>
|
# include <mbedtls/md.h>
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
# include <CommonCrypto/CommonHMAC.h>
|
# include <CommonCrypto/CommonHMAC.h>
|
||||||
#elif defined(IXCRYPTO_USE_OPEN_SSL)
|
|
||||||
# include <openssl/hmac.h>
|
|
||||||
#else
|
#else
|
||||||
# error "Unsupported configuration"
|
# include <openssl/hmac.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
@@ -24,7 +22,7 @@ namespace ix
|
|||||||
constexpr size_t hashSize = 16;
|
constexpr size_t hashSize = 16;
|
||||||
unsigned char hash[hashSize];
|
unsigned char hash[hashSize];
|
||||||
|
|
||||||
#if defined(IXCRYPTO_USE_MBED_TLS)
|
#if defined(IXWEBSOCKET_USE_MBED_TLS)
|
||||||
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_MD5),
|
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_MD5),
|
||||||
(unsigned char *) key.c_str(), key.size(),
|
(unsigned char *) key.c_str(), key.size(),
|
||||||
(unsigned char *) data.c_str(), data.size(),
|
(unsigned char *) data.c_str(), data.size(),
|
||||||
@@ -34,13 +32,11 @@ namespace ix
|
|||||||
key.c_str(), key.size(),
|
key.c_str(), key.size(),
|
||||||
data.c_str(), data.size(),
|
data.c_str(), data.size(),
|
||||||
&hash);
|
&hash);
|
||||||
#elif defined(IXCRYPTO_USE_OPEN_SSL)
|
#else
|
||||||
HMAC(EVP_md5(),
|
HMAC(EVP_md5(),
|
||||||
key.c_str(), (int) key.size(),
|
key.c_str(), (int) key.size(),
|
||||||
(unsigned char *) data.c_str(), (int) data.size(),
|
(unsigned char *) data.c_str(), (int) data.size(),
|
||||||
(unsigned char *) hash, nullptr);
|
(unsigned char *) hash, nullptr);
|
||||||
#else
|
|
||||||
# error "Unsupported configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string hashString(reinterpret_cast<char*>(hash), hashSize);
|
std::string hashString(reinterpret_cast<char*>(hash), hashSize);
|
||||||
@@ -5,11 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// 1. First you need to generate a config file in a config folder,
|
// 1. First you need to generate a config file in a config folder,
|
||||||
// which can use a white list of test to execute (with globbing),
|
// which can use a white list of test to execute (with globbing),
|
||||||
// or a black list of tests to ignore
|
// or a black list of tests to ignore
|
||||||
//
|
//
|
||||||
// config/fuzzingserver.json
|
// config/fuzzingserver.json
|
||||||
// {
|
// {
|
||||||
// "url": "ws://127.0.0.1:9001",
|
// "url": "ws://127.0.0.1:9001",
|
||||||
// "outdir": "./reports/clients",
|
// "outdir": "./reports/clients",
|
||||||
@@ -18,10 +18,15 @@
|
|||||||
// ],
|
// ],
|
||||||
// "exclude-agent-cases": {}
|
// "exclude-agent-cases": {}
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// 2 Run the test server (using docker)
|
// 2 Run the test server (using docker)
|
||||||
// docker run -it --rm -v "${PWD}/config:/config" -v "${PWD}/reports:/reports" -p 9001:9001 --name fuzzingserver crossbario/autobahn-testsuite
|
// docker run -it --rm \
|
||||||
|
// -v "${PWD}/config:/config" \
|
||||||
|
// -v "${PWD}/reports:/reports" \
|
||||||
|
// -p 9001:9001 \
|
||||||
|
// --name fuzzingserver \
|
||||||
|
// crossbario/autobahn-testsuite
|
||||||
//
|
//
|
||||||
// 3. Run this command
|
// 3. Run this command
|
||||||
// ws autobahn -q --url ws://localhost:9001
|
// ws autobahn -q --url ws://localhost:9001
|
||||||
@@ -310,3 +315,4 @@ namespace ix
|
|||||||
return generateReport(url) ? 0 : 1;
|
return generateReport(url) ? 0 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace ix
|
|||||||
// Display incoming messages
|
// Display incoming messages
|
||||||
std::atomic<int> msgPerSeconds(0);
|
std::atomic<int> msgPerSeconds(0);
|
||||||
std::atomic<int> msgCount(0);
|
std::atomic<int> msgCount(0);
|
||||||
|
|
||||||
auto timer = [&msgPerSeconds, &msgCount]
|
auto timer = [&msgPerSeconds, &msgCount]
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
|||||||
Reference in New Issue
Block a user