Compare commits

...

17 Commits

Author SHA1 Message Date
bdee582203 add sentry native project 2020-03-06 11:53:36 -08:00
4ef04b8339 (websocket server) fix regression with disabling zlib extension on the server side. If a client does not support this extension the server will handle it fine. We still need to figure out how to disable the option. cc #160 2020-03-02 16:53:08 -08:00
e581f29b42 Move zlib include_directories before add_subdirectory (#159) 2020-02-28 09:30:37 -08:00
a42f115f79 compatibility: add node.js example server 2020-02-26 12:17:34 -08:00
5ce1a596cf add a python echo server that does not close the connection after each received messages 2020-02-26 12:11:31 -08:00
21db7b6c5b add a simple pytho echo client 2020-02-26 11:50:24 -08:00
e15a2900e7 (websocket) traffic tracker received bytes is message size while it should be wire size 2020-02-26 11:24:41 -08:00
140a21c8b3 (ws_connect) display sent/received bytes statistics on exit 2020-02-26 11:23:36 -08:00
6d0c568aaa update doc / fix incorrect comment about sending defaultint to binary mode 2020-02-24 16:24:32 -08:00
c96abcef1c build status github badge 2020-02-23 09:46:08 -08:00
4a9b0b9dfd (server) give thread name to some usual worker threads / unittest is broken !! 2020-02-23 09:44:58 -08:00
8837d5e784 (websocket server) fix regression from 8.1.2, where per-deflate message compression was always disabled 2020-02-22 10:15:43 -08:00
242c945400 (client + server) Fix #155 / http header parser should treat the space(s) after the : delimiter as optional. Fixing this bug made us discover that websocket sub-protocols are not properly serialiazed, but start with a , 2020-02-21 14:05:38 -08:00
feab4dee0f split httpd test case into 2 test cases 2020-02-21 12:24:22 -08:00
8175829b4b unittest / add extra test for checking headers 2020-02-21 12:22:37 -08:00
4c66a7561e (WebSocketServer) add option to disable deflate compression, exposed with the -x option to ws echo_server 2020-02-18 21:38:28 -08:00
111475e65c (ws cobra to statsd and sentry sender) exit if no messages are received for one minute, which is a sign that something goes wrong on the server side. That should be changed to be configurable in the future 2020-02-18 12:43:07 -08:00
50 changed files with 2680 additions and 33 deletions

View File

@ -1,4 +1,4 @@
name: C/C++ CI name: unittest
on: [push] on: [push]

View File

@ -201,8 +201,8 @@ if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(ixwebsocket ${ZLIB_LIBRARIES}) target_link_libraries(ixwebsocket ${ZLIB_LIBRARIES})
else() else()
add_subdirectory(third_party/zlib)
include_directories(third_party/zlib ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib) include_directories(third_party/zlib ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib)
add_subdirectory(third_party/zlib)
target_link_libraries(ixwebsocket zlibstatic) target_link_libraries(ixwebsocket zlibstatic)
endif() endif()
@ -232,6 +232,7 @@ if (USE_WS OR USE_TEST)
add_subdirectory(ixsentry) add_subdirectory(ixsentry)
add_subdirectory(third_party/spdlog spdlog) add_subdirectory(third_party/spdlog spdlog)
add_subdirectory(third_party/sentry-native sentry-native)
if (USE_WS) if (USE_WS)
add_subdirectory(ws) add_subdirectory(ws)

View File

@ -1,6 +1,6 @@
## Hello world ## Hello world
![Build status badge](https://travis-ci.org/machinezone/IXWebSocket.svg?branch=master) ![Build status](https://github.com/machinezone/IXWebSocket/workflows/unittest/badge.svg)
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.

View File

@ -1,6 +1,38 @@
# Changelog # Changelog
All changes to this project will be documented in this file. All changes to this project will be documented in this file.
## [8.1.8] - 2020-03-02
(websocket server) fix regression with disabling zlib extension on the server side. If a client does not support this extension the server will handle it fine. We still need to figure out how to disable the option.
## [8.1.7] - 2020-02-26
(websocket) traffic tracker received bytes is message size while it should be wire size
## [8.1.6] - 2020-02-26
(ws_connect) display sent/received bytes statistics on exit
## [8.1.5] - 2020-02-23
(server) give thread name to some usual worker threads / unittest is broken !!
## [8.1.4] - 2020-02-22
(websocket server) fix regression from 8.1.2, where per-deflate message compression was always disabled
## [8.1.3] - 2020-02-21
(client + server) Fix #155 / http header parser should treat the space(s) after the : delimiter as optional. Fixing this bug made us discover that websocket sub-protocols are not properly serialiazed, but start with a ,
## [8.1.2] - 2020-02-18
(WebSocketServer) add option to disable deflate compression, exposed with the -x option to ws echo_server
## [8.1.1] - 2020-02-18
(ws cobra to statsd and sentry sender) exit if no messages are received for one minute, which is a sign that something goes wrong on the server side. That should be changed to be configurable in the future
## [8.1.0] - 2020-02-13 ## [8.1.0] - 2020-02-13
(http client + sentry minidump upload) Multipart stream closing boundary is invalid + mark some options as mandatory in the command line tools (http client + sentry minidump upload) Multipart stream closing boundary is invalid + mark some options as mandatory in the command line tools

View File

@ -42,7 +42,8 @@ namespace
namespace ix namespace ix
{ {
HttpServer::HttpServer(int port, const std::string& host, int backlog, size_t maxConnections, int addressFamily) HttpServer::HttpServer(
int port, const std::string& host, int backlog, size_t maxConnections, int addressFamily)
: SocketServer(port, host, backlog, maxConnections, addressFamily) : SocketServer(port, host, backlog, maxConnections, addressFamily)
, _connectedClientsCount(0) , _connectedClientsCount(0)
{ {

View File

@ -7,6 +7,7 @@
#include "IXSocketServer.h" #include "IXSocketServer.h"
#include "IXNetSystem.h" #include "IXNetSystem.h"
#include "IXSetThreadName.h"
#include "IXSocket.h" #include "IXSocket.h"
#include "IXSocketConnect.h" #include "IXSocketConnect.h"
#include "IXSocketFactory.h" #include "IXSocketFactory.h"
@ -23,11 +24,8 @@ namespace ix
const size_t SocketServer::kDefaultMaxConnections(32); const size_t SocketServer::kDefaultMaxConnections(32);
const int SocketServer::kDefaultAddressFamily(AF_INET); const int SocketServer::kDefaultAddressFamily(AF_INET);
SocketServer::SocketServer(int port, SocketServer::SocketServer(
const std::string& host, int port, const std::string& host, int backlog, size_t maxConnections, int addressFamily)
int backlog,
size_t maxConnections,
int addressFamily)
: _port(port) : _port(port)
, _host(host) , _host(host)
, _backlog(backlog) , _backlog(backlog)
@ -97,7 +95,8 @@ namespace ix
{ {
std::stringstream ss; std::stringstream ss;
ss << "SocketServer::listen() error calling inet_pton " ss << "SocketServer::listen() error calling inet_pton "
<< "at address " << _host << ":" << _port << " : " << strerror(Socket::getErrno()); << "at address " << _host << ":" << _port << " : "
<< strerror(Socket::getErrno());
Socket::closeSocket(_serverFd); Socket::closeSocket(_serverFd);
return std::make_pair(false, ss.str()); return std::make_pair(false, ss.str());
@ -108,7 +107,8 @@ namespace ix
{ {
std::stringstream ss; std::stringstream ss;
ss << "SocketServer::listen() error calling bind " ss << "SocketServer::listen() error calling bind "
<< "at address " << _host << ":" << _port << " : " << strerror(Socket::getErrno()); << "at address " << _host << ":" << _port << " : "
<< strerror(Socket::getErrno());
Socket::closeSocket(_serverFd); Socket::closeSocket(_serverFd);
return std::make_pair(false, ss.str()); return std::make_pair(false, ss.str());
@ -124,7 +124,8 @@ namespace ix
{ {
std::stringstream ss; std::stringstream ss;
ss << "SocketServer::listen() error calling inet_pton " ss << "SocketServer::listen() error calling inet_pton "
<< "at address " << _host << ":" << _port << " : " << strerror(Socket::getErrno()); << "at address " << _host << ":" << _port << " : "
<< strerror(Socket::getErrno());
Socket::closeSocket(_serverFd); Socket::closeSocket(_serverFd);
return std::make_pair(false, ss.str()); return std::make_pair(false, ss.str());
@ -135,7 +136,8 @@ namespace ix
{ {
std::stringstream ss; std::stringstream ss;
ss << "SocketServer::listen() error calling bind " ss << "SocketServer::listen() error calling bind "
<< "at address " << _host << ":" << _port << " : " << strerror(Socket::getErrno()); << "at address " << _host << ":" << _port << " : "
<< strerror(Socket::getErrno());
Socket::closeSocket(_serverFd); Socket::closeSocket(_serverFd);
return std::make_pair(false, ss.str()); return std::make_pair(false, ss.str());
@ -246,6 +248,8 @@ namespace ix
// Set the socket to non blocking mode, so that accept calls are not blocking // Set the socket to non blocking mode, so that accept calls are not blocking
SocketConnect::configure(_serverFd); SocketConnect::configure(_serverFd);
setThreadName("SocketServer::listen");
for (;;) for (;;)
{ {
if (_stop) return; if (_stop) return;
@ -346,6 +350,8 @@ namespace ix
void SocketServer::runGC() void SocketServer::runGC()
{ {
setThreadName("SocketServer::GC");
for (;;) for (;;)
{ {
// Garbage collection to shutdown/join threads for closed connections. // Garbage collection to shutdown/join threads for closed connections.

View File

@ -134,6 +134,13 @@ namespace ix
_enablePong = false; _enablePong = false;
} }
void WebSocket::enablePerMessageDeflate()
{
std::lock_guard<std::mutex> lock(_configMutex);
WebSocketPerMessageDeflateOptions perMessageDeflateOptions(true);
_perMessageDeflateOptions = perMessageDeflateOptions;
}
void WebSocket::disablePerMessageDeflate() void WebSocket::disablePerMessageDeflate()
{ {
std::lock_guard<std::mutex> lock(_configMutex); std::lock_guard<std::mutex> lock(_configMutex);
@ -191,9 +198,19 @@ namespace ix
auto subProtocols = getSubProtocols(); auto subProtocols = getSubProtocols();
if (!subProtocols.empty()) if (!subProtocols.empty())
{ {
//
// Sub Protocol strings are comma separated.
// Python code to do that is:
// >>> ','.join(['json', 'msgpack'])
// 'json,msgpack'
//
int i = 0;
for (auto subProtocol : subProtocols) for (auto subProtocol : subProtocols)
{ {
subProtocolsHeader += ","; if (i++ != 0)
{
subProtocolsHeader += ",";
}
subProtocolsHeader += subProtocol; subProtocolsHeader += subProtocol;
} }
headers["Sec-WebSocket-Protocol"] = subProtocolsHeader; headers["Sec-WebSocket-Protocol"] = subProtocolsHeader;
@ -395,7 +412,7 @@ namespace ix
WebSocketCloseInfo(), WebSocketCloseInfo(),
binary)); binary));
WebSocket::invokeTrafficTrackerCallback(msg.size(), true); WebSocket::invokeTrafficTrackerCallback(wireSize, true);
}); });
} }
} }

View File

@ -19,10 +19,10 @@
#include "IXWebSocketSendInfo.h" #include "IXWebSocketSendInfo.h"
#include "IXWebSocketTransport.h" #include "IXWebSocketTransport.h"
#include <atomic> #include <atomic>
#include <condition_variable>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <thread> #include <thread>
#include <condition_variable>
namespace ix namespace ix
{ {
@ -57,6 +57,7 @@ namespace ix
void setPingTimeout(int pingTimeoutSecs); void setPingTimeout(int pingTimeoutSecs);
void enablePong(); void enablePong();
void disablePong(); void disablePong();
void enablePerMessageDeflate();
void disablePerMessageDeflate(); void disablePerMessageDeflate();
void addSubProtocol(const std::string& subProtocol); void addSubProtocol(const std::string& subProtocol);
@ -71,7 +72,7 @@ namespace ix
WebSocketInitResult connect(int timeoutSecs); WebSocketInitResult connect(int timeoutSecs);
void run(); void run();
// send is in binary mode by default // send is in text mode by default
WebSocketSendInfo send(const std::string& data, WebSocketSendInfo send(const std::string& data,
bool binary = false, bool binary = false,
const OnProgressCallback& onProgressCallback = nullptr); const OnProgressCallback& onProgressCallback = nullptr);

View File

@ -12,6 +12,7 @@
#include "IXUserAgent.h" #include "IXUserAgent.h"
#include "libwshandshake.hpp" #include "libwshandshake.hpp"
#include <algorithm> #include <algorithm>
#include <iostream>
#include <random> #include <random>
#include <sstream> #include <sstream>
@ -335,7 +336,7 @@ namespace ix
std::string header = headers["sec-websocket-extensions"]; std::string header = headers["sec-websocket-extensions"];
WebSocketPerMessageDeflateOptions webSocketPerMessageDeflateOptions(header); WebSocketPerMessageDeflateOptions webSocketPerMessageDeflateOptions(header);
// If the client has requested that extension, enable it. // If the client has requested that extension,
if (webSocketPerMessageDeflateOptions.enabled()) if (webSocketPerMessageDeflateOptions.enabled())
{ {
_enablePerMessageDeflate = true; _enablePerMessageDeflate = true;

View File

@ -66,12 +66,23 @@ namespace ix
{ {
line[i] = '\0'; line[i] = '\0';
std::string lineStr(line); std::string lineStr(line);
// colon is ':', colon+1 is ' ', colon+2 is the start of the value. // colon is ':', usually colon+1 is ' ', and colon+2 is the start of the value.
// some webservers do not put a space after the colon character, so
// the start of the value might be farther than colon+2.
// The spec says that space after the : should be discarded.
// i is end of string (\0), i-colon is length of string minus key; // i is end of string (\0), i-colon is length of string minus key;
// subtract 1 for '\0', 1 for '\n', 1 for '\r', // subtract 1 for '\0', 1 for '\n', 1 for '\r',
// 1 for the ' ' after the ':', and total is -4 // 1 for the ' ' after the ':', and total is -4
// since we use an std::string later on and don't account for '\0',
// plus the optional first space, total is -2
int start = colon + 1;
while (lineStr[start] == ' ')
{
start++;
}
std::string name(lineStr.substr(0, colon)); std::string name(lineStr.substr(0, colon));
std::string value(lineStr.substr(colon + 2, i - colon - 4)); std::string value(lineStr.substr(start, lineStr.size() - start - 2));
headers[name] = value; headers[name] = value;
} }

View File

@ -7,6 +7,7 @@
#include "IXWebSocketServer.h" #include "IXWebSocketServer.h"
#include "IXNetSystem.h" #include "IXNetSystem.h"
#include "IXSetThreadName.h"
#include "IXSocketConnect.h" #include "IXSocketConnect.h"
#include "IXWebSocket.h" #include "IXWebSocket.h"
#include "IXWebSocketTransport.h" #include "IXWebSocketTransport.h"
@ -28,6 +29,7 @@ namespace ix
: SocketServer(port, host, backlog, maxConnections, addressFamily) : SocketServer(port, host, backlog, maxConnections, addressFamily)
, _handshakeTimeoutSecs(handshakeTimeoutSecs) , _handshakeTimeoutSecs(handshakeTimeoutSecs)
, _enablePong(kDefaultEnablePong) , _enablePong(kDefaultEnablePong)
, _enablePerMessageDeflate(true)
{ {
} }
@ -59,6 +61,11 @@ namespace ix
_enablePong = false; _enablePong = false;
} }
void WebSocketServer::disablePerMessageDeflate()
{
_enablePerMessageDeflate = false;
}
void WebSocketServer::setOnConnectionCallback(const OnConnectionCallback& callback) void WebSocketServer::setOnConnectionCallback(const OnConnectionCallback& callback)
{ {
_onConnectionCallback = callback; _onConnectionCallback = callback;
@ -67,15 +74,21 @@ namespace ix
void WebSocketServer::handleConnection(std::shared_ptr<Socket> socket, void WebSocketServer::handleConnection(std::shared_ptr<Socket> socket,
std::shared_ptr<ConnectionState> connectionState) std::shared_ptr<ConnectionState> connectionState)
{ {
setThreadName("WebSocketServer::" + connectionState->getId());
auto webSocket = std::make_shared<WebSocket>(); auto webSocket = std::make_shared<WebSocket>();
_onConnectionCallback(webSocket, connectionState); _onConnectionCallback(webSocket, connectionState);
webSocket->disableAutomaticReconnection(); webSocket->disableAutomaticReconnection();
if (_enablePong) if (_enablePong)
{
webSocket->enablePong(); webSocket->enablePong();
}
else else
{
webSocket->disablePong(); webSocket->disablePong();
}
// Add this client to our client set // Add this client to our client set
{ {

View File

@ -36,6 +36,7 @@ namespace ix
void enablePong(); void enablePong();
void disablePong(); void disablePong();
void disablePerMessageDeflate();
void setOnConnectionCallback(const OnConnectionCallback& callback); void setOnConnectionCallback(const OnConnectionCallback& callback);
@ -48,6 +49,7 @@ namespace ix
// Member variables // Member variables
int _handshakeTimeoutSecs; int _handshakeTimeoutSecs;
bool _enablePong; bool _enablePong;
bool _enablePerMessageDeflate;
OnConnectionCallback _onConnectionCallback; OnConnectionCallback _onConnectionCallback;

View File

@ -6,4 +6,4 @@
#pragma once #pragma once
#define IX_WEBSOCKET_VERSION "8.1.0" #define IX_WEBSOCKET_VERSION "8.1.7"

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ALL_BUILD
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD:
echo ""
echo Build\ all\ projects

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ALL_BUILD
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD:
echo ""
echo Build\ all\ projects

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ALL_BUILD
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD:
echo ""
echo Build\ all\ projects

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ALL_BUILD
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ALL_BUILD:
echo ""
echo Build\ all\ projects

View File

@ -0,0 +1,18 @@
# Generated by CMake, DO NOT EDIT
TARGETS:=
empty:=
space:= $(empty) $(empty)
spaceplus:= $(empty)\ $(empty)
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Applications/CMake.app/Contents/share/cmake-3.12/Modules/CMakeASMInformation.cmake))
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Applications/CMake.app/Contents/share/cmake-3.12/Modules/Compiler/AppleClang-ASM.cmake))
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Applications/CMake.app/Contents/share/cmake-3.12/Modules/Compiler/Clang-ASM.cmake))
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Applications/CMake.app/Contents/share/cmake-3.12/Modules/Compiler/Clang.cmake))
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Applications/CMake.app/Contents/share/cmake-3.12/Modules/Platform/Apple-clang.cmake))
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Users/bsergeant/src/foss/IXWebSocket/CMakeFiles/3.12.3/CMakeASMCompiler.cmake))
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Users/bsergeant/src/foss/IXWebSocket/third_party/sentry-native/CMakeLists.txt))
TARGETS += $(subst $(space),$(spaceplus),$(wildcard /Users/bsergeant/src/foss/IXWebSocket/third_party/sentry-native/src/CMakeLists.txt))
/Users/bsergeant/src/foss/IXWebSocket/CMakeFiles/cmake.check_cache: $(TARGETS)
/Applications/CMake.app/Contents/bin/cmake -H/Users/bsergeant/src/foss/IXWebSocket -B/Users/bsergeant/src/foss/IXWebSocket

View File

@ -0,0 +1,139 @@
# DO NOT EDIT
# This makefile makes sure all linkable targets are
# up-to-date with anything they link to
default:
echo "Do not invoke directly"
# Rules to remove targets that are older than anything to which they
# link. This forces Xcode to relink the targets from scratch. It
# does not seem to check these dependencies itself.
PostBuild.example.Debug:
PostBuild.sentry.Debug: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/example:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example
PostBuild.example_crashpad.Debug:
PostBuild.sentry.Debug: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example_crashpad
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/example_crashpad:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example_crashpad
PostBuild.sentry.Debug:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
PostBuild.sentry_test_integration.Debug:
PostBuild.sentry.Debug: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_integration
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_integration:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_integration
PostBuild.sentry_test_unit.Debug:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_unit:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_unit
PostBuild.example.Release:
PostBuild.sentry.Release: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/example:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example
PostBuild.example_crashpad.Release:
PostBuild.sentry.Release: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example_crashpad
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/example_crashpad:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/example_crashpad
PostBuild.sentry.Release:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
PostBuild.sentry_test_integration.Release:
PostBuild.sentry.Release: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_integration
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_integration:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_integration
PostBuild.sentry_test_unit.Release:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_unit:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/sentry_test_unit
PostBuild.example.MinSizeRel:
PostBuild.sentry.MinSizeRel: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/example
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/example:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/example
PostBuild.example_crashpad.MinSizeRel:
PostBuild.sentry.MinSizeRel: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/example_crashpad
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/example_crashpad:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/example_crashpad
PostBuild.sentry.MinSizeRel:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a
PostBuild.sentry_test_integration.MinSizeRel:
PostBuild.sentry.MinSizeRel: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/sentry_test_integration
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/sentry_test_integration:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/sentry_test_integration
PostBuild.sentry_test_unit.MinSizeRel:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/sentry_test_unit:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/sentry_test_unit
PostBuild.example.RelWithDebInfo:
PostBuild.sentry.RelWithDebInfo: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/example
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/example:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/example
PostBuild.example_crashpad.RelWithDebInfo:
PostBuild.sentry.RelWithDebInfo: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/example_crashpad
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/example_crashpad:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/example_crashpad
PostBuild.sentry.RelWithDebInfo:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a
PostBuild.sentry_test_integration.RelWithDebInfo:
PostBuild.sentry.RelWithDebInfo: /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/sentry_test_integration
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/sentry_test_integration:\
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/sentry_test_integration
PostBuild.sentry_test_unit.RelWithDebInfo:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/sentry_test_unit:
/bin/rm -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/sentry_test_unit
# For each target create a dummy ruleso the target does not have to exist
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a:
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a:

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ZERO_CHECK
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK:
echo ""
make -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeScripts/ReRunCMake.make

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ZERO_CHECK
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK:
echo ""
make -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeScripts/ReRunCMake.make

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ZERO_CHECK
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK:
echo ""
make -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeScripts/ReRunCMake.make

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for ZERO_CHECK
.SUFFIXES:
all: \
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK
/Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeFiles/ZERO_CHECK:
echo ""
make -f /Users/bsergeant/src/foss/IXWebSocket/sentry-native/CMakeScripts/ReRunCMake.make

View File

@ -0,0 +1,9 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for install
.SUFFIXES:
all: \
install_buildpart_0
install_buildpart_0:
/Applications/CMake.app/Contents/bin/cmake -DBUILD_TYPE=$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -P cmake_install.cmake

View File

@ -0,0 +1,9 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for install
.SUFFIXES:
all: \
install_buildpart_0
install_buildpart_0:
/Applications/CMake.app/Contents/bin/cmake -DBUILD_TYPE=$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -P cmake_install.cmake

View File

@ -0,0 +1,9 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for install
.SUFFIXES:
all: \
install_buildpart_0
install_buildpart_0:
/Applications/CMake.app/Contents/bin/cmake -DBUILD_TYPE=$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -P cmake_install.cmake

View File

@ -0,0 +1,9 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for install
.SUFFIXES:
all: \
install_buildpart_0
install_buildpart_0:
/Applications/CMake.app/Contents/bin/cmake -DBUILD_TYPE=$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -P cmake_install.cmake

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for sentry
.SUFFIXES:
all: \
sentry_buildpart_0
sentry_buildpart_0:
echo "Creating symlinks"
/Applications/CMake.app/Contents/bin/cmake -E cmake_symlink_library /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.dylib

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for sentry
.SUFFIXES:
all: \
sentry_buildpart_0
sentry_buildpart_0:
echo "Creating symlinks"
/Applications/CMake.app/Contents/bin/cmake -E cmake_symlink_library /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.dylib

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for sentry
.SUFFIXES:
all: \
sentry_buildpart_0
sentry_buildpart_0:
echo "Creating symlinks"
/Applications/CMake.app/Contents/bin/cmake -E cmake_symlink_library /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.dylib

View File

@ -0,0 +1,10 @@
# Generated by CMake, DO NOT EDIT
# Custom rules for sentry
.SUFFIXES:
all: \
sentry_buildpart_0
sentry_buildpart_0:
echo "Creating symlinks"
/Applications/CMake.app/Contents/bin/cmake -E cmake_symlink_library /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.dylib /Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.dylib

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>

View File

@ -0,0 +1,84 @@
# Install script for directory: /Users/bsergeant/src/foss/IXWebSocket/third_party/sentry-native
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "Release")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
execute_process(COMMAND "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
endif()
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
execute_process(COMMAND "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
endif()
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
execute_process(COMMAND "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
endif()
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
execute_process(COMMAND "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libsentry.a")
endif()
endif()
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include" TYPE FILE FILES "/Users/bsergeant/src/foss/IXWebSocket/third_party/sentry-native/include/sentry.h")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a.dSYM")
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/libsentry.a.dSYM")
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/MinSizeRel/libsentry.a.dSYM")
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE FILES "/Users/bsergeant/src/foss/IXWebSocket/sentry-native/RelWithDebInfo/libsentry.a.dSYM")
endif()
endif()
if(NOT CMAKE_INSTALL_LOCAL_ONLY)
# Include the install script for each subdirectory.
include("/Users/bsergeant/src/foss/IXWebSocket/sentry-native/src/cmake_install.cmake")
endif()

View File

@ -0,0 +1,34 @@
# Install script for directory: /Users/bsergeant/src/foss/IXWebSocket/third_party/sentry-native/src
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "Release")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()

View File

@ -59,10 +59,14 @@ TEST_CASE("http server", "[httpd]")
REQUIRE(response->errorCode == HttpErrorCode::Ok); REQUIRE(response->errorCode == HttpErrorCode::Ok);
REQUIRE(response->statusCode == 200); REQUIRE(response->statusCode == 200);
REQUIRE(response->headers["Accept-Encoding"] == "gzip");
server.stop(); server.stop();
} }
}
TEST_CASE("http server redirection", "[httpd_redirect]")
{
SECTION("Connect to a local HTTP server, with redirection enabled") SECTION("Connect to a local HTTP server, with redirection enabled")
{ {
int port = getFreePort(); int port = getFreePort();

View File

@ -0,0 +1,11 @@
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});

View File

@ -0,0 +1,11 @@
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080, perMessageDeflate: true });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});

