From: Remi Gacogne Date: Fri, 6 Nov 2015 15:28:56 +0000 (+0100) Subject: Handle LuaContext::SyntaxErrorException() in the Console server. Gracefully handle... X-Git-Tag: dnsdist-1.0.0-alpha1~226^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F2871%2Fhead;p=thirdparty%2Fpdns.git Handle LuaContext::SyntaxErrorException() in the Console server. Gracefully handle disconnection on the client. Fixes #2866. --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index a2f922cf12..8f4488738e 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -679,6 +679,9 @@ try response += string(e.reason); } } + catch(const LuaContext::SyntaxErrorException& e) { + response = "Error: " + string(e.what()) + ": "; + } response = sodEncryptSym(response, g_key, ours); putMsgLen(fd, response.length()); writen2(fd, response.c_str(), (uint16_t)response.length()); @@ -777,9 +780,13 @@ void doClient(ComboAddress server, const std::string& command) uint16_t len; getMsgLen(fd, &len); + if(len == 0) { + cout << "Connection closed by the server." << endl; + break; + } + char resp[len]; - if(len) - readn2(fd, resp, len); + readn2(fd, resp, len); msg.assign(resp, len); msg=sodDecryptSym(msg, g_key, theirs); cout<