4 #include <QJsonDocument>
33 , _sslCertPath(sslCertPath)
45 QSslSocket *_sslSocket =
dynamic_cast<QSslSocket *
> (
_socket);
48 QList<QSslCertificate> certs = QSslCertificate::fromPath(
_sslCertPath, QSsl::Pem);
54 QSslConfiguration sslConfiguration;
55 sslConfiguration.addCaCertificates(certs);
56 _sslSocket->setSslConfiguration(sslConfiguration);
62 connect(_sslSocket, SIGNAL(
sslErrors(QList<QSslError>)),
this, SLOT(
sslErrors(QList<QSslError>)));
65 connect(_sslSocket, SIGNAL(
modeChanged(QSslSocket::SslMode)),
this, SLOT(
modeChanged(QSslSocket::SslMode)));
68 connect(_sslSocket, SIGNAL(encrypted()),
this, SLOT(
sslReady()));
90 , _sslCertPath(sslCertPath)
104 QSslSocket *_sslSocket =
dynamic_cast<QSslSocket *
> (
_socket);
107 QList<QSslCertificate> certs = QSslCertificate::fromPath(
_sslCertPath, QSsl::Pem);
113 QSslConfiguration sslConfiguration;
114 sslConfiguration.addCaCertificates(certs);
115 _sslSocket->setSslConfiguration(sslConfiguration);
121 connect(_sslSocket, SIGNAL(
sslErrors(QList<QSslError>)),
this, SLOT(
sslErrors(QList<QSslError>)));
124 connect(_sslSocket, SIGNAL(
modeChanged(QSslSocket::SslMode)),
this, SLOT(
modeChanged(QSslSocket::SslMode)));
127 connect(_sslSocket, SIGNAL(encrypted()),
this, SLOT(
sslReady()));
148 , _initialized(false)
161 QSslSocket *_sslSocket =
dynamic_cast<QSslSocket *
> (
_socket);
164 _sslSocket->setSslConfiguration(sslConfiguration);
170 connect(_sslSocket, SIGNAL(
sslErrors(QList<QSslError>)),
this, SLOT(
sslErrors(QList<QSslError>)));
173 connect(_sslSocket, SIGNAL(
modeChanged(QSslSocket::SslMode)),
this, SLOT(
modeChanged(QSslSocket::SslMode)));
176 connect(_sslSocket, SIGNAL(encrypted()),
this, SLOT(
sslReady()));
218 connect(
_socket, SIGNAL(
error(QAbstractSocket::SocketError) ),
219 this, SIGNAL(
error(QAbstractSocket::SocketError) ) );
237 QSslSocket *_sslSocket =
dynamic_cast<QSslSocket *
> (
_socket);
238 if (!_sslSocket->isEncrypted())
242 if (!_sslSocket->waitForEncrypted(500))
245 VFS::WARN( QString(
"SSL socket is not in encrypted state. You may need to enable SSL on the remote side. Closing socket. (%1:%2)").arg(
_address).arg(
_port),0,cn);
309 if (message.length() == 0)
321 if (
_socket->bytesAvailable() > 0)
352 printf(
"about to write..\n");
353 printf(
"socket parent: %p\n",
_socket->thread());
355 printf(
"FIXME: VFS_tcp_client::write needs to be defined!");
358 printf(
"wrote...\n");
380 return QString(
"%1:%2 (%3)").arg(
_address).arg(
_port).arg(
_ssl?
"secure":
"insecure");
405 for (
int i=0;i<errors.length();i++)
VFS_node is the base class from which all other VFS_node classes derive.
static bool __isNode(VFS_node *)
Check to see if a node is in the global registry.
void mounted()
Emitted when a node is mount()ed.
void unmounted(VFS_node *self)
Emitted when a node is unmount()ed.
QString className()
Return the class name of a node.
The base class for all requests between nodes.
void error(QAbstractSocket::SocketError)
Emitted when a socket error occurs.
void connected()
Emitted when a connection has been made.
QString _address
The address resolved by peerAddress(), or the address to connect to.
MESSAGE_SIZE _messageSize
The message size received. Will wait for this many bytes before emitting messageReady.
void sslErrors(const QList< QSslError > &errors)
VFS_tcp_client::sslErrors.
void sslReady()
Signal that an SSL connnection has been established.
QTcpSocket * _socket
The socket connection.
VFS_tcp_client(QTcpSocket *socket, bool ssl=false, QSslConfiguration sslConfiguration=QSslConfiguration())
VFS_tcp_client constructor for client mode.
virtual QString reportDetails()
Report data about this client.
void readyMessage(QByteArray message)
Emitted when a message is ready for processing.
virtual bool isContainer()
DOCME.
bool _initialized
Has this node been initialized?
void peerVerifyError(const QSslError &error)
VFS_tcp_client::peerVerifyError.
virtual void init()
DOCME.
virtual void close()
DOCME.
quint16 _port
The port to connect to.
QString _sslCertPath
ssl cert file path.
virtual void write(VFS_request *r)
DOCME.
virtual void writeMessage(QByteArray data)
DOCME.
void modeChanged(QSslSocket::SslMode mode)
A slot for when the SSL mode has changed.
void disconnected()
Emitted when a connection has been lost.
void moreToRead()
Emitted when an incoming message has additional data.
virtual ~VFS_tcp_client()
static VFS * root()
Return the root node of the VFS filesystem.
static void LOG(QString message, int level=0, QString user="server")
Send a message to the VFS::_messages VFS_stream.
static void ERROR(QString message, int level=0, QString user="server")
Send a message to the VFS::_errors VFS_stream.
static void WARN(QString message, int level=0, QString user="server")
Send a message to the VFS::_warnings VFS_stream.