|
@@ -64,6 +64,13 @@ LWorld::LWorld(TCPConnection* in_con, bool in_OutgoingLoginUplink, int32 iIP, in
|
|
ip = iIP;
|
|
ip = iIP;
|
|
else
|
|
else
|
|
ip = in_con->GetrIP();
|
|
ip = in_con->GetrIP();
|
|
|
|
+
|
|
|
|
+ struct in_addr in;
|
|
|
|
+ in.s_addr = in_con->GetrIP();
|
|
|
|
+ char* ipadd = inet_ntoa(in);
|
|
|
|
+ if(ipadd)
|
|
|
|
+ strncpy(IPAddr,ipadd,64);
|
|
|
|
+
|
|
if (iPort)
|
|
if (iPort)
|
|
port = iPort;
|
|
port = iPort;
|
|
else
|
|
else
|
|
@@ -100,7 +107,6 @@ LWorld::LWorld(TCPConnection* in_con, bool in_OutgoingLoginUplink, int32 iIP, in
|
|
OutgoingUplink = false;
|
|
OutgoingUplink = false;
|
|
}
|
|
}
|
|
|
|
|
|
- struct in_addr in;
|
|
|
|
in.s_addr = GetIP();
|
|
in.s_addr = GetIP();
|
|
strcpy(address, inet_ntoa(in));
|
|
strcpy(address, inet_ntoa(in));
|
|
isaddressip = true;
|
|
isaddressip = true;
|
|
@@ -115,6 +121,7 @@ LWorld::LWorld(int32 in_accountid, char* in_accountname, char* in_worldname, int
|
|
ip = 0;
|
|
ip = 0;
|
|
port = 0;
|
|
port = 0;
|
|
ID = 0;
|
|
ID = 0;
|
|
|
|
+ strcpy(IPAddr,"");
|
|
pClientPort = 0;
|
|
pClientPort = 0;
|
|
memset(account, 0, sizeof(account));
|
|
memset(account, 0, sizeof(account));
|
|
memset(address, 0, sizeof(address));
|
|
memset(address, 0, sizeof(address));
|
|
@@ -151,6 +158,16 @@ LWorld::LWorld(TCPConnection* in_RemoteLink, int32 in_ip, int32 in_RemoteID, int
|
|
RemoteID = in_RemoteID;
|
|
RemoteID = in_RemoteID;
|
|
LinkWorldID = iLinkWorldID;
|
|
LinkWorldID = iLinkWorldID;
|
|
ip = in_ip;
|
|
ip = in_ip;
|
|
|
|
+
|
|
|
|
+ struct in_addr in;
|
|
|
|
+ if(in_RemoteLink)
|
|
|
|
+ in.s_addr = in_RemoteLink->GetrIP();
|
|
|
|
+ else if (in_ip)
|
|
|
|
+ in.s_addr = in_ip;
|
|
|
|
+ char* ipadd = inet_ntoa(in);
|
|
|
|
+ if(ipadd)
|
|
|
|
+ strncpy(IPAddr,ipadd,64);
|
|
|
|
+
|
|
port = 0;
|
|
port = 0;
|
|
ID = 0;
|
|
ID = 0;
|
|
pClientPort = 0;
|
|
pClientPort = 0;
|
|
@@ -234,7 +251,15 @@ bool LWorld::Process() {
|
|
return true;
|
|
return true;
|
|
|
|
|
|
if(pStatsTimer && pStatsTimer->Check())
|
|
if(pStatsTimer && pStatsTimer->Check())
|
|
|
|
+ {
|
|
|
|
+ if(isAuthenticated && (database.IsServerAccountDisabled(account) || database.IsIPBanned(IPAddr)))
|
|
|
|
+ {
|
|
|
|
+ this->Kick(ERROR_BADPASSWORD);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
database.UpdateWorldServerStats(this, GetStatus());
|
|
database.UpdateWorldServerStats(this, GetStatus());
|
|
|
|
+ }
|
|
|
|
|
|
ServerPacket* pack = 0;
|
|
ServerPacket* pack = 0;
|
|
while (ret && (pack = Link->PopPacket())) {
|
|
while (ret && (pack = Link->PopPacket())) {
|
|
@@ -302,6 +327,10 @@ bool LWorld::Process() {
|
|
UsertoWorldResponse_Struct* seps = (UsertoWorldResponse_Struct*) pack->pBuffer;
|
|
UsertoWorldResponse_Struct* seps = (UsertoWorldResponse_Struct*) pack->pBuffer;
|
|
if (seps->ToID) {
|
|
if (seps->ToID) {
|
|
LWorld* world = world_list.FindByID(seps->ToID);
|
|
LWorld* world = world_list.FindByID(seps->ToID);
|
|
|
|
+
|
|
|
|
+ if (this->GetType() != Login) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
if (world) {
|
|
if (world) {
|
|
seps->ToID = world->GetRemoteID();
|
|
seps->ToID = world->GetRemoteID();
|
|
world->SendPacket(pack);
|
|
world->SendPacket(pack);
|
|
@@ -453,41 +482,6 @@ bool LWorld::Process() {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case ServerOP_WorldListUpdate: {
|
|
case ServerOP_WorldListUpdate: {
|
|
- if (this->GetType() != Login) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (pack->size != sizeof(ServerSyncWorldList_Struct)) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- ServerSyncWorldList_Struct* sswls = (ServerSyncWorldList_Struct*) pack->pBuffer;
|
|
|
|
- if (!CheckServerName(sswls->name)) {
|
|
|
|
- //struct in_addr in;
|
|
|
|
- //in.s_addr = sswls->ip;
|
|
|
|
- break; // Someone needs to tell the other login server to update it's exe!
|
|
|
|
- }
|
|
|
|
- LWorld* world = world_list.FindByLink(this->Link, sswls->RemoteID);
|
|
|
|
- if (world) {
|
|
|
|
- world->SetRemoteInfo(sswls->ip, sswls->accountid, sswls->account, sswls->name, sswls->address, sswls->status, sswls->adminid, sswls->num_players, sswls->num_zones);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- world = world_list.FindByAccount(sswls->accountid, World);
|
|
|
|
- if (world == 0 || sswls->placeholder == false) {
|
|
|
|
- if (world) {
|
|
|
|
-#ifdef _DEBUG
|
|
|
|
- cout << "Kick(" << world->GetID() << ") in ServerOP_WorldListUpdate" << endl;
|
|
|
|
-#endif
|
|
|
|
- world->Kick();
|
|
|
|
- }
|
|
|
|
- world = new LWorld(this->Link, sswls->ip, sswls->RemoteID, sswls->accountid, sswls->account, sswls->name, sswls->address, sswls->status, sswls->adminid, sswls->showdown, sswls->authlevel, sswls->placeholder, this->GetID());
|
|
|
|
- LWorld* world2=world_list.FindByID(sswls->RemoteID);
|
|
|
|
- if(!world2)
|
|
|
|
- world_list.Add(world);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- sswls->RemoteID = world->GetID();
|
|
|
|
- if (net.GetLoginMode() != Mesh)
|
|
|
|
- world_list.SendPacketLogin(pack, this);
|
|
|
|
- cout << "Got world update for '" << sswls->name << "', #" << world->GetID() << endl;
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case ServerOP_WorldListRemove: {
|
|
case ServerOP_WorldListRemove: {
|
|
@@ -664,16 +658,24 @@ bool LWorld::SetupWorld(char* in_worldname, char* in_worldaddress, char* in_acco
|
|
strcpy(address, in_worldaddress);
|
|
strcpy(address, in_worldaddress);
|
|
}
|
|
}
|
|
if (strlen(in_worldname) > 3) {
|
|
if (strlen(in_worldname) > 3) {
|
|
- int32 id = database.CheckServerAccount(in_account, in_password);
|
|
|
|
|
|
+ char tmpAccount[30];
|
|
|
|
+ memcpy(tmpAccount, in_account, 29);
|
|
|
|
+ tmpAccount[29] = '\0';
|
|
|
|
+
|
|
|
|
+ int32 id = database.CheckServerAccount(tmpAccount, in_password);
|
|
|
|
|
|
if(id == 0)
|
|
if(id == 0)
|
|
return false;
|
|
return false;
|
|
|
|
+ if(database.IsServerAccountDisabled(tmpAccount) || database.IsIPBanned(IPAddr) || (isaddressip && database.IsIPBanned(address)))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
LWorld* world = world_list.FindByID(id);
|
|
LWorld* world = world_list.FindByID(id);
|
|
if(world)
|
|
if(world)
|
|
world->Kick("Ghost Kick!");
|
|
world->Kick("Ghost Kick!");
|
|
|
|
|
|
ID = id;
|
|
ID = id;
|
|
accountid = id;
|
|
accountid = id;
|
|
|
|
+ strncpy(account,tmpAccount,30);
|
|
char* name = database.GetServerAccountName(id);
|
|
char* name = database.GetServerAccountName(id);
|
|
if(name)
|
|
if(name)
|
|
snprintf(worldname, (sizeof(worldname)) - 1, "%s", name);
|
|
snprintf(worldname, (sizeof(worldname)) - 1, "%s", name);
|
|
@@ -684,7 +686,6 @@ bool LWorld::SetupWorld(char* in_worldname, char* in_worldaddress, char* in_acco
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
//world_list.KickGhostIP(GetIP(), this);
|
|
//world_list.KickGhostIP(GetIP(), this);
|
|
- account[0] = 0;
|
|
|
|
IsInit = true;
|
|
IsInit = true;
|
|
ptype = World;
|
|
ptype = World;
|
|
world_list.SendWorldChanged(id, true);
|
|
world_list.SendWorldChanged(id, true);
|
|
@@ -734,7 +735,7 @@ void LWorld::ChangeToPlaceholder() {
|
|
void LWorld::SetRemoteInfo(int32 in_ip, int32 in_accountid, char* in_account, char* in_name, char* in_address, int32 in_status, int32 in_adminid, sint32 in_players, sint32 in_zones) {
|
|
void LWorld::SetRemoteInfo(int32 in_ip, int32 in_accountid, char* in_account, char* in_name, char* in_address, int32 in_status, int32 in_adminid, sint32 in_players, sint32 in_zones) {
|
|
ip = in_ip;
|
|
ip = in_ip;
|
|
accountid = in_accountid;
|
|
accountid = in_accountid;
|
|
- strcpy(account, in_account);
|
|
|
|
|
|
+// strcpy(account, in_account);
|
|
strcpy(worldname, in_name);
|
|
strcpy(worldname, in_name);
|
|
strcpy(address, in_address);
|
|
strcpy(address, in_address);
|
|
status = in_status;
|
|
status = in_status;
|