From 0f17e031e85dc7359ce1a0cbb842b07d2b2aa82a Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 18 Feb 2016 10:32:38 +0100 Subject: [PATCH] basic loop connection detection. prevent if you configure forward to 127.0.0.1: and your server has the same port. But this doesn't protect if not forwarded to localhost "127.0.0.1". Loop connections across different hosts arn't detected too. Former-commit-id: 464a80708ebd11c0f7c83dc87a1afe0f10e0e078 --- libsrc/jsonserver/JsonServer.cpp | 8 ++++++++ libsrc/protoserver/ProtoServer.cpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/libsrc/jsonserver/JsonServer.cpp b/libsrc/jsonserver/JsonServer.cpp index 4efe855c..4cd7f411 100644 --- a/libsrc/jsonserver/JsonServer.cpp +++ b/libsrc/jsonserver/JsonServer.cpp @@ -16,6 +16,14 @@ JsonServer::JsonServer(Hyperion *hyperion, uint16_t port) : throw std::runtime_error("Json server could not bind to port"); } + QList list = _hyperion->getForwarder()->getJsonSlaves(); + for ( int i=0; igetProtoSlaves(); for (int i = 0; i < slaves.size(); ++i) { + if ( QString("127.0.0.1:%1").arg(port) == slaves.at(i) ) { + throw std::runtime_error("Loop between proto server and forwarder detected. Fix your config!"); + } + ProtoConnection* p = new ProtoConnection(slaves.at(i).toLocal8Bit().constData()); p->setSkipReply(true); _proxy_connections << p;