address peer listing having multiple of the same addresses (So we can just list all in the same server_config instead of many dirs with their own server_config)
This commit is contained in:
parent
beaa63504c
commit
82bea97ff2
@ -290,15 +290,18 @@ void World::init(std::string web_ipaddr, int16 web_port, std::string cert_file,
|
||||
return;
|
||||
}
|
||||
try {
|
||||
std::map<std::string, int16> peers = net.GetWebPeers();
|
||||
std::map<std::string, int16>::iterator peer_itr;
|
||||
if(peers.size() > 0) {
|
||||
std::multimap<std::string, int16> peers = net.GetWebPeers();
|
||||
std::multimap<std::string, int16>::iterator peer_itr;
|
||||
if (!peers.empty()) {
|
||||
net.is_primary = false;
|
||||
for(peer_itr = peers.begin(); peer_itr != peers.end(); peer_itr++) {
|
||||
if(net.GetWebWorldAddress() == peer_itr->first && net.GetWebWorldPort() == peer_itr->second)
|
||||
continue; // no good you can't add yourself
|
||||
for (peer_itr = peers.begin(); peer_itr != peers.end(); ++peer_itr) {
|
||||
if (net.GetWebWorldAddress() == peer_itr->first && net.GetWebWorldPort() == peer_itr->second) {
|
||||
continue; // no good, you can't add yourself
|
||||
}
|
||||
|
||||
std::string portNum = std::to_string(peer_itr->second);
|
||||
std::string peerName = "eq2emu_" + peer_itr->first + "_" + portNum;
|
||||
|
||||
peer_manager.addPeer(peerName, PeeringStatus::SECONDARY, "", "", 0, peer_itr->first, peer_itr->second);
|
||||
peer_https_pool.addPeerClient(peerName, peer_itr->first, std::to_string(peer_itr->second), "/addpeer");
|
||||
}
|
||||
|
@ -779,7 +779,7 @@ bool NetConnection::ReadLoginINI(int argc, char** argv) {
|
||||
int16 port = 0;
|
||||
parser.convertStringToUnsignedShort(web_peerport, port);
|
||||
if(port > 0) {
|
||||
web_peers[web_peeraddress] = port;
|
||||
web_peers.insert({web_peeraddress, port});
|
||||
LogWrite(INIT__INFO, 0, "Init", "Adding peer %s:%u...", web_peeraddress.c_str(), port);
|
||||
}
|
||||
else {
|
||||
|
@ -96,7 +96,11 @@ public:
|
||||
std::string GetWebHardcodePassword() { return web_hardcodepassword; }
|
||||
std::string GetCmdUser() { return web_cmduser; }
|
||||
std::string GetCmdPassword() { return web_cmdpassword; }
|
||||
std::map<std::string, int16> GetWebPeers() { std::map<std::string, int16> copied_map(web_peers); return copied_map; }
|
||||
std::multimap<std::string, int16> GetWebPeers() {
|
||||
// Create a copy of the existing multimap
|
||||
std::multimap<std::string, int16> copied_map(web_peers);
|
||||
return copied_map;
|
||||
}
|
||||
int16 GetPeerPriority() { return web_peerpriority; }
|
||||
bool world_locked;
|
||||
std::atomic<bool> is_primary;
|
||||
@ -119,7 +123,7 @@ private:
|
||||
std::string web_hardcodepassword;
|
||||
std::string web_cmduser;
|
||||
std::string web_cmdpassword;
|
||||
std::map<std::string, int16> web_peers;
|
||||
std::multimap<std::string, int16> web_peers;
|
||||
int16 web_worldport;
|
||||
int16 web_peerpriority;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user