mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-03-22 00:45:10 +00:00
NOTE: There is a special API/event for the bridge to announce which server/client connections are available (clients will see only servers, and vice versa)
The syntax for this event is:
{
"namespace":"events",
"name":"bridge",
"id":"",
"args":{
"available_connections":["ID1","ID2", etc..]
}
}
Note that the available_connections are *all* the connections available at that time (it is not a difference from a previous state), so there may be both new ID's in the list and ID's which are no longer listed.
This event will get sent out any time a new connection/disconnection is made from the bridge which impacts the current connection (so a client will only get the event when a server connects/disconnects and vice versa).
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
// ===============================
|
|
// PC-BSD SysAdm Bridge Server
|
|
// Available under the 3-clause BSD License
|
|
// Written by: Ken Moore <ken@pcbsd.org> May 2016
|
|
// =================================
|
|
#ifndef _PCBSD_SYSADM_BRIDGE_SERVER_H
|
|
#define _PCBSD_SYSADM_BRIDGE_SERVER_H
|
|
|
|
#include "globals.h"
|
|
|
|
#include "BridgeConnection.h"
|
|
|
|
class BridgeServer : public QWebSocketServer{
|
|
Q_OBJECT
|
|
public:
|
|
BridgeServer();
|
|
~BridgeServer();
|
|
|
|
bool startServer(quint16 port);
|
|
|
|
public slots:
|
|
void sendMessage(QString toID, QString msg);
|
|
|
|
private:
|
|
QList<BridgeConnection*> OpenSockets;
|
|
|
|
//Server Setup functions
|
|
bool setupWebSocket(quint16 port);
|
|
|
|
//Server Blacklist / DDOS mitigator
|
|
bool allowConnection(QHostAddress addr);
|
|
|
|
//Generic functions for either type of server
|
|
QString generateID(QString name); //generate a new ID for a socket
|
|
|
|
private slots:
|
|
// Generic Server Slots
|
|
void NewSocketConnection(); //newConnection() signal
|
|
void NewConnectError(QAbstractSocket::SocketError); //acceptError() signal
|
|
//Socket Blacklist function
|
|
void BlackListConnection(QHostAddress addr);
|
|
|
|
//Server signals/slots
|
|
void ServerClosed(); //closed() signal
|
|
void ServerError(QWebSocketProtocol::CloseCode); //serverError() signal
|
|
void ConnectError(QAbstractSocket::SocketError);
|
|
// - SSL/Authentication Signals
|
|
void OriginAuthRequired(QWebSocketCorsAuthenticator*); //originAuthenticationRequired() signal
|
|
void PeerVerifyError(const QSslError&); //peerVerifyError() signal
|
|
void SslErrors(const QList<QSslError>&); //sslErrors() signal
|
|
void SocketClosed(QString ID);
|
|
// Connection Keys Changed
|
|
void announceKeyChange(QString ID, bool isServer, QStringList keys);
|
|
|
|
signals:
|
|
void ForwardMessage(QString, QString); //toID, msg
|
|
|
|
};
|
|
|
|
#endif
|