Balancer input ignores replies of local addresses to prevent loops, load balancer itself updated to not sent self-answers to servers.

This commit is contained in:
Thulinma 2018-07-09 11:23:21 +02:00
parent eeffba15ad
commit 5b059dcf6f
3 changed files with 13 additions and 1 deletions

View file

@ -93,6 +93,7 @@ private:
public:
std::string host;
char binHost[16];
unsigned long long availBandwidth;
JSON::Value geoDetails;
double servLati, servLongi;
@ -498,6 +499,10 @@ int handleRequest(Socket::Connection &conn){
unsigned int bestScore = 0;
for (HOSTLOOP){
HOSTCHECK;
if (Socket::matchIPv6Addr(std::string(HOST(i).details->binHost ,16), conn.getBinHost(), 0)){
INFO_MSG("Ignoring same-host entry %s", HOST(i).details->host.data());
continue;
}
unsigned int score = HOST(i).details->source(source);
if (score > bestScore){
bestHost = "dtsc://" + HOST(i).details->host;
@ -661,6 +666,7 @@ void handleServer(void *hostEntryPointer){
}else{
if (down){
WARN_MSG("Connection established with %s", url.host.c_str());
memcpy(entry->details->binHost, DL.getSocket().getBinHost().data(), 16);
entry->state = STATE_ONLINE;
down = false;
}