lightningd: list disabled plugins in listconfig.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-05-05 10:45:34 +09:30
parent 24063ca972
commit fe365f930f
4 changed files with 24 additions and 1 deletions

View file

@ -1278,8 +1278,9 @@ static void add_config(struct lightningd *ld,
json_add_opt_plugins(response, ld->plugins); json_add_opt_plugins(response, ld->plugins);
} else if (opt->cb_arg == (void *)opt_log_level) { } else if (opt->cb_arg == (void *)opt_log_level) {
json_add_opt_log_levels(response, ld->log); json_add_opt_log_levels(response, ld->log);
} else if (opt->cb_arg == (void *)opt_disable_plugin) {
json_add_opt_disable_plugins(response, ld->plugins);
} else if (opt->cb_arg == (void *)opt_add_plugin_dir } else if (opt->cb_arg == (void *)opt_add_plugin_dir
|| opt->cb_arg == (void *)opt_disable_plugin
|| opt->cb_arg == (void *)plugin_opt_set || opt->cb_arg == (void *)plugin_opt_set
|| opt->cb_arg == (void *)plugin_opt_flag_set) { || opt->cb_arg == (void *)plugin_opt_flag_set) {
/* FIXME: We actually treat it as if they specified /* FIXME: We actually treat it as if they specified

View file

@ -180,6 +180,7 @@ void plugin_blacklist(struct plugins *plugins, const char *name)
{ {
struct plugin *p, *next; struct plugin *p, *next;
log_debug(plugins->log, "blacklist for %s", name);
list_for_each_safe(&plugins->plugins, p, next, list) { list_for_each_safe(&plugins->plugins, p, next, list) {
if (plugin_paths_match(p->cmd, name)) { if (plugin_paths_match(p->cmd, name)) {
log_info(plugins->log, "%s: disabled via disable-plugin", log_info(plugins->log, "%s: disabled via disable-plugin",
@ -1453,6 +1454,15 @@ void json_add_opt_plugins(struct json_stream *response,
json_array_end(response); json_array_end(response);
} }
void json_add_opt_disable_plugins(struct json_stream *response,
const struct plugins *plugins)
{
json_array_start(response, "disable-plugin");
for (size_t i = 0; i < tal_count(plugins->blacklist); i++)
json_add_string(response, NULL, plugins->blacklist[i]);
json_array_end(response);
}
/** /**
* Determine whether a plugin is subscribed to a given topic/method. * Determine whether a plugin is subscribed to a given topic/method.
*/ */

View file

@ -274,6 +274,12 @@ void json_add_opt_plugins(struct json_stream *response,
const struct plugins *plugins); const struct plugins *plugins);
/**
* Add the disable-plugins options to listconfigs.
*/
void json_add_opt_disable_plugins(struct json_stream *response,
const struct plugins *plugins);
/** /**
* Used by db hooks which can't have any other I/O while talking to plugin. * Used by db hooks which can't have any other I/O while talking to plugin.
* *

View file

@ -322,6 +322,12 @@ def test_plugin_disable(node_factory):
n.rpc.plugin_startdir(directory=os.path.join(os.getcwd(), "contrib/plugins")) n.rpc.plugin_startdir(directory=os.path.join(os.getcwd(), "contrib/plugins"))
n.daemon.wait_for_log('helloworld.py: disabled via disable-plugin') n.daemon.wait_for_log('helloworld.py: disabled via disable-plugin')
# Check that list works
n = node_factory.get_node(options={'disable-plugin':
['something-else.py', 'helloworld.py']})
assert n.rpc.listconfigs()['disable-plugin'] == ['something-else.py', 'helloworld.py']
def test_plugin_hook(node_factory, executor): def test_plugin_hook(node_factory, executor):
"""The helloworld plugin registers a htlc_accepted hook. """The helloworld plugin registers a htlc_accepted hook.