- disallow non compressed tileset downloads when client IP not on same subnet as host

- bugfix for LAN server broadcasting
- bugfix for empty message on player disconnect (now properly shows that player switched to AI mode)
This commit is contained in:
Mark Vejvoda
2011-11-29 05:07:18 +00:00
parent 28ae161c25
commit 7cf9c189b2
13 changed files with 153 additions and 34 deletions

View File

@@ -129,6 +129,18 @@ int ftpFindAccount(const char* name)
return 0;
}
const char * ftpFindAccountById(int userid)
{
if(userid == 0) {
return 0;
}
else if(ftpUsers[userid - 1].name[0] == '\0') {
return 0;
}
return ftpUsers[userid - 1].name;
}
/**
* @brief Checks the password of a user account
*
@@ -143,12 +155,15 @@ int ftpFindAccount(const char* name)
*/
int ftpCheckPassword(int userId, const char* passw)
{
if(!userId)
if(userId == 0) {
return -1;
else if(ftpUsers[userId - 1].passw[0] == '\0')
}
else if(ftpUsers[userId - 1].passw[0] == '\0') {
return 0;
else
}
else {
return strncmp(ftpUsers[userId - 1].passw, passw, MAXLEN_PASSWORD);
}
}
/**

View File

@@ -524,6 +524,16 @@ LOCAL int ftpCmdRetr(int sessionId, const char* args, int len)
return 2;
}
if(ftpIsClientAllowedToGetFile != NULL) {
if(ftpIsClientAllowedToGetFile(ftpGetSession(sessionId)->remoteIp,ftpFindAccountById(ftpGetSession(sessionId)->userId),realPath) != 1) {
if(VERBOSE_MODE_ENABLED) printf("ERROR In ftpCmdRetr FILE DISALLOWED By MGserver [file not available] args [%s] realPath [%s]\n", args, realPath);
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg032);
return 2;
}
}
if(ftpGetSession(sessionId)->passive == FALSE)
{
s = ftpEstablishDataConnection(FALSE, &ftpGetSession(sessionId)->remoteIp, &ftpGetSession(sessionId)->remoteDataPort,sessionId);

View File

@@ -39,11 +39,14 @@ LOCAL int serverListenPort;
LOCAL int serverPassiveListenPort;
//LOCAL socket_t serverPassivePort;
void ftpInit(ftpFindExternalFTPServerIpType cb1, ftpAddUPNPPortForwardType cb2, ftpRemoveUPNPPortForwardType cb3, ftpIsValidClientType cb4) {
void ftpInit(ftpFindExternalFTPServerIpType cb1, ftpAddUPNPPortForwardType cb2,
ftpRemoveUPNPPortForwardType cb3, ftpIsValidClientType cb4,
ftpIsClientAllowedToGetFileType cb5) {
ftpFindExternalFTPServerIp = cb1;
ftpAddUPNPPortForward = cb2;
ftpRemoveUPNPPortForward = cb3;
ftpIsValidClient = cb4;
ftpIsClientAllowedToGetFile = cb5;
}
int ftpGetListenPort()

View File

@@ -254,12 +254,17 @@ LOCAL int normalizePath(char* path)
*/
const char* ftpGetRealPath(int id, const char* path, int normalize)
{
const char* ftpRoot;
char ftpRoot[2048]="";
int ftpRootLen;
int len;
ftpRoot = ftpGetRoot(sessions[id].userId, &len);
strcpy(ftpRoot,ftpGetRoot(sessions[id].userId, &len));
ftpRootLen = strlen(ftpRoot);
if(ftpRootLen > 0 && ftpRoot[ftpRootLen-1] != '/') {
strcat(ftpRoot,"/");
}
if(VERBOSE_MODE_ENABLED) printf("#1 ftpGetRealPath id = %d path [%s] ftpRoot [%s] sessions[id].workingDir [%s] normalize = %d\n", id, path, ftpRoot, sessions[id].workingDir,normalize);
if(VERBOSE_MODE_ENABLED) printf("#1 ftpGetRealPath id = %d path [%s] ftpRoot [%s] sessions[id].workingDir [%s] normalize = %d\n", id, path, ftpRoot, sessions[id].workingDir,normalize);
pathScratchBuf[0]='\0';
if(path[0] == '/' || strcmp(path,sessions[id].workingDir) == 0) // absolute path?