Browse Source

lightningd: list disabled plugins in listconfig.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
nifty/pset-pre
Rusty Russell 5 years ago
parent
commit
fe365f930f
  1. 3
      lightningd/options.c
  2. 10
      lightningd/plugin.c
  3. 6
      lightningd/plugin.h
  4. 6
      tests/test_plugin.py

3
lightningd/options.c

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

10
lightningd/plugin.c

@ -180,6 +180,7 @@ void plugin_blacklist(struct plugins *plugins, const char *name)
{
struct plugin *p, *next;
log_debug(plugins->log, "blacklist for %s", name);
list_for_each_safe(&plugins->plugins, p, next, list) {
if (plugin_paths_match(p->cmd, name)) {
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);
}
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.
*/

6
lightningd/plugin.h

@ -274,6 +274,12 @@ void json_add_opt_plugins(struct json_stream *response,
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.
*

6
tests/test_plugin.py

@ -322,6 +322,12 @@ def test_plugin_disable(node_factory):
n.rpc.plugin_startdir(directory=os.path.join(os.getcwd(), "contrib/plugins"))
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):
"""The helloworld plugin registers a htlc_accepted hook.

Loading…
Cancel
Save