Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c15964d43 | |||
99fe6ea493 | |||
acab19fe9f |
@ -129,9 +129,6 @@ if (USE_TLS)
|
|||||||
elseif (APPLE AND NOT USE_OPEN_SSL)
|
elseif (APPLE AND NOT USE_OPEN_SSL)
|
||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketAppleSSL.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketAppleSSL.h)
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketAppleSSL.cpp)
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketAppleSSL.cpp)
|
||||||
elseif (WIN32 AND NOT USE_OPEN_SSL)
|
|
||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketSChannel.h)
|
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketSChannel.cpp)
|
|
||||||
else()
|
else()
|
||||||
set(USE_OPEN_SSL ON)
|
set(USE_OPEN_SSL ON)
|
||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
|
||||||
|
@ -21,6 +21,7 @@ FROM alpine:3.11 as runtime
|
|||||||
|
|
||||||
RUN apk add --no-cache libstdc++
|
RUN apk add --no-cache libstdc++
|
||||||
RUN apk add --no-cache strace
|
RUN apk add --no-cache strace
|
||||||
|
RUN apk add --no-cache gdb
|
||||||
|
|
||||||
RUN addgroup -S app && adduser -S -G app app
|
RUN addgroup -S app && adduser -S -G app app
|
||||||
COPY --chown=app:app --from=build /usr/local/bin/ws /usr/local/bin/ws
|
COPY --chown=app:app --from=build /usr/local/bin/ws /usr/local/bin/ws
|
||||||
@ -36,4 +37,3 @@ WORKDIR /home/app
|
|||||||
|
|
||||||
ENTRYPOINT ["ws"]
|
ENTRYPOINT ["ws"]
|
||||||
EXPOSE 8008
|
EXPOSE 8008
|
||||||
C
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [7.9.6] - 2020-01-22
|
||||||
|
|
||||||
|
(ws) add a dnslookup sub-command, to get the ip address of a remote host
|
||||||
|
|
||||||
|
## [7.9.5] - 2020-01-14
|
||||||
|
|
||||||
|
(windows) fix #144, get rid of stubbed/un-implemented windows schannel ssl backend
|
||||||
|
|
||||||
## [7.9.4] - 2020-01-12
|
## [7.9.4] - 2020-01-12
|
||||||
|
|
||||||
(openssl + mbedssl) fix #140, can send large files with ws send over ssl / still broken with apple ssl
|
(openssl + mbedssl) fix #140, can send large files with ws send over ssl / still broken with apple ssl
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
#include "IXSocketOpenSSL.h"
|
#include "IXSocketOpenSSL.h"
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
#include "IXSocketAppleSSL.h"
|
#include "IXSocketAppleSSL.h"
|
||||||
#elif defined(_WIN32)
|
|
||||||
#include "IXSocketSChannel.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -46,8 +44,6 @@ namespace ix
|
|||||||
socket = std::make_shared<SocketMbedTLS>(tlsOptions, fd);
|
socket = std::make_shared<SocketMbedTLS>(tlsOptions, fd);
|
||||||
#elif defined(IXWEBSOCKET_USE_OPEN_SSL)
|
#elif defined(IXWEBSOCKET_USE_OPEN_SSL)
|
||||||
socket = std::make_shared<SocketOpenSSL>(tlsOptions, fd);
|
socket = std::make_shared<SocketOpenSSL>(tlsOptions, fd);
|
||||||
#elif defined(_WIN32)
|
|
||||||
socket = std::make_shared<SocketSChannel>(tlsOptions, fd);
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
socket = std::make_shared<SocketAppleSSL>(tlsOptions, fd);
|
socket = std::make_shared<SocketAppleSSL>(tlsOptions, fd);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* IXSocketSChannel.cpp
|
|
||||||
* Author: Benjamin Sergeant
|
|
||||||
* Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* See https://docs.microsoft.com/en-us/windows/desktop/WinSock/using-secure-socket-extensions
|
|
||||||
*
|
|
||||||
* https://github.com/pauldotknopf/WindowsSDK7-Samples/blob/master/netds/winsock/securesocket/stcpclient/tcpclient.c
|
|
||||||
*
|
|
||||||
* This is the right example to look at:
|
|
||||||
* https://www.codeproject.com/Articles/1000189/A-Working-TCP-Client-and-Server-With-SSL
|
|
||||||
*
|
|
||||||
* Similar code is available from this git repo
|
|
||||||
* https://github.com/david-maw/StreamSSL
|
|
||||||
*/
|
|
||||||
#include "IXSocketSChannel.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <WS2tcpip.h>
|
|
||||||
#include <WinSock2.h>
|
|
||||||
#include <basetsd.h>
|
|
||||||
#include <io.h>
|
|
||||||
#include <schannel.h>
|
|
||||||
#include <ws2def.h>
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#ifndef UNICODE
|
|
||||||
#define UNICODE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <mstcpip.h>
|
|
||||||
#include <ntdsapi.h>
|
|
||||||
#include <rpc.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#define RECV_DATA_BUF_SIZE 256
|
|
||||||
|
|
||||||
// Link with ws2_32.lib
|
|
||||||
#pragma comment(lib, "Ws2_32.lib")
|
|
||||||
|
|
||||||
// link with fwpuclnt.lib for Winsock secure socket extensions
|
|
||||||
#pragma comment(lib, "fwpuclnt.lib")
|
|
||||||
|
|
||||||
// link with ntdsapi.lib for DsMakeSpn function
|
|
||||||
#pragma comment(lib, "ntdsapi.lib")
|
|
||||||
|
|
||||||
// The following function assumes that Winsock
|
|
||||||
// has already been initialized
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error("This file should only be built on Windows")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace ix
|
|
||||||
{
|
|
||||||
SocketSChannel::SocketSChannel()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SocketSChannel::~SocketSChannel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SocketSChannel::connect(const std::string& host, int port, std::string& errMsg)
|
|
||||||
{
|
|
||||||
return Socket::connect(host, port, errMsg, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SocketSChannel::secureSocket()
|
|
||||||
{
|
|
||||||
// there will be a lot to do here ...
|
|
||||||
}
|
|
||||||
|
|
||||||
void SocketSChannel::close()
|
|
||||||
{
|
|
||||||
Socket::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t SocketSChannel::send(char* buf, size_t nbyte)
|
|
||||||
{
|
|
||||||
return Socket::send(buf, nbyte);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t SocketSChannel::send(const std::string& buffer)
|
|
||||||
{
|
|
||||||
return Socket::send(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t SocketSChannel::recv(void* buf, size_t nbyte)
|
|
||||||
{
|
|
||||||
return Socket::recv(buf, nbyte);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ix
|
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* IXSocketSChannel.h
|
|
||||||
* Author: Benjamin Sergeant
|
|
||||||
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "IXSocket.h"
|
|
||||||
|
|
||||||
namespace ix
|
|
||||||
{
|
|
||||||
class SocketSChannel final : public Socket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SocketSChannel();
|
|
||||||
~SocketSChannel();
|
|
||||||
|
|
||||||
virtual bool connect(const std::string& host, int port, std::string& errMsg) final;
|
|
||||||
virtual void close() final;
|
|
||||||
|
|
||||||
// The important override
|
|
||||||
virtual void secureSocket() final;
|
|
||||||
|
|
||||||
virtual ssize_t send(char* buffer, size_t length) final;
|
|
||||||
virtual ssize_t send(const std::string& buffer) final;
|
|
||||||
virtual ssize_t recv(void* buffer, size_t length) final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ix
|
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "7.9.4"
|
#define IX_WEBSOCKET_VERSION "7.9.6"
|
||||||
|
@ -65,6 +65,7 @@ add_executable(ws
|
|||||||
ws_autobahn.cpp
|
ws_autobahn.cpp
|
||||||
ws_proxy_server.cpp
|
ws_proxy_server.cpp
|
||||||
ws_sentry_minidump_upload.cpp
|
ws_sentry_minidump_upload.cpp
|
||||||
|
ws_dns_lookup.cpp
|
||||||
ws.cpp)
|
ws.cpp)
|
||||||
|
|
||||||
target_link_libraries(ws ixsnake)
|
target_link_libraries(ws ixsnake)
|
||||||
|
@ -338,6 +338,9 @@ int main(int argc, char** argv)
|
|||||||
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");
|
||||||
|
|
||||||
|
CLI::App* dnsLookupApp = app.add_subcommand("dnslookup", "DNS lookup");
|
||||||
|
dnsLookupApp->add_option("host", hostname, "Hostname")->required();
|
||||||
|
|
||||||
CLI11_PARSE(app, argc, argv);
|
CLI11_PARSE(app, argc, argv);
|
||||||
|
|
||||||
// pid file handling
|
// pid file handling
|
||||||
@ -509,6 +512,10 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
ret = ix::ws_sentry_minidump_upload(metadata, minidump, project, key, verbose);
|
ret = ix::ws_sentry_minidump_upload(metadata, minidump, project, key, verbose);
|
||||||
}
|
}
|
||||||
|
else if (app.got_subcommand("dnslookup"))
|
||||||
|
{
|
||||||
|
ret = ix::ws_dns_lookup(hostname);
|
||||||
|
}
|
||||||
else if (version)
|
else if (version)
|
||||||
{
|
{
|
||||||
spdlog::info("ws {}", ix::userAgent());
|
spdlog::info("ws {}", ix::userAgent());
|
||||||
|
2
ws/ws.h
2
ws/ws.h
@ -163,4 +163,6 @@ namespace ix
|
|||||||
const std::string& project,
|
const std::string& project,
|
||||||
const std::string& key,
|
const std::string& key,
|
||||||
bool verbose);
|
bool verbose);
|
||||||
|
|
||||||
|
int ws_dns_lookup(const std::string& hostname);
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
34
ws/ws_dns_lookup.cpp
Normal file
34
ws/ws_dns_lookup.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* ws_dns_lookup.cpp
|
||||||
|
* Author: Benjamin Sergeant
|
||||||
|
* Copyright (c) 2020 Machine Zone, Inc. All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <ixwebsocket/IXNetSystem.h>
|
||||||
|
#include <ixwebsocket/IXDNSLookup.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace ix
|
||||||
|
{
|
||||||
|
int ws_dns_lookup(const std::string& hostname)
|
||||||
|
{
|
||||||
|
auto dnsLookup = std::make_shared<DNSLookup>(hostname, 80);
|
||||||
|
|
||||||
|
std::string errMsg;
|
||||||
|
struct addrinfo* res;
|
||||||
|
|
||||||
|
res = dnsLookup->resolve(errMsg, [] { return false; });
|
||||||
|
|
||||||
|
auto addr = res->ai_addr;
|
||||||
|
|
||||||
|
char str[INET_ADDRSTRLEN];
|
||||||
|
inet_ntop(AF_INET, &addr, str, INET_ADDRSTRLEN);
|
||||||
|
|
||||||
|
spdlog::info("host: {} ip: {}", hostname, str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} // namespace ix
|
Reference in New Issue
Block a user