Example #1
0
EQLConfig * EQW::GetLauncher(Const_char *launcher_name) {
	return(launcher_list.GetConfig(launcher_name));
}
Example #2
0
bool LauncherLink::Process() {
	if (!tcpc->Connected())
		return false;

	if(m_bootTimer.Check(false)) {
		//force a boot on any zone which isnt running.
		std::map<std::string, ZoneState>::iterator cur, end;
		cur = m_states.begin();
		end = m_states.end();
		for(; cur != end; ++cur) {
			if(!cur->second.up) {
				StartZone(cur->first.c_str());
			}
		}
		m_bootTimer.Disable();
	}

	ServerPacket *pack = 0;
	while((pack = tcpc->PopPacket())) {
		_hex(WORLD__ZONE_TRACE,pack->pBuffer,pack->size);
		if (!authenticated) {
			if (WorldConfig::get()->SharedKey.length() > 0) {
				if (pack->opcode == ServerOP_ZAAuth && pack->size == 16) {
					uint8 tmppass[16];
					MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
					if (memcmp(pack->pBuffer, tmppass, 16) == 0)
						authenticated = true;
					else {
						struct in_addr in;
						in.s_addr = GetIP();
						_log(WORLD__LAUNCH_ERR, "Launcher authorization failed.");
						ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
						SendPacket(pack);
						delete pack;
						Disconnect();
						return false;
					}
				}
				else {
					struct in_addr in;
					in.s_addr = GetIP();
					_log(WORLD__LAUNCH_ERR, "Launcher authorization failed.");
					ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
					SendPacket(pack);
					delete pack;
					Disconnect();
					return false;
				}
			}
			else
			{
				_log(WORLD__LAUNCH,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
				authenticated = true;
			}
			delete pack;
			continue;
		}
		switch(pack->opcode) {
		case 0:
			break;
		case ServerOP_KeepAlive: {
			// ignore this
			break;
		}
		case ServerOP_ZAAuth: {
			_log(WORLD__LAUNCH, "Got authentication from %s when they are already authenticated.", m_name.c_str());
			break;
		}
		case ServerOP_LauncherConnectInfo: {
			const LauncherConnectInfo *it = (const LauncherConnectInfo *) pack->pBuffer;
			if(HasName()) {
				_log(WORLD__LAUNCH_ERR, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name);
				break;
			}
			m_name = it->name;

			EQLConfig *config = launcher_list.GetConfig(m_name.c_str());
			if(config == nullptr) {
				_log(WORLD__LAUNCH, "Unknown launcher '%s' connected. Disconnecting.", it->name);
				Disconnect();
				break;
			}

			_log(WORLD__LAUNCH, "Launcher Identified itself as '%s'. Loading zone list.", it->name);

			std::vector<LauncherZone> result;
			//database.GetLauncherZones(it->name, result);
			config->GetZones(result);

			std::vector<LauncherZone>::iterator cur, end;
			cur = result.begin();
			end = result.end();
			ZoneState zs;
			for(; cur != end; cur++) {
				zs.port = cur->port;
				zs.up = false;
				zs.starts = 0;
				_log(WORLD__LAUNCH_TRACE, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port);
				m_states[cur->name] = zs;
			}

			//now we add all the dynamics.
			BootDynamics(config->GetDynamicCount());

			m_bootTimer.Start();

			break;
		}
		case ServerOP_LauncherZoneStatus: {
			const LauncherZoneStatus *it = (const LauncherZoneStatus *) pack->pBuffer;
			std::map<std::string, ZoneState>::iterator res;
			res = m_states.find(it->short_name);
			if(res == m_states.end()) {
				_log(WORLD__LAUNCH_ERR, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name);
				break;
			}
			_log(WORLD__LAUNCH, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running?"STARTED":"STOPPED", it->start_count);
			res->second.up = it->running;
			res->second.starts = it->start_count;
			break;
		}
		default:
		{
			_log(WORLD__LAUNCH_ERR, "Unknown ServerOPcode from launcher 0x%04x, size %d",pack->opcode,pack->size);
			DumpPacket(pack->pBuffer, pack->size);
			break;
		}
		}

		delete pack;
	}
	return(true);
}