- added option to disable file transfers for tileset and/or techtrees for published (internet) games
This commit is contained in:
parent
e070cf2cbb
commit
9eb1f60048
|
@ -87,7 +87,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
|
|
||||||
serverInitError = false;
|
serverInitError = false;
|
||||||
try {
|
try {
|
||||||
networkManager.init(nrServer);
|
networkManager.init(nrServer,openNetworkSlots);
|
||||||
}
|
}
|
||||||
catch(const std::exception &ex) {
|
catch(const std::exception &ex) {
|
||||||
serverInitError = true;
|
serverInitError = true;
|
||||||
|
@ -95,7 +95,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
||||||
//throw runtime_error(szBuf);!!!
|
//throw runtime_error(szBuf);
|
||||||
showGeneralError=true;
|
showGeneralError=true;
|
||||||
generalErrorToShow = ex.what();
|
generalErrorToShow = ex.what();
|
||||||
|
|
||||||
|
@ -314,10 +314,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
listBoxPublishServer.init(50, networkPos, 100);
|
listBoxPublishServer.init(50, networkPos, 100);
|
||||||
listBoxPublishServer.pushBackItem(lang.get("Yes"));
|
listBoxPublishServer.pushBackItem(lang.get("Yes"));
|
||||||
listBoxPublishServer.pushBackItem(lang.get("No"));
|
listBoxPublishServer.pushBackItem(lang.get("No"));
|
||||||
if(openNetworkSlots)
|
if(openNetworkSlots) {
|
||||||
listBoxPublishServer.setSelectedItemIndex(0);
|
listBoxPublishServer.setSelectedItemIndex(0);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Network Frame Period
|
// Network Frame Period
|
||||||
//labelNetworkFramePeriod.registerGraphicComponent(containerName,"labelNetworkFramePeriod");
|
//labelNetworkFramePeriod.registerGraphicComponent(containerName,"labelNetworkFramePeriod");
|
||||||
|
@ -792,6 +794,9 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
|
|
||||||
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
||||||
}
|
}
|
||||||
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){
|
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
@ -1445,6 +1450,9 @@ void MenuStateCustomGame::update() {
|
||||||
showMessageBox( masterServererErrorToShow, lang.get("ErrorFromMasterserver"), false);
|
showMessageBox( masterServererErrorToShow, lang.get("ErrorFromMasterserver"), false);
|
||||||
|
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
|
|
||||||
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
||||||
}
|
}
|
||||||
else if(showGeneralError) {
|
else if(showGeneralError) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -1734,6 +1742,9 @@ void MenuStateCustomGame::update() {
|
||||||
{
|
{
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
listBoxPublishServer.setEditable(false);
|
listBoxPublishServer.setEditable(false);
|
||||||
|
|
||||||
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
||||||
//listBoxEnableServerControlledAI.setEditable(false);
|
//listBoxEnableServerControlledAI.setEditable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -376,6 +376,28 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
labelFTPServerDataPorts.init(currentColumnStart,currentLine );
|
labelFTPServerDataPorts.init(currentColumnStart,currentLine );
|
||||||
labelFTPServerDataPorts.setText(szBuf);
|
labelFTPServerDataPorts.setText(szBuf);
|
||||||
currentLine-=30;
|
currentLine-=30;
|
||||||
|
|
||||||
|
labelEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTilesetXfer");
|
||||||
|
labelEnableFTPServerInternetTilesetXfer.init(currentLabelStart ,currentLine );
|
||||||
|
labelEnableFTPServerInternetTilesetXfer.setText(lang.get("EnableFTPServerInternetTilesetXfer"));
|
||||||
|
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTilesetXfer");
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.setValue(config.getBool("EnableFTPServerInternetTilesetXfer","true"));
|
||||||
|
|
||||||
|
currentLine-=30;
|
||||||
|
|
||||||
|
labelEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTechtreeXfer");
|
||||||
|
labelEnableFTPServerInternetTechtreeXfer.init(currentLabelStart ,currentLine );
|
||||||
|
labelEnableFTPServerInternetTechtreeXfer.setText(lang.get("EnableFTPServerInternetTechtreeXfer"));
|
||||||
|
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTechtreeXfer");
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.setValue(config.getBool("EnableFTPServerInternetTechtreeXfer","true"));
|
||||||
|
|
||||||
|
currentLine-=30;
|
||||||
|
|
||||||
|
|
||||||
// FTP config end
|
// FTP config end
|
||||||
|
|
||||||
// Privacy flag
|
// Privacy flag
|
||||||
|
@ -546,6 +568,9 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
checkBoxEnableFTP.mouseClick(x, y);
|
checkBoxEnableFTP.mouseClick(x, y);
|
||||||
checkBoxEnableFTPServer.mouseClick(x, y);
|
checkBoxEnableFTPServer.mouseClick(x, y);
|
||||||
|
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.mouseClick(x, y);
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.mouseClick(x, y);
|
||||||
|
|
||||||
checkBoxEnablePrivacy.mouseClick(x, y);
|
checkBoxEnablePrivacy.mouseClick(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -580,6 +605,9 @@ void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){
|
||||||
checkBoxEnableFTP.mouseMove(x, y);
|
checkBoxEnableFTP.mouseMove(x, y);
|
||||||
checkBoxEnableFTPServer.mouseMove(x, y);
|
checkBoxEnableFTPServer.mouseMove(x, y);
|
||||||
|
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.mouseMove(x, y);
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.mouseMove(x, y);
|
||||||
|
|
||||||
checkBoxEnablePrivacy.mouseMove(x, y);
|
checkBoxEnablePrivacy.mouseMove(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,6 +720,11 @@ void MenuStateOptions::render(){
|
||||||
renderer.renderLabel(&labelFTPServerDataPortsLabel);
|
renderer.renderLabel(&labelFTPServerDataPortsLabel);
|
||||||
renderer.renderLabel(&labelFTPServerDataPorts);
|
renderer.renderLabel(&labelFTPServerDataPorts);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelEnableFTPServerInternetTilesetXfer);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnableFTPServerInternetTilesetXfer);
|
||||||
|
renderer.renderLabel(&labelEnableFTPServerInternetTechtreeXfer);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnableFTPServerInternetTechtreeXfer);
|
||||||
|
|
||||||
renderer.renderLabel(&labelEnablePrivacy);
|
renderer.renderLabel(&labelEnablePrivacy);
|
||||||
renderer.renderCheckBox(&checkBoxEnablePrivacy);
|
renderer.renderCheckBox(&checkBoxEnablePrivacy);
|
||||||
}
|
}
|
||||||
|
@ -732,6 +765,10 @@ void MenuStateOptions::saveConfig(){
|
||||||
config.setInt("FTPServerPort",config.getInt("MasterServerExternalPort")+1);
|
config.setInt("FTPServerPort",config.getInt("MasterServerExternalPort")+1);
|
||||||
config.setBool("EnableFTPXfer", checkBoxEnableFTP.getValue());
|
config.setBool("EnableFTPXfer", checkBoxEnableFTP.getValue());
|
||||||
config.setBool("EnableFTPServer", checkBoxEnableFTPServer.getValue());
|
config.setBool("EnableFTPServer", checkBoxEnableFTPServer.getValue());
|
||||||
|
|
||||||
|
config.setBool("EnableFTPServerInternetTilesetXfer", checkBoxEnableFTPServerInternetTilesetXfer.getValue());
|
||||||
|
config.setBool("EnableFTPServerInternetTechtreeXfer", checkBoxEnableFTPServerInternetTechtreeXfer.getValue());
|
||||||
|
|
||||||
config.setBool("PrivacyPlease", checkBoxEnablePrivacy.getValue());
|
config.setBool("PrivacyPlease", checkBoxEnablePrivacy.getValue());
|
||||||
|
|
||||||
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight");
|
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight");
|
||||||
|
|
|
@ -96,6 +96,12 @@ private:
|
||||||
GraphicLabel labelFTPServerDataPortsLabel;
|
GraphicLabel labelFTPServerDataPortsLabel;
|
||||||
GraphicLabel labelFTPServerDataPorts;
|
GraphicLabel labelFTPServerDataPorts;
|
||||||
|
|
||||||
|
GraphicLabel labelEnableFTPServerInternetTilesetXfer;
|
||||||
|
GraphicCheckBox checkBoxEnableFTPServerInternetTilesetXfer;
|
||||||
|
|
||||||
|
GraphicLabel labelEnableFTPServerInternetTechtreeXfer;
|
||||||
|
GraphicCheckBox checkBoxEnableFTPServerInternetTechtreeXfer;
|
||||||
|
|
||||||
GraphicLabel labelEnablePrivacy;
|
GraphicLabel labelEnablePrivacy;
|
||||||
GraphicCheckBox checkBoxEnablePrivacy;
|
GraphicCheckBox checkBoxEnablePrivacy;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ NetworkManager::NetworkManager() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::init(NetworkRole networkRole) {
|
void NetworkManager::init(NetworkRole networkRole, bool publishEnabled) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
||||||
|
|
||||||
assert(gameNetworkInterface==NULL);
|
assert(gameNetworkInterface==NULL);
|
||||||
|
@ -44,7 +44,7 @@ void NetworkManager::init(NetworkRole networkRole) {
|
||||||
|
|
||||||
if(networkRole == nrServer) {
|
if(networkRole == nrServer) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
||||||
gameNetworkInterface = new ServerInterface();
|
gameNetworkInterface = new ServerInterface(publishEnabled);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
static NetworkManager &getInstance();
|
static NetworkManager &getInstance();
|
||||||
|
|
||||||
NetworkManager();
|
NetworkManager();
|
||||||
void init(NetworkRole networkRole);
|
void init(NetworkRole networkRole,bool publishEnabled=false);
|
||||||
void end();
|
void end();
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ double MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE = 2;
|
||||||
const int MAX_SLOT_THREAD_WAIT_TIME = 3;
|
const int MAX_SLOT_THREAD_WAIT_TIME = 3;
|
||||||
const int MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS = 30;
|
const int MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS = 30;
|
||||||
|
|
||||||
ServerInterface::ServerInterface() :GameNetworkInterface() {
|
ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
nextEventId = 1;
|
nextEventId = 1;
|
||||||
|
@ -105,13 +105,25 @@ ServerInterface::ServerInterface() :GameNetworkInterface() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
int portNumber = Config::getInstance().getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
|
int portNumber = Config::getInstance().getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
|
||||||
ServerSocket::setFTPServerPort(portNumber);
|
ServerSocket::setFTPServerPort(portNumber);
|
||||||
|
|
||||||
|
bool allowInternetTilesetFileTransfers = Config::getInstance().getBool("EnableFTPServerInternetTilesetXfer","true");
|
||||||
|
bool allowInternetTechtreeFileTransfers = Config::getInstance().getBool("EnableFTPServerInternetTechtreeXfer","true");
|
||||||
|
|
||||||
ftpServer = new FTPServerThread(mapsPath,tilesetsPath,techtreesPath,
|
ftpServer = new FTPServerThread(mapsPath,tilesetsPath,techtreesPath,
|
||||||
portNumber,GameConstants::maxPlayers,this);
|
publishEnabled,
|
||||||
|
allowInternetTilesetFileTransfers, allowInternetTechtreeFileTransfers,
|
||||||
|
portNumber,GameConstants::maxPlayers,this);
|
||||||
ftpServer->start();
|
ftpServer->start();
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerInterface::setPublishEnabled(bool value) {
|
||||||
|
if(ftpServer != NULL) {
|
||||||
|
ftpServer->setInternetEnabled(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServerInterface::~ServerInterface() {
|
ServerInterface::~ServerInterface() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
exitServer = true;
|
exitServer = true;
|
||||||
|
|
|
@ -74,7 +74,7 @@ private:
|
||||||
bool inBroadcastMessage;
|
bool inBroadcastMessage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerInterface();
|
ServerInterface(bool publishEnabled);
|
||||||
virtual ~ServerInterface();
|
virtual ~ServerInterface();
|
||||||
|
|
||||||
virtual Socket* getSocket() {return &serverSocket;}
|
virtual Socket* getSocket() {return &serverSocket;}
|
||||||
|
@ -157,6 +157,8 @@ public:
|
||||||
needToRepublishToMasterserver = value;
|
needToRepublishToMasterserver = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPublishEnabled(bool value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Mutex *getServerSynchAccessor() {
|
Mutex *getServerSynchAccessor() {
|
||||||
return &serverSynchAccessor;
|
return &serverSynchAccessor;
|
||||||
|
@ -165,6 +167,7 @@ public:
|
||||||
virtual void simpleTask(BaseThread *callingThread);
|
virtual void simpleTask(BaseThread *callingThread);
|
||||||
void addClientToServerIPAddress(uint32 clientIp, uint32 ServerIp);
|
void addClientToServerIPAddress(uint32 clientIp, uint32 ServerIp);
|
||||||
virtual int isValidClientType(uint32 clientIp);
|
virtual int isValidClientType(uint32 clientIp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void broadcastMessage(const NetworkMessage *networkMessage, int excludeSlot = -1, int lockedSlotIndex = -1);
|
void broadcastMessage(const NetworkMessage *networkMessage, int excludeSlot = -1, int lockedSlotIndex = -1);
|
||||||
void broadcastMessageToConnectedClients(const NetworkMessage *networkMessage, int excludeSlot = -1);
|
void broadcastMessageToConnectedClients(const NetworkMessage *networkMessage, int excludeSlot = -1);
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
||||||
|
|
||||||
void ftpInit(ftpFindExternalFTPServerIpType cb1, ftpAddUPNPPortForwardType cb2, ftpRemoveUPNPPortForwardType cb3, ftpIsValidClientType cb4);
|
void ftpInit(ftpFindExternalFTPServerIpType cb1, ftpAddUPNPPortForwardType cb2, ftpRemoveUPNPPortForwardType cb3, ftpIsValidClientType cb4);
|
||||||
int ftpCreateAccount(const char* name, const char* passw, const char* root, int accRights);
|
int ftpCreateAccount(const char* name, const char* passw, const char* root, int accRights);
|
||||||
|
int ftpDeleteAccount(const char* name);
|
||||||
int ftpStart(int portNumber);
|
int ftpStart(int portNumber);
|
||||||
int ftpShutdown(void);
|
int ftpShutdown(void);
|
||||||
int ftpExecute(void);
|
int ftpExecute(void);
|
||||||
|
|
|
@ -39,16 +39,23 @@ protected:
|
||||||
int maxPlayers;
|
int maxPlayers;
|
||||||
static FTPClientValidationInterface *ftpValidationIntf;
|
static FTPClientValidationInterface *ftpValidationIntf;
|
||||||
|
|
||||||
|
bool internetEnabled;
|
||||||
|
bool allowInternetTilesetFileTransfers;
|
||||||
|
bool allowInternetTechtreeFileTransfers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FTPServerThread(std::pair<string,string> mapsPath,
|
FTPServerThread(std::pair<string,string> mapsPath,
|
||||||
std::pair<string,string> tilesetsPath, std::pair<string,string> techtreesPath,
|
std::pair<string,string> tilesetsPath, std::pair<string,string> techtreesPath,
|
||||||
|
bool internetEnabledFlag,
|
||||||
|
bool allowInternetTilesetFileTransfers, bool allowInternetTechtreeFileTransfers,
|
||||||
int portNumber,int maxPlayers, FTPClientValidationInterface *ftpValidationIntf);
|
int portNumber,int maxPlayers, FTPClientValidationInterface *ftpValidationIntf);
|
||||||
~FTPServerThread();
|
~FTPServerThread();
|
||||||
virtual void execute();
|
virtual void execute();
|
||||||
virtual void signalQuit();
|
virtual void signalQuit();
|
||||||
virtual bool shutdownAndWait();
|
virtual bool shutdownAndWait();
|
||||||
|
|
||||||
|
void setInternetEnabled(bool value, bool forceChange=false);
|
||||||
static void addClientToServerIPAddress(uint32 clientIp,uint32 ServerIp);
|
static void addClientToServerIPAddress(uint32 clientIp,uint32 ServerIp);
|
||||||
static FTPClientValidationInterface * getFtpValidationIntf() { return ftpValidationIntf; }
|
static FTPClientValidationInterface * getFtpValidationIntf() { return ftpValidationIntf; }
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,21 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
LOCAL ftpUserAccount_S ftpUsers[MAX_USERS];
|
LOCAL ftpUserAccount_S ftpUsers[MAX_USERS];
|
||||||
|
|
||||||
|
|
||||||
|
int ftpDeleteAccount(const char* name)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
n = ftpFindAccount(name); // check if account already exists
|
||||||
|
if(n > 0)
|
||||||
|
{
|
||||||
|
ftpUsers[n - 1].name[0] = '\0'; // delete account
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates a new user account
|
* @brief Creates a new user account
|
||||||
*
|
*
|
||||||
|
|
|
@ -48,11 +48,16 @@ int isValidClientType(ip_t clientIp) {
|
||||||
|
|
||||||
FTPServerThread::FTPServerThread(std::pair<string,string> mapsPath,
|
FTPServerThread::FTPServerThread(std::pair<string,string> mapsPath,
|
||||||
std::pair<string,string> tilesetsPath, std::pair<string,string> techtreesPath,
|
std::pair<string,string> tilesetsPath, std::pair<string,string> techtreesPath,
|
||||||
|
bool internetEnabledFlag,
|
||||||
|
bool allowInternetTilesetFileTransfers, bool allowInternetTechtreeFileTransfers,
|
||||||
int portNumber, int maxPlayers,
|
int portNumber, int maxPlayers,
|
||||||
FTPClientValidationInterface *ftpValidationIntf) : BaseThread() {
|
FTPClientValidationInterface *ftpValidationIntf) : BaseThread() {
|
||||||
this->mapsPath = mapsPath;
|
this->mapsPath = mapsPath;
|
||||||
this->tilesetsPath = tilesetsPath;
|
this->tilesetsPath = tilesetsPath;
|
||||||
this->techtreesPath = techtreesPath;
|
this->techtreesPath = techtreesPath;
|
||||||
|
setInternetEnabled(internetEnabledFlag,true);
|
||||||
|
this->allowInternetTilesetFileTransfers = allowInternetTilesetFileTransfers;
|
||||||
|
this->allowInternetTechtreeFileTransfers = allowInternetTechtreeFileTransfers;
|
||||||
this->portNumber = portNumber;
|
this->portNumber = portNumber;
|
||||||
this->maxPlayers = maxPlayers;
|
this->maxPlayers = maxPlayers;
|
||||||
this->ftpValidationIntf = ftpValidationIntf;
|
this->ftpValidationIntf = ftpValidationIntf;
|
||||||
|
@ -94,6 +99,79 @@ void FTPServerThread::addClientToServerIPAddress(uint32 clientIp,uint32 ServerIp
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Server thread clientIp = %u, ServerIp = %u\n",clientIp,ServerIp);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Server thread clientIp = %u, ServerIp = %u\n",clientIp,ServerIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FTPServerThread::setInternetEnabled(bool value, bool forceChange) {
|
||||||
|
if(forceChange == true || this->internetEnabled != value) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, changing InternetEnabled = %d\n",value);
|
||||||
|
|
||||||
|
this->internetEnabled = value;
|
||||||
|
if(this->internetEnabled == true) {
|
||||||
|
// Setup FTP Users and permissions for tilesets
|
||||||
|
if(this->allowInternetTilesetFileTransfers == true) {
|
||||||
|
if(tilesetsPath.first != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.first.c_str());
|
||||||
|
ftpCreateAccount("tilesets", "mg_ftp_server", tilesetsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
if(tilesetsPath.second != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.second.c_str());
|
||||||
|
ftpCreateAccount("tilesets_custom", "mg_ftp_server", tilesetsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users created\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ftpDeleteAccount("tilesets");
|
||||||
|
ftpDeleteAccount("tilesets_custom");
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users deleted\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->allowInternetTechtreeFileTransfers == true) {
|
||||||
|
// Setup FTP Users and permissions for tilesets
|
||||||
|
if(techtreesPath.first != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.first.c_str());
|
||||||
|
ftpCreateAccount("techtrees", "mg_ftp_server", techtreesPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
if(techtreesPath.second != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.second.c_str());
|
||||||
|
ftpCreateAccount("techtrees_custom", "mg_ftp_server", techtreesPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users created\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ftpDeleteAccount("techtrees");
|
||||||
|
ftpDeleteAccount("techtrees_custom");
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users deleted\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(tilesetsPath.first != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.first.c_str());
|
||||||
|
ftpCreateAccount("tilesets", "mg_ftp_server", tilesetsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
if(tilesetsPath.second != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.second.c_str());
|
||||||
|
ftpCreateAccount("tilesets_custom", "mg_ftp_server", tilesetsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users created\n");
|
||||||
|
|
||||||
|
// Setup FTP Users and permissions for tilesets
|
||||||
|
if(techtreesPath.first != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.first.c_str());
|
||||||
|
ftpCreateAccount("techtrees", "mg_ftp_server", techtreesPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
if(techtreesPath.second != "") {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.second.c_str());
|
||||||
|
ftpCreateAccount("techtrees_custom", "mg_ftp_server", techtreesPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users created\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FTPServerThread::execute() {
|
void FTPServerThread::execute() {
|
||||||
{
|
{
|
||||||
RunningStatusSafeWrapper runningStatus(this);
|
RunningStatusSafeWrapper runningStatus(this);
|
||||||
|
@ -119,26 +197,6 @@ void FTPServerThread::execute() {
|
||||||
ftpCreateAccount("maps_custom", "mg_ftp_server", mapsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
ftpCreateAccount("maps_custom", "mg_ftp_server", mapsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup FTP Users and permissions for tilesets
|
|
||||||
if(tilesetsPath.first != "") {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.first.c_str());
|
|
||||||
ftpCreateAccount("tilesets", "mg_ftp_server", tilesetsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
|
||||||
}
|
|
||||||
if(tilesetsPath.second != "") {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.second.c_str());
|
|
||||||
ftpCreateAccount("tilesets_custom", "mg_ftp_server", tilesetsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup FTP Users and permissions for tilesets
|
|
||||||
if(techtreesPath.first != "") {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.first.c_str());
|
|
||||||
ftpCreateAccount("techtrees", "mg_ftp_server", techtreesPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
|
||||||
}
|
|
||||||
if(techtreesPath.second != "") {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.second.c_str());
|
|
||||||
ftpCreateAccount("techtrees_custom", "mg_ftp_server", techtreesPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ftpCreateAccount("anonymous", "", "./", FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
ftpCreateAccount("anonymous", "", "./", FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
ftpCreateAccount("nothing", "", "./", 0);
|
ftpCreateAccount("nothing", "", "./", 0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user