diff --git a/src/modules/lcr/lcr_rpc.c b/src/modules/lcr/lcr_rpc.c index baf657ad0c9..af4a205d35e 100644 --- a/src/modules/lcr/lcr_rpc.c +++ b/src/modules/lcr/lcr_rpc.c @@ -126,18 +126,36 @@ static const char *dump_rules_doc[2] = { static void dump_rules(rpc_t *rpc, void *c) { int i, j; + int _filter_by_prefix = 0; + int _lcr_id = 0; + str _prefix = {NULL,0}; struct rule_info **rules, *rule; struct target *t; void *st; str prefix, from_uri, request_uri; + if (rpc->scan(c, "d", &_lcr_id)>0) { + if (rpc->scan(c, ".S", &_prefix)>0) { + _filter_by_prefix = 1; + } + } + for(j = 1; j <= lcr_count_param; j++) { + if (_lcr_id && _lcr_id!=j) continue; + rules = rule_pt[j]; for(i = 0; i < lcr_rule_hash_size_param; i++) { rule = rules[i]; while(rule) { + if (_filter_by_prefix && _prefix.len && _prefix.s) { + if (_prefix.len > rule->prefix_len || + strncmp(_prefix.s, rule->prefix, _prefix.len)!=0) { + rule = rule->next; + continue; + } + } if(rpc->add(c, "{", &st) < 0) return; prefix.s = rule->prefix; @@ -243,4 +261,4 @@ rpc_export_t lcr_rpc[] = { {"lcr.load_gws", load_gws, load_gws_doc, 0}, {0, 0, 0, 0} }; -/* clang-format on */ \ No newline at end of file +/* clang-format on */