Fix last warnings, SocketContextOptions, BloomFilter
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
EXAMPLE_FILES := HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
|
EXAMPLE_FILES := HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
|
||||||
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
|
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
|
||||||
override CXXFLAGS += -lpthread -Wpedantic -Wall -Wextra -std=c++2a -Isrc -IuSockets/src
|
override CXXFLAGS += -lpthread -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++2a -Isrc -IuSockets/src
|
||||||
override LDFLAGS += uSockets/*.o -lz
|
override LDFLAGS += uSockets/*.o -lz
|
||||||
|
|
||||||
DESTDIR ?=
|
DESTDIR ?=
|
||||||
|
|||||||
@@ -29,6 +29,23 @@
|
|||||||
|
|
||||||
namespace uWS {
|
namespace uWS {
|
||||||
|
|
||||||
|
/* This one matches us_socket_context_options_t but has default values */
|
||||||
|
struct SocketContextOptions {
|
||||||
|
const char *key_file_name = nullptr;
|
||||||
|
const char *cert_file_name = nullptr;
|
||||||
|
const char *passphrase = nullptr;
|
||||||
|
const char *dh_params_file_name = nullptr;
|
||||||
|
const char *ca_file_name = nullptr;
|
||||||
|
int ssl_prefer_low_memory_usage = 0;
|
||||||
|
|
||||||
|
/* Conversion operator used internally */
|
||||||
|
operator struct us_socket_context_options_t() const {
|
||||||
|
struct us_socket_context_options_t socket_context_options;
|
||||||
|
memcpy(&socket_context_options, this, sizeof(SocketContextOptions));
|
||||||
|
return socket_context_options;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <bool SSL>
|
template <bool SSL>
|
||||||
struct TemplatedApp {
|
struct TemplatedApp {
|
||||||
private:
|
private:
|
||||||
@@ -39,7 +56,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/* Server name */
|
/* Server name */
|
||||||
TemplatedApp &&addServerName(std::string hostname_pattern, us_socket_context_options_t options = {}) {
|
TemplatedApp &&addServerName(std::string hostname_pattern, SocketContextOptions options = {}) {
|
||||||
|
|
||||||
us_socket_context_add_server_name(SSL, (struct us_socket_context_t *) httpContext, hostname_pattern.c_str(), options);
|
us_socket_context_add_server_name(SSL, (struct us_socket_context_t *) httpContext, hostname_pattern.c_str(), options);
|
||||||
return std::move(*this);
|
return std::move(*this);
|
||||||
@@ -107,7 +124,7 @@ public:
|
|||||||
webSocketContexts = std::move(other.webSocketContexts);
|
webSocketContexts = std::move(other.webSocketContexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplatedApp(us_socket_context_options_t options = {}) {
|
TemplatedApp(SocketContextOptions options = {}) {
|
||||||
httpContext = uWS::HttpContext<SSL>::create(uWS::Loop::get(), options);
|
httpContext = uWS::HttpContext<SSL>::create(uWS::Loop::get(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -31,11 +31,11 @@ private:
|
|||||||
std::bitset<512> filter;
|
std::bitset<512> filter;
|
||||||
|
|
||||||
unsigned int hash1(std::string_view key) {
|
unsigned int hash1(std::string_view key) {
|
||||||
return ((unsigned int)key[key.length() - 1] - (key.length() << 3)) & 511;
|
return ((size_t)key[key.length() - 1] - (key.length() << 3)) & 511;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int hash2(std::string_view key) {
|
unsigned int hash2(std::string_view key) {
|
||||||
return (((unsigned int)key[0] + (key.length() << 4)) & 511);
|
return (((size_t)key[0] + (key.length() << 4)) & 511);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int hash3(std::string_view key) {
|
unsigned int hash3(std::string_view key) {
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ private:
|
|||||||
static unsigned int toUnsignedInteger(std::string_view str) {
|
static unsigned int toUnsignedInteger(std::string_view str) {
|
||||||
unsigned int unsignedIntegerValue = 0;
|
unsigned int unsignedIntegerValue = 0;
|
||||||
for (char c : str) {
|
for (char c : str) {
|
||||||
unsignedIntegerValue = unsignedIntegerValue * 10 + ((unsigned char) c - '0');
|
unsignedIntegerValue = unsignedIntegerValue * 10u + ((unsigned int) c - (unsigned int) '0');
|
||||||
}
|
}
|
||||||
return unsignedIntegerValue;
|
return unsignedIntegerValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,9 +362,9 @@ protected:
|
|||||||
static inline bool consumeContinuation(char *&src, unsigned int &length, WebSocketState<isServer> *wState, void *user) {
|
static inline bool consumeContinuation(char *&src, unsigned int &length, WebSocketState<isServer> *wState, void *user) {
|
||||||
if (wState->remainingBytes <= length) {
|
if (wState->remainingBytes <= length) {
|
||||||
if (isServer) {
|
if (isServer) {
|
||||||
int n = wState->remainingBytes >> 2;
|
unsigned int n = wState->remainingBytes >> 2;
|
||||||
unmaskInplace(src, src + n * 4, wState->mask);
|
unmaskInplace(src, src + n * 4, wState->mask);
|
||||||
for (int i = 0, s = wState->remainingBytes % 4; i < s; i++) {
|
for (unsigned int i = 0, s = wState->remainingBytes % 4; i < s; i++) {
|
||||||
src[n * 4 + i] ^= wState->mask[i];
|
src[n * 4 + i] ^= wState->mask[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user