mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 12:54:01 +02:00
- added ftp port # as an ini setting and added to UPNP for router auto-config
- added new language string for message box to prompt map file downloads
This commit is contained in:
@@ -53,10 +53,11 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
|
||||
return fwrite(buffer, size, nmemb, out->stream);
|
||||
}
|
||||
|
||||
FTPClientThread::FTPClientThread(string serverUrl, std::pair<string,string> mapsPath, FTPClientCallbackInterface *pCBObject) : BaseThread() {
|
||||
this->serverUrl = serverUrl;
|
||||
this->mapsPath = mapsPath;
|
||||
this->pCBObject = pCBObject;
|
||||
FTPClientThread::FTPClientThread(int portNumber, string serverUrl, std::pair<string,string> mapsPath, FTPClientCallbackInterface *pCBObject) : BaseThread() {
|
||||
this->portNumber = portNumber;
|
||||
this->serverUrl = serverUrl;
|
||||
this->mapsPath = mapsPath;
|
||||
this->pCBObject = pCBObject;
|
||||
}
|
||||
|
||||
void FTPClientThread::signalQuit() {
|
||||
@@ -107,7 +108,7 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
|
||||
ftpfile.stream = NULL;
|
||||
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"ftp://maps:mg_ftp_server@%s/%s%s",serverUrl.c_str(),mapFileName.c_str(),destFileExt.c_str());
|
||||
sprintf(szBuf,"ftp://maps:mg_ftp_server@%s:%d/%s%s",serverUrl.c_str(),portNumber, mapFileName.c_str(),destFileExt.c_str());
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL,szBuf);
|
||||
/* Define our callback to get called when there's data to be written */
|
||||
@@ -129,7 +130,7 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
|
||||
|
||||
ftpfile.stream = NULL;
|
||||
|
||||
sprintf(szBuf,"ftp://maps_custom:mg_ftp_server@%s/%s%s",serverUrl.c_str(),mapFileName.c_str(),destFileExt.c_str());
|
||||
sprintf(szBuf,"ftp://maps_custom:mg_ftp_server@%s:%d/%s%s",serverUrl.c_str(),portNumber,mapFileName.c_str(),destFileExt.c_str());
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL,szBuf);
|
||||
/* Define our callback to get called when there's data to be written */
|
||||
|
@@ -25,8 +25,9 @@ using namespace Shared::PlatformCommon;
|
||||
|
||||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
FTPServerThread::FTPServerThread(std::pair<string,string> mapsPath) : BaseThread() {
|
||||
FTPServerThread::FTPServerThread(std::pair<string,string> mapsPath,int portNumber) : BaseThread() {
|
||||
this->mapsPath = mapsPath;
|
||||
this->portNumber = portNumber;
|
||||
}
|
||||
|
||||
void FTPServerThread::signalQuit() {
|
||||
@@ -73,7 +74,7 @@ void FTPServerThread::execute() {
|
||||
ftpCreateAccount("lister", "", "./", FTP_ACC_LS);
|
||||
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
*/
|
||||
ftpStart();
|
||||
ftpStart(portNumber);
|
||||
while(this->getQuitStatus() == false) {
|
||||
ftpExecute();
|
||||
sleep(25);
|
||||
|
@@ -62,7 +62,8 @@ using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
int Socket::broadcast_portno = 61357;
|
||||
int Socket::broadcast_portno = 61357;
|
||||
int ServerSocket::ftpServerPort = 61358;
|
||||
BroadCastClientSocketThread *ClientSocket::broadCastClientThread = NULL;
|
||||
|
||||
//
|
||||
@@ -1656,6 +1657,7 @@ ServerSocket::~ServerSocket() {
|
||||
|
||||
stopBroadCastThread();
|
||||
NETremRedirects(ServerSocket::externalPort);
|
||||
NETremRedirects(ServerSocket::ftpServerPort);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
@@ -1835,7 +1837,7 @@ int ServerSocket::upnp_init(void *param) {
|
||||
//int *externalPort = (int *)asdf;
|
||||
ServerSocket *srv = (ServerSocket *)param;
|
||||
|
||||
int ports[2] = { externalPort, srv->getBindPort() };
|
||||
int ports[4] = { externalPort, srv->getBindPort(), ftpServerPort, ftpServerPort };
|
||||
|
||||
memset(&urls, 0, sizeof(struct UPNPUrls));
|
||||
memset(&data, 0, sizeof(struct IGDdatas));
|
||||
@@ -1900,13 +1902,13 @@ int ServerSocket::upnp_init(void *param) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ServerSocket::upnp_add_redirect(int ports[2]) {
|
||||
bool ServerSocket::upnp_add_redirect(int ports[4]) {
|
||||
char externalIP[16]="";
|
||||
char ext_port_str[16]="";
|
||||
char int_port_str[16]="";
|
||||
int r=0;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"upnp_add_redir(%d : %d)\n", ports[0],ports[1]);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"upnp_add_redir(%d : %d) (%d : %d)\n", ports[0],ports[1],ports[2],ports[3]);
|
||||
|
||||
UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP);
|
||||
|
||||
@@ -1920,6 +1922,18 @@ bool ServerSocket::upnp_add_redirect(int ports[2]) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"AddPortMapping(%s, %s, %s) failed\n", ext_port_str, int_port_str, lanaddr);
|
||||
return false;
|
||||
}
|
||||
|
||||
sprintf(ext_port_str, "%d", ports[2]);
|
||||
sprintf(int_port_str, "%d", ports[3]);
|
||||
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,
|
||||
ext_port_str, int_port_str, lanaddr, "MegaGlest (FTP) - www.megaglest.org", "TCP", 0);
|
||||
|
||||
if (r != UPNPCOMMAND_SUCCESS) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"AddPortMapping(%s, %s, %s) failed\n", ext_port_str, int_port_str, lanaddr);
|
||||
//return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -1931,7 +1945,7 @@ void ServerSocket::upnp_rem_redirect(int ext_port) {
|
||||
UPNP_DeletePortMapping(urls.controlURL, data.servicetype, ext_port_str, "TCP", 0);
|
||||
}
|
||||
|
||||
void ServerSocket::NETaddRedirects(int ports[2]) {
|
||||
void ServerSocket::NETaddRedirects(int ports[4]) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork, "%s\n", __FUNCTION__);
|
||||
//if (!upnp_done)
|
||||
//{
|
||||
|
Reference in New Issue
Block a user