mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-05 00:15:17 +00:00
[trac738] Remove old support for verbose flag
This is now handled in the new logging configuration.
This commit is contained in:
@@ -105,7 +105,6 @@ public:
|
||||
|
||||
/// These members are public because AuthSrv accesses them directly.
|
||||
ModuleCCSession* config_session_;
|
||||
bool verbose_mode_;
|
||||
AbstractSession* xfrin_session_;
|
||||
|
||||
/// In-memory data source. Currently class IN only for simplicity.
|
||||
@@ -144,11 +143,11 @@ private:
|
||||
|
||||
AuthSrvImpl::AuthSrvImpl(const bool use_cache,
|
||||
AbstractXfroutClient& xfrout_client) :
|
||||
config_session_(NULL), verbose_mode_(false),
|
||||
config_session_(NULL),
|
||||
xfrin_session_(NULL),
|
||||
memory_datasrc_class_(RRClass::IN()),
|
||||
statistics_timer_(io_service_),
|
||||
counters_(verbose_mode_),
|
||||
counters_(),
|
||||
keyring_(NULL),
|
||||
xfrout_connected_(false),
|
||||
xfrout_client_(xfrout_client)
|
||||
@@ -252,7 +251,7 @@ public:
|
||||
|
||||
void
|
||||
makeErrorMessage(MessagePtr message, OutputBufferPtr buffer,
|
||||
const Rcode& rcode, const bool&,
|
||||
const Rcode& rcode,
|
||||
std::auto_ptr<TSIGContext> tsig_context =
|
||||
std::auto_ptr<TSIGContext>())
|
||||
{
|
||||
@@ -295,16 +294,6 @@ makeErrorMessage(MessagePtr message, OutputBufferPtr buffer,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AuthSrv::setVerbose(const bool on) {
|
||||
impl_->verbose_mode_ = on;
|
||||
}
|
||||
|
||||
bool
|
||||
AuthSrv::getVerbose() const {
|
||||
return (impl_->verbose_mode_);
|
||||
}
|
||||
|
||||
IOService&
|
||||
AuthSrv::getIOService() {
|
||||
return (impl_->io_service_);
|
||||
@@ -427,15 +416,13 @@ AuthSrv::processMessage(const IOMessage& io_message, MessagePtr message,
|
||||
} catch (const DNSProtocolError& error) {
|
||||
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_PACKET_PROTOCOL_ERROR)
|
||||
.arg(error.getRcode().toText()).arg(error.what());
|
||||
makeErrorMessage(message, buffer, error.getRcode(),
|
||||
impl_->verbose_mode_);
|
||||
makeErrorMessage(message, buffer, error.getRcode());
|
||||
server->resume(true);
|
||||
return;
|
||||
} catch (const Exception& ex) {
|
||||
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_PACKET_PARSE_ERROR)
|
||||
.arg(ex.what());
|
||||
makeErrorMessage(message, buffer, Rcode::SERVFAIL(),
|
||||
impl_->verbose_mode_);
|
||||
makeErrorMessage(message, buffer, Rcode::SERVFAIL());
|
||||
server->resume(true);
|
||||
return;
|
||||
} // other exceptions will be handled at a higher layer.
|
||||
@@ -463,19 +450,16 @@ AuthSrv::processMessage(const IOMessage& io_message, MessagePtr message,
|
||||
|
||||
bool sendAnswer = true;
|
||||
if (tsig_error != TSIGError::NOERROR()) {
|
||||
makeErrorMessage(message, buffer, tsig_error.toRcode(),
|
||||
impl_->verbose_mode_, tsig_context);
|
||||
makeErrorMessage(message, buffer, tsig_error.toRcode(), tsig_context);
|
||||
} else if (message->getOpcode() == Opcode::NOTIFY()) {
|
||||
sendAnswer = impl_->processNotify(io_message, message, buffer,
|
||||
tsig_context);
|
||||
} else if (message->getOpcode() != Opcode::QUERY()) {
|
||||
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_UNSUPPORTED_OPCODE)
|
||||
.arg(message->getOpcode().toText());
|
||||
makeErrorMessage(message, buffer, Rcode::NOTIMP(),
|
||||
impl_->verbose_mode_, tsig_context);
|
||||
makeErrorMessage(message, buffer, Rcode::NOTIMP(), tsig_context);
|
||||
} else if (message->getRRCount(Message::SECTION_QUESTION) != 1) {
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(),
|
||||
impl_->verbose_mode_, tsig_context);
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(), tsig_context);
|
||||
} else {
|
||||
ConstQuestionPtr question = *message->beginQuestion();
|
||||
const RRType &qtype = question->getType();
|
||||
@@ -483,8 +467,7 @@ AuthSrv::processMessage(const IOMessage& io_message, MessagePtr message,
|
||||
sendAnswer = impl_->processAxfrQuery(io_message, message, buffer,
|
||||
tsig_context);
|
||||
} else if (qtype == RRType::IXFR()) {
|
||||
makeErrorMessage(message, buffer, Rcode::NOTIMP(),
|
||||
impl_->verbose_mode_, tsig_context);
|
||||
makeErrorMessage(message, buffer, Rcode::NOTIMP(), tsig_context);
|
||||
} else {
|
||||
sendAnswer = impl_->processNormalQuery(io_message, message, buffer,
|
||||
tsig_context);
|
||||
@@ -532,7 +515,7 @@ AuthSrvImpl::processNormalQuery(const IOMessage& io_message, MessagePtr message,
|
||||
}
|
||||
} catch (const Exception& ex) {
|
||||
LOG_ERROR(auth_logger, AUTH_PROCESS_FAIL).arg(ex.what());
|
||||
makeErrorMessage(message, buffer, Rcode::SERVFAIL(), verbose_mode_);
|
||||
makeErrorMessage(message, buffer, Rcode::SERVFAIL());
|
||||
return (true);
|
||||
}
|
||||
|
||||
@@ -561,8 +544,7 @@ AuthSrvImpl::processAxfrQuery(const IOMessage& io_message, MessagePtr message,
|
||||
|
||||
if (io_message.getSocket().getProtocol() == IPPROTO_UDP) {
|
||||
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_AXFR_UDP);
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(), verbose_mode_,
|
||||
tsig_context);
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(), tsig_context);
|
||||
return (true);
|
||||
}
|
||||
|
||||
@@ -587,8 +569,7 @@ AuthSrvImpl::processAxfrQuery(const IOMessage& io_message, MessagePtr message,
|
||||
|
||||
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_AXFR_ERROR)
|
||||
.arg(err.what());
|
||||
makeErrorMessage(message, buffer, Rcode::SERVFAIL(), verbose_mode_,
|
||||
tsig_context);
|
||||
makeErrorMessage(message, buffer, Rcode::SERVFAIL(), tsig_context);
|
||||
return (true);
|
||||
}
|
||||
|
||||
@@ -605,16 +586,14 @@ AuthSrvImpl::processNotify(const IOMessage& io_message, MessagePtr message,
|
||||
if (message->getRRCount(Message::SECTION_QUESTION) != 1) {
|
||||
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_NOTIFY_QUESTIONS)
|
||||
.arg(message->getRRCount(Message::SECTION_QUESTION));
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(), verbose_mode_,
|
||||
tsig_context);
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(), tsig_context);
|
||||
return (true);
|
||||
}
|
||||
ConstQuestionPtr question = *message->beginQuestion();
|
||||
if (question->getType() != RRType::SOA()) {
|
||||
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_NOTIFY_RRTYPE)
|
||||
.arg(question->getType().toText());
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(), verbose_mode_,
|
||||
tsig_context);
|
||||
makeErrorMessage(message, buffer, Rcode::FORMERR(), tsig_context);
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
@@ -124,27 +124,6 @@ public:
|
||||
isc::util::OutputBufferPtr buffer,
|
||||
isc::asiodns::DNSServer* server);
|
||||
|
||||
/// \brief Set verbose flag
|
||||
///
|
||||
/// \param on The new value of the verbose flag
|
||||
|
||||
/// \brief Enable or disable verbose logging.
|
||||
///
|
||||
/// This method never throws an exception.
|
||||
///
|
||||
/// \param on \c true to enable verbose logging; \c false to disable
|
||||
/// verbose logging.
|
||||
void setVerbose(const bool on);
|
||||
|
||||
/// \brief Returns the logging verbosity of the \c AuthSrv object.
|
||||
///
|
||||
/// This method never throws an exception.
|
||||
///
|
||||
/// \return \c true if verbose logging is enabled; otherwise \c false.
|
||||
|
||||
/// \brief Get the current value of the verbose flag
|
||||
bool getVerbose() const;
|
||||
|
||||
/// \brief Updates the data source for the \c AuthSrv object.
|
||||
///
|
||||
/// This method installs or replaces the data source that the \c AuthSrv
|
||||
|
@@ -65,8 +65,6 @@ using namespace isc::xfr;
|
||||
|
||||
namespace {
|
||||
|
||||
bool verbose_mode = false;
|
||||
|
||||
/* need global var for config/command handlers.
|
||||
* todo: turn this around, and put handlers in the authserver
|
||||
* class itself? */
|
||||
@@ -100,6 +98,7 @@ main(int argc, char* argv[]) {
|
||||
int ch;
|
||||
const char* uid = NULL;
|
||||
bool cache = true;
|
||||
bool verbose = false;
|
||||
|
||||
while ((ch = getopt(argc, argv, ":nu:v")) != -1) {
|
||||
switch (ch) {
|
||||
@@ -110,7 +109,7 @@ main(int argc, char* argv[]) {
|
||||
uid = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
verbose_mode = true;
|
||||
verbose = true;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
@@ -124,7 +123,7 @@ main(int argc, char* argv[]) {
|
||||
|
||||
// Initialize logging. If verbose, we'll use maximum verbosity.
|
||||
isc::log::initLogger("b10-auth",
|
||||
(verbose_mode ? isc::log::DEBUG : isc::log::INFO),
|
||||
(verbose ? isc::log::DEBUG : isc::log::INFO),
|
||||
isc::log::MAX_DEBUG_LEVEL, NULL);
|
||||
|
||||
int ret = 0;
|
||||
@@ -147,7 +146,6 @@ main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
auth_server = new AuthSrv(cache, xfrout_client);
|
||||
auth_server->setVerbose(verbose_mode);
|
||||
LOG_INFO(auth_logger, AUTH_SERVER_CREATED);
|
||||
|
||||
SimpleCallback* checkin = auth_server->getCheckinProvider();
|
||||
|
@@ -32,10 +32,7 @@ private:
|
||||
AuthCountersImpl(const AuthCountersImpl& source);
|
||||
AuthCountersImpl& operator=(const AuthCountersImpl& source);
|
||||
public:
|
||||
// References verbose_mode flag in AuthSrvImpl
|
||||
// TODO: Fix this short term workaround for logging
|
||||
// after we have logging framework
|
||||
AuthCountersImpl(const bool& verbose_mode);
|
||||
AuthCountersImpl();
|
||||
~AuthCountersImpl();
|
||||
void inc(const AuthCounters::CounterType type);
|
||||
bool submitStatistics() const;
|
||||
@@ -45,15 +42,13 @@ public:
|
||||
private:
|
||||
std::vector<uint64_t> counters_;
|
||||
isc::cc::AbstractSession* statistics_session_;
|
||||
const bool& verbose_mode_;
|
||||
};
|
||||
|
||||
AuthCountersImpl::AuthCountersImpl(const bool& verbose_mode) :
|
||||
AuthCountersImpl::AuthCountersImpl() :
|
||||
// initialize counter
|
||||
// size: AuthCounters::COUNTER_TYPES, initial value: 0
|
||||
counters_(AuthCounters::COUNTER_TYPES, 0),
|
||||
statistics_session_(NULL),
|
||||
verbose_mode_(verbose_mode)
|
||||
statistics_session_(NULL)
|
||||
{}
|
||||
|
||||
AuthCountersImpl::~AuthCountersImpl()
|
||||
@@ -67,9 +62,7 @@ AuthCountersImpl::inc(const AuthCounters::CounterType type) {
|
||||
bool
|
||||
AuthCountersImpl::submitStatistics() const {
|
||||
if (statistics_session_ == NULL) {
|
||||
if (verbose_mode_) {
|
||||
LOG_ERROR(auth_logger, AUTH_NO_STATS_SESSION);
|
||||
}
|
||||
LOG_ERROR(auth_logger, AUTH_NO_STATS_SESSION);
|
||||
return (false);
|
||||
}
|
||||
std::stringstream statistics_string;
|
||||
@@ -96,14 +89,10 @@ AuthCountersImpl::submitStatistics() const {
|
||||
// currently it just returns empty message
|
||||
statistics_session_->group_recvmsg(env, answer, false, seq);
|
||||
} catch (const isc::cc::SessionError& ex) {
|
||||
if (verbose_mode_) {
|
||||
LOG_ERROR(auth_logger, AUTH_STATS_COMMS).arg(ex.what());
|
||||
}
|
||||
LOG_ERROR(auth_logger, AUTH_STATS_COMMS).arg(ex.what());
|
||||
return (false);
|
||||
} catch (const isc::cc::SessionTimeout& ex) {
|
||||
if (verbose_mode_) {
|
||||
LOG_ERROR(auth_logger, AUTH_STATS_TIMEOUT).arg(ex.what());
|
||||
}
|
||||
LOG_ERROR(auth_logger, AUTH_STATS_TIMEOUT).arg(ex.what());
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
@@ -122,8 +111,7 @@ AuthCountersImpl::getCounter(const AuthCounters::CounterType type) const {
|
||||
return (counters_.at(type));
|
||||
}
|
||||
|
||||
AuthCounters::AuthCounters(const bool& verbose_mode) :
|
||||
impl_(new AuthCountersImpl(verbose_mode))
|
||||
AuthCounters::AuthCounters() : impl_(new AuthCountersImpl())
|
||||
{}
|
||||
|
||||
AuthCounters::~AuthCounters() {
|
||||
|
@@ -61,15 +61,10 @@ public:
|
||||
};
|
||||
/// The constructor.
|
||||
///
|
||||
/// \param verbose_mode reference to verbose_mode_ of AuthSrvImpl
|
||||
///
|
||||
/// This constructor is mostly exception free. But it may still throw
|
||||
/// a standard exception if memory allocation fails inside the method.
|
||||
///
|
||||
/// \todo Fix this short term workaround for logging
|
||||
/// after we have logging framework.
|
||||
///
|
||||
AuthCounters(const bool& verbose_mode);
|
||||
AuthCounters();
|
||||
/// The destructor.
|
||||
///
|
||||
/// This method never throws an exception.
|
||||
|
@@ -190,15 +190,6 @@ TEST_F(AuthSrvTest, unsupportedRequest) {
|
||||
unsupportedRequest();
|
||||
}
|
||||
|
||||
// Simple API check
|
||||
TEST_F(AuthSrvTest, verbose) {
|
||||
EXPECT_FALSE(server.getVerbose());
|
||||
server.setVerbose(true);
|
||||
EXPECT_TRUE(server.getVerbose());
|
||||
server.setVerbose(false);
|
||||
EXPECT_FALSE(server.getVerbose());
|
||||
}
|
||||
|
||||
// Multiple questions. Should result in FORMERR.
|
||||
TEST_F(AuthSrvTest, multiQuestion) {
|
||||
multiQuestion();
|
||||
|
@@ -69,13 +69,12 @@ private:
|
||||
};
|
||||
|
||||
protected:
|
||||
AuthCountersTest() : verbose_mode_(false), counters(verbose_mode_) {
|
||||
AuthCountersTest() : counters() {
|
||||
counters.setStatisticsSession(&statistics_session_);
|
||||
}
|
||||
~AuthCountersTest() {
|
||||
}
|
||||
MockSession statistics_session_;
|
||||
bool verbose_mode_;
|
||||
AuthCounters counters;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user