mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
cluster/websocket-ixwebsocket: Determine proper address_family
Closes #4474
This commit is contained in:
parent
372986f052
commit
8b029d0050
1 changed files with 15 additions and 5 deletions
|
@ -3,10 +3,13 @@
|
||||||
// Implementation of a WebSocket server and clients using the IXWebSocket client library.
|
// Implementation of a WebSocket server and clients using the IXWebSocket client library.
|
||||||
#include "zeek/cluster/websocket/WebSocket.h"
|
#include "zeek/cluster/websocket/WebSocket.h"
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include "zeek/IPAddr.h"
|
||||||
#include "zeek/Reporter.h"
|
#include "zeek/Reporter.h"
|
||||||
|
#include "zeek/net_util.h"
|
||||||
|
|
||||||
#include "ixwebsocket/IXConnectionState.h"
|
#include "ixwebsocket/IXConnectionState.h"
|
||||||
#include "ixwebsocket/IXSocketTLSOptions.h"
|
#include "ixwebsocket/IXSocketTLSOptions.h"
|
||||||
|
@ -73,11 +76,18 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<WebSocketServer> StartServer(std::unique_ptr<WebSocketEventDispatcher> dispatcher,
|
std::unique_ptr<WebSocketServer> StartServer(std::unique_ptr<WebSocketEventDispatcher> dispatcher,
|
||||||
const ServerOptions& options) {
|
const ServerOptions& options) {
|
||||||
auto server =
|
if ( ! zeek::IPAddr::IsValid(options.host.c_str()) ) {
|
||||||
std::make_unique<ix::WebSocketServer>(options.port, options.host, ix::SocketServer::kDefaultTcpBacklog,
|
zeek::reporter->Error("WebSocket: Host is not a valid IP %s", options.host.c_str());
|
||||||
options.max_connections,
|
return nullptr;
|
||||||
ix::WebSocketServer::kDefaultHandShakeTimeoutSecs,
|
}
|
||||||
ix::SocketServer::kDefaultAddressFamily, options.ping_interval_seconds);
|
|
||||||
|
zeek::IPAddr host_addr(options.host);
|
||||||
|
int address_family = host_addr.GetFamily() == IPv4 ? AF_INET : AF_INET6;
|
||||||
|
|
||||||
|
auto server = std::make_unique<ix::WebSocketServer>(options.port, options.host,
|
||||||
|
ix::SocketServer::kDefaultTcpBacklog, options.max_connections,
|
||||||
|
ix::WebSocketServer::kDefaultHandShakeTimeoutSecs,
|
||||||
|
address_family, options.ping_interval_seconds);
|
||||||
|
|
||||||
if ( ! options.per_message_deflate )
|
if ( ! options.per_message_deflate )
|
||||||
server->disablePerMessageDeflate();
|
server->disablePerMessageDeflate();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue