mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-22 07:20:15 +03:00
lib/net: Pass connection security level to within socket classes
This commit is contained in:
parent
5c7d7194d5
commit
57769cffda
@ -25,11 +25,11 @@
|
||||
#include "common/DataDirectories.h"
|
||||
#include "base/String.h"
|
||||
|
||||
SecureListenSocket::SecureListenSocket(
|
||||
IEventQueue* events,
|
||||
SocketMultiplexer* socketMultiplexer,
|
||||
IArchNetwork::EAddressFamily family) :
|
||||
TCPListenSocket(events, socketMultiplexer, family)
|
||||
SecureListenSocket::SecureListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer,
|
||||
IArchNetwork::EAddressFamily family,
|
||||
ConnectionSecurityLevel security_level) :
|
||||
TCPListenSocket(events, socketMultiplexer, family),
|
||||
security_level_{security_level}
|
||||
{
|
||||
}
|
||||
|
||||
@ -38,10 +38,8 @@ SecureListenSocket::accept()
|
||||
{
|
||||
SecureSocket* socket = NULL;
|
||||
try {
|
||||
socket = new SecureSocket(
|
||||
m_events,
|
||||
m_socketMultiplexer,
|
||||
ARCH->acceptSocket(m_socket, NULL));
|
||||
socket = new SecureSocket(m_events, m_socketMultiplexer,
|
||||
ARCH->acceptSocket(m_socket, NULL), security_level_);
|
||||
socket->initSsl(true);
|
||||
|
||||
if (socket != NULL) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "net/TCPListenSocket.h"
|
||||
#include "common/stdset.h"
|
||||
#include "ConnectionSecurityLevel.h"
|
||||
|
||||
class IEventQueue;
|
||||
class SocketMultiplexer;
|
||||
@ -26,11 +27,13 @@ class IDataSocket;
|
||||
|
||||
class SecureListenSocket : public TCPListenSocket {
|
||||
public:
|
||||
SecureListenSocket(IEventQueue* events,
|
||||
SocketMultiplexer* socketMultiplexer,
|
||||
IArchNetwork::EAddressFamily family);
|
||||
SecureListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer,
|
||||
IArchNetwork::EAddressFamily family,
|
||||
ConnectionSecurityLevel security_level);
|
||||
|
||||
// IListenSocket overrides
|
||||
virtual IDataSocket*
|
||||
accept();
|
||||
private:
|
||||
ConnectionSecurityLevel security_level_;
|
||||
};
|
||||
|
@ -54,25 +54,24 @@ struct Ssl {
|
||||
SSL* m_ssl;
|
||||
};
|
||||
|
||||
SecureSocket::SecureSocket(
|
||||
IEventQueue* events,
|
||||
SocketMultiplexer* socketMultiplexer,
|
||||
IArchNetwork::EAddressFamily family) :
|
||||
SecureSocket::SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer,
|
||||
IArchNetwork::EAddressFamily family,
|
||||
ConnectionSecurityLevel security_level) :
|
||||
TCPSocket(events, socketMultiplexer, family),
|
||||
m_ssl(nullptr),
|
||||
m_secureReady(false),
|
||||
m_fatal(false)
|
||||
m_fatal(false),
|
||||
security_level_{security_level}
|
||||
{
|
||||
}
|
||||
|
||||
SecureSocket::SecureSocket(
|
||||
IEventQueue* events,
|
||||
SocketMultiplexer* socketMultiplexer,
|
||||
ArchSocket socket) :
|
||||
SecureSocket::SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer,
|
||||
ArchSocket socket, ConnectionSecurityLevel security_level) :
|
||||
TCPSocket(events, socketMultiplexer, socket),
|
||||
m_ssl(nullptr),
|
||||
m_secureReady(false),
|
||||
m_fatal(false)
|
||||
m_fatal(false),
|
||||
security_level_{security_level}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ConnectionSecurityLevel.h"
|
||||
#include "net/TCPSocket.h"
|
||||
#include "net/XSocket.h"
|
||||
#include "io/filesystem.h"
|
||||
@ -33,10 +34,10 @@ A secure socket using SSL.
|
||||
*/
|
||||
class SecureSocket : public TCPSocket {
|
||||
public:
|
||||
SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family);
|
||||
SecureSocket(IEventQueue* events,
|
||||
SocketMultiplexer* socketMultiplexer,
|
||||
ArchSocket socket);
|
||||
SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer,
|
||||
IArchNetwork::EAddressFamily family, ConnectionSecurityLevel security_level);
|
||||
SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer,
|
||||
ArchSocket socket, ConnectionSecurityLevel security_level);
|
||||
~SecureSocket();
|
||||
|
||||
// ISocket overrides
|
||||
@ -86,4 +87,5 @@ private:
|
||||
Ssl* m_ssl;
|
||||
bool m_secureReady;
|
||||
bool m_fatal;
|
||||
ConnectionSecurityLevel security_level_ = ConnectionSecurityLevel::ENCRYPTED;
|
||||
};
|
||||
|
@ -44,7 +44,8 @@ IDataSocket* TCPSocketFactory::create(IArchNetwork::EAddressFamily family,
|
||||
ConnectionSecurityLevel security_level) const
|
||||
{
|
||||
if (security_level != ConnectionSecurityLevel::PLAINTEXT) {
|
||||
SecureSocket* secureSocket = new SecureSocket(m_events, m_socketMultiplexer, family);
|
||||
SecureSocket* secureSocket = new SecureSocket(m_events, m_socketMultiplexer, family,
|
||||
security_level);
|
||||
secureSocket->initSsl (false);
|
||||
return secureSocket;
|
||||
}
|
||||
@ -58,7 +59,7 @@ IListenSocket* TCPSocketFactory::createListen(IArchNetwork::EAddressFamily famil
|
||||
{
|
||||
IListenSocket* socket = NULL;
|
||||
if (security_level != ConnectionSecurityLevel::PLAINTEXT) {
|
||||
socket = new SecureListenSocket(m_events, m_socketMultiplexer, family);
|
||||
socket = new SecureListenSocket(m_events, m_socketMultiplexer, family, security_level);
|
||||
}
|
||||
else {
|
||||
socket = new TCPListenSocket(m_events, m_socketMultiplexer, family);
|
||||
|
Loading…
Reference in New Issue
Block a user