View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
# websocket send client
import argparse
import asyncio
import websockets
async def send(url):
async with websockets.connect(url) as ws:
while True:
message = input('> ')
print('Sending message...')
await ws.send(message)
print('Message sent.')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='websocket proxy.')
parser.add_argument('--url', help='Remote websocket url',
default='wss://echo.websocket.org')
args = parser.parse_args()
asyncio.get_event_loop().run_until_complete(send(args.url))

View File

@ -8,9 +8,10 @@ import websockets
async def echo(websocket, path): async def echo(websocket, path):
msg = await websocket.recv() while True:
print(f'Received {len(msg)} bytes') msg = await websocket.recv()
await websocket.send(msg) print(f'Received {len(msg)} bytes')
await websocket.send(msg)
host = os.getenv('BIND_HOST', 'localhost') host = os.getenv('BIND_HOST', 'localhost')
print(f'Serving on {host}:8766') print(f'Serving on {host}:8766')

View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
# WS server example
import asyncio
import os
import websockets
async def echo(websocket, path):
while True:
msg = await websocket.recv()
print(f'Received {len(msg)} bytes')
await websocket.send(msg)
host = os.getenv('BIND_HOST', 'localhost')
print(f'Serving on {host}:8766')
start_server = websockets.serve(echo, host, 8766, max_size=2 ** 30)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

