Add future deprecation warning to --rpc-user and --rpc-passwd

This commit is contained in:
Tatsuhiro Tsujikawa 2014-02-02 17:58:56 +09:00
parent 7f6987a4b4
commit 7d1aa887ee
5 changed files with 56 additions and 17 deletions

View File

@ -988,6 +988,12 @@ RPC Options
Set JSON-RPC/XML-RPC password.
.. Warning::
:option:`--rpc-passwd` option will be deprecated in the future
release. Migrate to :option:`--rpc-secret` option as soon as
possible.
.. option:: --rpc-private-key=<FILE>
Use the private key in FILE for RPC server. The private key must be
@ -1021,6 +1027,12 @@ RPC Options
Set JSON-RPC/XML-RPC user.
.. Warning::
:option:`--rpc-user` option will be deprecated in the future
release. Migrate to :option:`--rpc-secret` option as soon as
possible.
Advanced Options
~~~~~~~~~~~~~~~~
.. option:: --allow-overwrite[=true|false]

View File

@ -883,17 +883,22 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
handlers.push_back(op);
}
{
OptionHandler* op(new DefaultOptionHandler
(PREF_RPC_USER,
TEXT_RPC_USER));
OptionHandler* op(new DeprecatedOptionHandler
(new DefaultOptionHandler
(PREF_RPC_USER,
TEXT_RPC_USER),
nullptr, true,
"Migrate to --rpc-secret option as soon as possible."));
op->addTag(TAG_RPC);
op->setEraseAfterParse(true);
handlers.push_back(op);
}
{
OptionHandler* op(new DefaultOptionHandler
(PREF_RPC_PASSWD,
TEXT_RPC_PASSWD));
OptionHandler* op(new DeprecatedOptionHandler
(new DefaultOptionHandler
(PREF_RPC_PASSWD,
TEXT_RPC_PASSWD),
nullptr, true));
op->addTag(TAG_RPC);
op->setEraseAfterParse(true);
handlers.push_back(op);

View File

@ -578,8 +578,13 @@ std::string PrioritizePieceOptionHandler::createPossibleValuesString() const
DeprecatedOptionHandler::DeprecatedOptionHandler
(OptionHandler* depOptHandler,
const OptionHandler* repOptHandler)
: depOptHandler_(depOptHandler), repOptHandler_(repOptHandler)
const OptionHandler* repOptHandler,
bool stillWork,
std::string additionalMessage)
: depOptHandler_(depOptHandler),
repOptHandler_(repOptHandler),
stillWork_(stillWork),
additionalMessage_(std::move(additionalMessage))
{
depOptHandler_->addTag(TAG_DEPRECATED);
}
@ -594,13 +599,21 @@ void DeprecatedOptionHandler::parse(Option& option, const std::string& arg)
const
{
if(repOptHandler_) {
A2_LOG_WARN(fmt(_("--%s option is deprecated. Use --%s option instead."),
A2_LOG_WARN(fmt(_("--%s option is deprecated. Use --%s option instead. %s"),
depOptHandler_->getName(),
repOptHandler_->getName()));
repOptHandler_->getName(),
additionalMessage_.c_str()));
repOptHandler_->parse(option, arg);
} else if(stillWork_) {
A2_LOG_WARN(fmt(_("--%s option will be deprecated in the future release. "
"%s"),
depOptHandler_->getName(),
additionalMessage_.c_str()));
depOptHandler_->parse(option, arg);
} else {
A2_LOG_WARN(fmt(_("--%s option is deprecated."),
depOptHandler_->getName()));
A2_LOG_WARN(fmt(_("--%s option is deprecated. %s"),
depOptHandler_->getName(),
additionalMessage_.c_str()));
}
}

View File

@ -265,13 +265,18 @@ class DeprecatedOptionHandler:public OptionHandler {
private:
OptionHandler* depOptHandler_;
const OptionHandler* repOptHandler_;
bool stillWork_;
std::string additionalMessage_;
public:
// depOptHandler is deprecated option and repOptHandler is replacing
// new option. If there is no replacing option, omit second
// argument.
// new option. If there is no replacing option, specify nullptr. If
// there is no replacing option, but the option still alives, give
// true to stillWork. Set additional message to additionalMessage.
DeprecatedOptionHandler
(OptionHandler* depOptHandler,
const OptionHandler* repOptHandler = nullptr);
const OptionHandler* repOptHandler = nullptr,
bool stillWork = false,
std::string additionalMessage = "");
virtual ~DeprecatedOptionHandler();
virtual void parse(Option& option, const std::string& arg) const
CXX11_OVERRIDE;

View File

@ -780,9 +780,13 @@
" detects the request is more than SIZE bytes, it\n" \
" drops connection.")
#define TEXT_RPC_USER \
_(" --rpc-user=USER Set JSON-RPC/XML-RPC user.")
_(" --rpc-user=USER Set JSON-RPC/XML-RPC user. This option will be\n" \
" deprecated in the future release. Migrate to\n" \
" --rpc-secret option as soon as possible.")
#define TEXT_RPC_PASSWD \
_(" --rpc-passwd=PASSWD Set JSON-RPC/XML-RPC password.")
_(" --rpc-passwd=PASSWD Set JSON-RPC/XML-RPC password. This option will\n" \
" be deprecated in the future release. Migrate to\n" \
" --rpc-secret option as soon as possible.")
#define TEXT_RPC_LISTEN_ALL \
_(" --rpc-listen-all[=true|false] Listen incoming JSON-RPC/XML-RPC requests on all\n" \
" network interfaces. If false is given, listen only\n" \