mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
WebSocketServer: Include password in changed GetConnectString()
New format is `obswebsocket|ip:port|password`
This commit is contained in:
parent
4028d42931
commit
ba710efe09
@ -79,6 +79,7 @@ void WebSocketServer::Start()
|
||||
}
|
||||
|
||||
_serverPort = conf->ServerPort;
|
||||
_serverPassword = conf->ServerPassword;
|
||||
_debugEnabled = conf->DebugEnabled;
|
||||
_authenticationRequired = conf->AuthRequired;
|
||||
_authenticationSalt = Utils::Crypto::GenerateSalt();
|
||||
@ -187,10 +188,14 @@ std::vector<WebSocketServer::WebSocketSessionState> WebSocketServer::GetWebSocke
|
||||
return webSocketSessions;
|
||||
}
|
||||
|
||||
std::string WebSocketServer::GetConnectUrl()
|
||||
QString WebSocketServer::GetConnectString()
|
||||
{
|
||||
QString ret = QString("ws://%1:%2").arg(QString::fromStdString(Utils::Platform::GetLocalAddress())).arg(_serverPort);
|
||||
return ret.toStdString();
|
||||
QString ret;
|
||||
if (_authenticationRequired)
|
||||
ret = QString("obswebsocket|%1:%2|%3").arg(QString::fromStdString(Utils::Platform::GetLocalAddress())).arg(_serverPort).arg(_serverPassword);
|
||||
else
|
||||
ret = QString("obswebsocket|%1:%2").arg(QString::fromStdString(Utils::Platform::GetLocalAddress())).arg(_serverPort);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData)
|
||||
@ -207,6 +212,7 @@ void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventT
|
||||
std::string messageJson;
|
||||
std::string messageMsgPack;
|
||||
|
||||
// Recurse connected sessions and send the event to suitable sessions.
|
||||
std::unique_lock<std::mutex> lock(_sessionMutex);
|
||||
for (auto & it : _sessions) {
|
||||
if (!it.second.IsIdentified())
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QThreadPool>
|
||||
#include <QString>
|
||||
#include <mutex>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
@ -71,7 +72,7 @@ class WebSocketServer : QObject
|
||||
return &_threadPool;
|
||||
}
|
||||
|
||||
std::string GetConnectUrl();
|
||||
QString GetConnectString();
|
||||
|
||||
public Q_SLOTS:
|
||||
void BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData = nullptr);
|
||||
@ -94,6 +95,7 @@ class WebSocketServer : QObject
|
||||
std::mutex _sessionMutex;
|
||||
std::map<websocketpp::connection_hdl, WebSocketSession, std::owner_less<websocketpp::connection_hdl>> _sessions;
|
||||
uint16_t _serverPort;
|
||||
QString _serverPassword;
|
||||
bool _debugEnabled;
|
||||
bool _authenticationRequired;
|
||||
std::string _authenticationSecret;
|
||||
|
Loading…
Reference in New Issue
Block a user