View File

@ -24,6 +24,7 @@ include_directories(ws ../third_party)
include_directories(ws ../third_party/statsd-client-cpp/src) include_directories(ws ../third_party/statsd-client-cpp/src)
include_directories(ws ../third_party/spdlog/include) include_directories(ws ../third_party/spdlog/include)
include_directories(ws ../third_party/cpp-linenoise) include_directories(ws ../third_party/cpp-linenoise)
include_directories(ws ../third_party/sentry-native/include)
add_definitions(-DSPDLOG_COMPILED_LIB=1) add_definitions(-DSPDLOG_COMPILED_LIB=1)
@ -76,6 +77,7 @@ target_link_libraries(ws ixcore)
target_link_libraries(ws ixsentry) target_link_libraries(ws ixsentry)
target_link_libraries(ws spdlog) target_link_libraries(ws spdlog)
target_link_libraries(ws sentry)
if(NOT APPLE AND NOT USE_MBED_TLS) if(NOT APPLE AND NOT USE_MBED_TLS)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)

View File

@ -9,6 +9,7 @@
// //
#include "ws.h" #include "ws.h"
#include <sentry.h>
#include <cli11/CLI11.hpp> #include <cli11/CLI11.hpp>
#include <fstream> #include <fstream>
#include <ixcore/utils/IXCoreLogger.h> #include <ixcore/utils/IXCoreLogger.h>
@ -26,9 +27,21 @@
#define getpid _getpid #define getpid _getpid
#endif #endif
void initSentry()
{
sentry_options_t *options = sentry_options_new();
sentry_options_set_environment(options, "Production");
sentry_options_set_release(options, "5fd7a6cd");
// sentry_options_set_debug(options, 1);
sentry_init(options);
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
initSentry();
ix::initNetSystem(); ix::initNetSystem();
ix::IXCoreLogger::LogFunc logFunc = [](const char* msg) { spdlog::info(msg); }; ix::IXCoreLogger::LogFunc logFunc = [](const char* msg) { spdlog::info(msg); };
@ -174,6 +187,7 @@ int main(int argc, char** argv)
echoServerApp->add_option("--host", hostname, "Hostname"); echoServerApp->add_option("--host", hostname, "Hostname");
echoServerApp->add_flag("-g", greetings, "Verbose"); echoServerApp->add_flag("-g", greetings, "Verbose");
echoServerApp->add_flag("-6", ipv6, "IpV6"); echoServerApp->add_flag("-6", ipv6, "IpV6");
echoServerApp->add_flag("-x", disablePerMessageDeflate, "Disable per message deflate");
addTLSOptions(echoServerApp); addTLSOptions(echoServerApp);
CLI::App* broadcastServerApp = app.add_subcommand("broadcast_server", "Broadcasting server"); CLI::App* broadcastServerApp = app.add_subcommand("broadcast_server", "Broadcasting server");
@ -336,8 +350,12 @@ int main(int argc, char** argv)
addTLSOptions(proxyServerApp); addTLSOptions(proxyServerApp);
CLI::App* minidumpApp = app.add_subcommand("upload_minidump", "Upload a minidump to sentry"); CLI::App* minidumpApp = app.add_subcommand("upload_minidump", "Upload a minidump to sentry");
minidumpApp->add_option("--minidump", minidump, "Minidump path")->required()->check(CLI::ExistingPath); minidumpApp->add_option("--minidump", minidump, "Minidump path")
minidumpApp->add_option("--metadata", metadata, "Metadata path")->required()->check(CLI::ExistingPath); ->required()
->check(CLI::ExistingPath);
minidumpApp->add_option("--metadata", metadata, "Metadata path")
->required()
->check(CLI::ExistingPath);
minidumpApp->add_option("--project", project, "Sentry Project")->required(); minidumpApp->add_option("--project", project, "Sentry Project")->required();
minidumpApp->add_option("--key", key, "Sentry Key")->required(); minidumpApp->add_option("--key", key, "Sentry Key")->required();
minidumpApp->add_flag("-v", verbose, "Verbose"); minidumpApp->add_flag("-v", verbose, "Verbose");
@ -363,6 +381,8 @@ int main(int argc, char** argv)
tlsOptions.caFile = "NONE"; tlsOptions.caFile = "NONE";
} }
// memset((char *)0x0, 1, 100);
int ret = 1; int ret = 1;
if (app.got_subcommand("transfer")) if (app.got_subcommand("transfer"))
{ {
@ -394,7 +414,8 @@ int main(int argc, char** argv)
} }
else if (app.got_subcommand("echo_server")) else if (app.got_subcommand("echo_server"))
{ {
ret = ix::ws_echo_server_main(port, greetings, hostname, tlsOptions, ipv6); ret = ix::ws_echo_server_main(
port, greetings, hostname, tlsOptions, ipv6, disablePerMessageDeflate);
} }
else if (app.got_subcommand("broadcast_server")) else if (app.got_subcommand("broadcast_server"))
{ {

View File

@ -30,7 +30,8 @@ namespace ix
bool greetings, bool greetings,
const std::string& hostname, const std::string& hostname,
const ix::SocketTLSOptions& tlsOptions, const ix::SocketTLSOptions& tlsOptions,
bool ipv6); bool ipv6,
bool disablePerMessageDeflate);
int ws_broadcast_server_main(int port, int ws_broadcast_server_main(int port,
const std::string& hostname, const std::string& hostname,

View File

@ -135,6 +135,31 @@ namespace ix
std::thread t1(timer); std::thread t1(timer);
auto heartbeat = [&sentCount, &receivedCount] {
std::string state("na");
while (true)
{
std::stringstream ss;
ss << "messages received " << receivedCount;
ss << "messages sent " << sentCount;
std::string currentState = ss.str();
if (currentState == state)
{
spdlog::error("no messages received or sent for 1 minute, exiting");
exit(1);
}
state = currentState;
auto duration = std::chrono::minutes(1);
std::this_thread::sleep_for(duration);
}
};
std::thread t2(heartbeat);
auto sentrySender = auto sentrySender =
[&queueManager, verbose, &errorSending, &sentCount, &stop, &throttled, &dsn] { [&queueManager, verbose, &errorSending, &sentCount, &stop, &throttled, &dsn] {
SentryClient sentryClient(dsn); SentryClient sentryClient(dsn);

View File

@ -153,6 +153,31 @@ namespace ix
std::thread t1(timer); std::thread t1(timer);
auto heartbeat = [&sentCount, &receivedCount] {
std::string state("na");
while (true)
{
std::stringstream ss;
ss << "messages received " << receivedCount;
ss << "messages sent " << sentCount;
std::string currentState = ss.str();
if (currentState == state)
{
spdlog::error("no messages received or sent for 1 minute, exiting");
exit(1);
}
state = currentState;
auto duration = std::chrono::minutes(1);
std::this_thread::sleep_for(duration);
}
};
std::thread t2(heartbeat);
auto statsdSender = [&queueManager, &host, &port, &sentCount, &tokens, &prefix, &stop] { auto statsdSender = [&queueManager, &host, &port, &sentCount, &tokens, &prefix, &stop] {
// statsd client // statsd client
// test with netcat as a server: `nc -ul 8125` // test with netcat as a server: `nc -ul 8125`
@ -184,7 +209,7 @@ namespace ix
} }
}; };
std::thread t2(statsdSender); std::thread t3(statsdSender);
conn.setEventCallback( conn.setEventCallback(
[&conn, &channel, &filter, &jsonWriter, verbose, &queueManager, &receivedCount]( [&conn, &channel, &filter, &jsonWriter, verbose, &queueManager, &receivedCount](

View File

@ -30,6 +30,9 @@ namespace ix
void start(); void start();
void stop(); void stop();
int getSentBytes() { return _sentBytes; }
int getReceivedBytes() { return _receivedBytes; }
void sendMessage(const std::string& text); void sendMessage(const std::string& text);
private: private:
@ -38,6 +41,8 @@ namespace ix
ix::WebSocket _webSocket; ix::WebSocket _webSocket;
bool _disablePerMessageDeflate; bool _disablePerMessageDeflate;
bool _binaryMode; bool _binaryMode;
std::atomic<int> _receivedBytes;
std::atomic<int> _sentBytes;
void log(const std::string& msg); void log(const std::string& msg);
WebSocketHttpHeaders parseHeaders(const std::string& data); WebSocketHttpHeaders parseHeaders(const std::string& data);
@ -54,6 +59,8 @@ namespace ix
: _url(url) : _url(url)
, _disablePerMessageDeflate(disablePerMessageDeflate) , _disablePerMessageDeflate(disablePerMessageDeflate)
, _binaryMode(binaryMode) , _binaryMode(binaryMode)
, _receivedBytes(0)
, _sentBytes(0)
{ {
if (disableAutomaticReconnection) if (disableAutomaticReconnection)
{ {
@ -68,6 +75,20 @@ namespace ix
{ {
_webSocket.addSubProtocol(subprotocol); _webSocket.addSubProtocol(subprotocol);
} }
WebSocket::setTrafficTrackerCallback(
[this](int size, bool incoming)
{
if (incoming)
{
_receivedBytes += size;
}
else
{
_sentBytes += size;
}
}
);
} }
void WebSocketConnect::log(const std::string& msg) void WebSocketConnect::log(const std::string& msg)
@ -246,6 +267,9 @@ namespace ix
spdlog::info(""); spdlog::info("");
webSocketChat.stop(); webSocketChat.stop();
spdlog::info("Received {} bytes", webSocketChat.getReceivedBytes());
spdlog::info("Sent {} bytes", webSocketChat.getSentBytes());
return 0; return 0;
} }
} // namespace ix } // namespace ix

View File

@ -5,10 +5,10 @@
*/ */
#include <atomic> #include <atomic>
#include <ixwebsocket/IXDNSLookup.h>
#include <ixwebsocket/IXNetSystem.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <sstream> #include <sstream>
#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXDNSLookup.h>
namespace ix namespace ix

View File

@ -4,8 +4,8 @@
* Copyright (c) 2018 Machine Zone, Inc. All rights reserved. * Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
*/ */
#include <ixwebsocket/IXWebSocketServer.h>
#include <ixwebsocket/IXNetSystem.h> #include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXWebSocketServer.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <sstream> #include <sstream>
@ -15,7 +15,8 @@ namespace ix
bool greetings, bool greetings,
const std::string& hostname, const std::string& hostname,
const ix::SocketTLSOptions& tlsOptions, const ix::SocketTLSOptions& tlsOptions,
bool ipv6) bool ipv6,
bool disablePerMessageDeflate)
{ {
spdlog::info("Listening on {}:{}", hostname, port); spdlog::info("Listening on {}:{}", hostname, port);
@ -28,6 +29,12 @@ namespace ix
server.setTLSOptions(tlsOptions); server.setTLSOptions(tlsOptions);
if (disablePerMessageDeflate)
{
spdlog::info("Disable per message deflate");
server.disablePerMessageDeflate();
}
server.setOnConnectionCallback( server.setOnConnectionCallback(
[greetings](std::shared_ptr<ix::WebSocket> webSocket, [greetings](std::shared_ptr<ix::WebSocket> webSocket,
std::shared_ptr<ConnectionState> connectionState) { std::shared_ptr<ConnectionState> connectionState) {