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: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1542240ee87c056023a15a4b29ce4c2a5385c8ae;p=pdns 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 a2f922cf1..8f4488738 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<