Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -64,7 +64,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
myConfigState = OK;
|
myConfigState = OK;
|
||||||
|
|
||||||
// !!!! Revisionsnummer der Configdefaults !!!!!
|
// !!!! Revisionsnummer der Configdefaults !!!!!
|
||||||
configRev = 101;
|
configRev = 102;
|
||||||
|
|
||||||
//standard defaults
|
//standard defaults
|
||||||
logOnOffDefault = "1";
|
logOnOffDefault = "1";
|
||||||
@@ -223,6 +223,8 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
configList.push_back(ConfigInfo("ServerUseWebSocket", CONFIG_TYPE_INT, "0"));
|
configList.push_back(ConfigInfo("ServerUseWebSocket", CONFIG_TYPE_INT, "0"));
|
||||||
configList.push_back(ConfigInfo("ServerPort", CONFIG_TYPE_INT, "7234"));
|
configList.push_back(ConfigInfo("ServerPort", CONFIG_TYPE_INT, "7234"));
|
||||||
configList.push_back(ConfigInfo("ServerWebSocketPort", CONFIG_TYPE_INT, "7233"));
|
configList.push_back(ConfigInfo("ServerWebSocketPort", CONFIG_TYPE_INT, "7233"));
|
||||||
|
configList.push_back(ConfigInfo("ServerWebSocketResource", CONFIG_TYPE_STRING, ""));
|
||||||
|
configList.push_back(ConfigInfo("ServerWebSocketOrigin", CONFIG_TYPE_STRING, ""));
|
||||||
configList.push_back(ConfigInfo("ServerUsePutAvatars", CONFIG_TYPE_INT, "0"));
|
configList.push_back(ConfigInfo("ServerUsePutAvatars", CONFIG_TYPE_INT, "0"));
|
||||||
configList.push_back(ConfigInfo("ServerPutAvatarsAddress", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("ServerPutAvatarsAddress", CONFIG_TYPE_STRING, ""));
|
||||||
configList.push_back(ConfigInfo("ServerPutAvatarsUser", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("ServerPutAvatarsUser", CONFIG_TYPE_STRING, ""));
|
||||||
|
|||||||
@@ -36,8 +36,10 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ServerAcceptWebHelper::ServerAcceptWebHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService)
|
ServerAcceptWebHelper::ServerAcceptWebHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService,
|
||||||
: m_ioService(ioService), m_serverCallback(serverCallback)
|
const string &webSocketResource, const string &webSocketOrigin)
|
||||||
|
: m_ioService(ioService), m_serverCallback(serverCallback),
|
||||||
|
m_webSocketResource(webSocketResource), m_webSocketOrigin(webSocketOrigin)
|
||||||
{
|
{
|
||||||
m_webSocketServer.reset(new server);
|
m_webSocketServer.reset(new server);
|
||||||
}
|
}
|
||||||
@@ -71,9 +73,15 @@ ServerAcceptWebHelper::Close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ServerAcceptWebHelper::validate(websocketpp::connection_hdl /*hdl*/)
|
ServerAcceptWebHelper::validate(websocketpp::connection_hdl hdl)
|
||||||
{
|
{
|
||||||
return true;
|
bool retVal = false;
|
||||||
|
server::connection_ptr con = m_webSocketServer->get_con_from_hdl(hdl);
|
||||||
|
if ((m_webSocketResource.empty() || con->get_resource() == m_webSocketResource)
|
||||||
|
&& (m_webSocketOrigin.empty() || (con->get_origin() != "null" && con->get_origin() == m_webSocketOrigin))) {
|
||||||
|
retVal = true;
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -348,6 +348,9 @@ ServerLobbyThread::ReAddSession(boost::shared_ptr<SessionData> session, int reas
|
|||||||
case NTF_NET_REMOVED_START_FAILED :
|
case NTF_NET_REMOVED_START_FAILED :
|
||||||
removed->set_removedfromgamereason(RemovedFromGameMessage::removedStartFailed);
|
removed->set_removedfromgamereason(RemovedFromGameMessage::removedStartFailed);
|
||||||
break;
|
break;
|
||||||
|
case NTF_NET_REMOVED_GAME_CLOSED :
|
||||||
|
removed->set_removedfromgamereason(RemovedFromGameMessage::gameClosed);
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
removed->set_removedfromgamereason(RemovedFromGameMessage::removedOnRequest);
|
removed->set_removedfromgamereason(RemovedFromGameMessage::removedOnRequest);
|
||||||
break;
|
break;
|
||||||
@@ -1835,8 +1838,10 @@ ServerLobbyThread::TimerRemoveGame(const boost::system::error_code &ec)
|
|||||||
++next;
|
++next;
|
||||||
boost::shared_ptr<ServerGame> tmpGame = i->second;
|
boost::shared_ptr<ServerGame> tmpGame = i->second;
|
||||||
if (!tmpGame->GetSessionManager().HasSessionWithState(SessionData::Game))
|
if (!tmpGame->GetSessionManager().HasSessionWithState(SessionData::Game))
|
||||||
|
{
|
||||||
tmpGame->MoveSpectatorsToLobby();
|
tmpGame->MoveSpectatorsToLobby();
|
||||||
InternalRemoveGame(tmpGame); // This will delete the game.
|
InternalRemoveGame(tmpGame); // This will delete the game.
|
||||||
|
}
|
||||||
i = next;
|
i = next;
|
||||||
}
|
}
|
||||||
// Restart timer
|
// Restart timer
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ ServerManager::~ServerManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerManager::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const string &logDir)
|
ServerManager::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const string &logDir,
|
||||||
|
const string &webSocketResource, const string &webSocketOrigin)
|
||||||
{
|
{
|
||||||
GetLobbyThread().Init(logDir);
|
GetLobbyThread().Init(logDir);
|
||||||
|
|
||||||
@@ -95,7 +96,8 @@ ServerManager::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int
|
|||||||
}*/
|
}*/
|
||||||
if (proto & TRANSPORT_PROTOCOL_WEBSOCKET)
|
if (proto & TRANSPORT_PROTOCOL_WEBSOCKET)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<ServerAcceptInterface> webAcceptHelper(new ServerAcceptWebHelper(GetGui(), m_ioService));
|
boost::shared_ptr<ServerAcceptInterface> webAcceptHelper(
|
||||||
|
new ServerAcceptWebHelper(GetGui(), m_ioService, webSocketResource, webSocketOrigin));
|
||||||
webAcceptHelper->Listen(websocketPort, ipv6, logDir, m_lobbyThread);
|
webAcceptHelper->Listen(websocketPort, ipv6, logDir, m_lobbyThread);
|
||||||
m_acceptHelperPool.push_back(webAcceptHelper);
|
m_acceptHelperPool.push_back(webAcceptHelper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ ServerManagerIrc::~ServerManagerIrc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerManagerIrc::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const string &logDir)
|
ServerManagerIrc::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const string &logDir,
|
||||||
|
const std::string &webSocketResource, const std::string &webSocketOrigin)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<IrcThread> tmpIrcAdminThread;
|
boost::shared_ptr<IrcThread> tmpIrcAdminThread;
|
||||||
boost::shared_ptr<IrcThread> tmpIrcLobbyThread;
|
boost::shared_ptr<IrcThread> tmpIrcLobbyThread;
|
||||||
@@ -83,7 +84,7 @@ ServerManagerIrc::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, i
|
|||||||
|
|
||||||
m_adminBot->Init(m_lobbyThread, tmpIrcAdminThread, myConfig.readConfigString("CacheDir"));
|
m_adminBot->Init(m_lobbyThread, tmpIrcAdminThread, myConfig.readConfigString("CacheDir"));
|
||||||
m_lobbyBot->Init(m_lobbyThread, tmpIrcLobbyThread);
|
m_lobbyBot->Init(m_lobbyThread, tmpIrcLobbyThread);
|
||||||
ServerManager::Init(serverPort, websocketPort, ipv6, proto, logDir);
|
ServerManager::Init(serverPort, websocketPort, ipv6, proto, logDir, webSocketResource, webSocketOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -40,7 +40,8 @@
|
|||||||
class ServerAcceptWebHelper : public ServerAcceptInterface
|
class ServerAcceptWebHelper : public ServerAcceptInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerAcceptWebHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService);
|
ServerAcceptWebHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService,
|
||||||
|
const std::string &webSocketResource, const std::string &webSocketOrigin);
|
||||||
|
|
||||||
virtual void Listen(unsigned serverPort, bool ipv6, const std::string &logDir,
|
virtual void Listen(unsigned serverPort, bool ipv6, const std::string &logDir,
|
||||||
boost::shared_ptr<ServerLobbyThread> lobbyThread);
|
boost::shared_ptr<ServerLobbyThread> lobbyThread);
|
||||||
@@ -61,6 +62,8 @@ private:
|
|||||||
ServerCallback &m_serverCallback;
|
ServerCallback &m_serverCallback;
|
||||||
boost::shared_ptr<server> m_webSocketServer;
|
boost::shared_ptr<server> m_webSocketServer;
|
||||||
SessionMap m_sessionMap;
|
SessionMap m_sessionMap;
|
||||||
|
std::string m_webSocketResource;
|
||||||
|
std::string m_webSocketOrigin;
|
||||||
|
|
||||||
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
|
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ public:
|
|||||||
virtual ~ServerManager();
|
virtual ~ServerManager();
|
||||||
|
|
||||||
// Set the parameters.
|
// Set the parameters.
|
||||||
virtual void Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const std::string &logDir);
|
virtual void Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const std::string &logDir,
|
||||||
|
const std::string &webSocketResource, const std::string &webSocketOrigin);
|
||||||
|
|
||||||
// Main start function.
|
// Main start function.
|
||||||
virtual void RunAll();
|
virtual void RunAll();
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ public:
|
|||||||
virtual ~ServerManagerIrc();
|
virtual ~ServerManagerIrc();
|
||||||
|
|
||||||
// Set the parameters.
|
// Set the parameters.
|
||||||
virtual void Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const std::string &logDir);
|
virtual void Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const std::string &logDir,
|
||||||
|
const std::string &webSocketResource, const std::string &webSocketOrigin);
|
||||||
|
|
||||||
// Main start function.
|
// Main start function.
|
||||||
virtual void RunAll();
|
virtual void RunAll();
|
||||||
|
|||||||
+3
-1
@@ -342,7 +342,9 @@ void Session::startNetworkServer(bool dedicated)
|
|||||||
myConfig->readConfigInt("ServerWebSocketPort"),
|
myConfig->readConfigInt("ServerWebSocketPort"),
|
||||||
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
||||||
protocol,
|
protocol,
|
||||||
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir"))
|
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")),
|
||||||
|
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("ServerWebSocketResource")),
|
||||||
|
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("ServerWebSocketOrigin"))
|
||||||
);
|
);
|
||||||
|
|
||||||
myNetServer->RunAll();
|
myNetServer->RunAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user