From: Alan T. DeKok Date: Thu, 10 May 2018 14:29:47 +0000 (-0400) Subject: add local clients here, too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6f04c370c8cb02cccaa376b32d8f1e873c8eb85;p=thirdparty%2Ffreeradius-server.git add local clients here, too --- diff --git a/src/modules/proto_vmps/proto_vmps_udp.c b/src/modules/proto_vmps/proto_vmps_udp.c index e18fb7eef5b..f3627eef852 100644 --- a/src/modules/proto_vmps/proto_vmps_udp.c +++ b/src/modules/proto_vmps/proto_vmps_udp.c @@ -67,6 +67,8 @@ typedef struct proto_vmps_udp_t { fr_io_address_t *connection; //!< for connected sockets. + RADCLIENT_LIST *clients; //!< local clients + } proto_vmps_udp_t; @@ -456,6 +458,8 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) { proto_vmps_udp_t *inst = talloc_get_type_abort(instance, proto_vmps_udp_t); size_t num; + CONF_ITEM *ci; + CONF_SECTION *server_cs; inst->cs = cs; @@ -514,6 +518,27 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) } } + ci = cf_parent(inst->cs); /* listen { ... } */ + rad_assert(ci != NULL); + ci = cf_parent(ci); + rad_assert(ci != NULL); + + server_cs = cf_item_to_section(ci); + + /* + * Look up local clients, if they exist. + * + * @todo - ensure that we only parse clients which are + * for IPPROTO_UDP, and to not require a "secret". + */ + if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) { + inst->clients = client_list_parse_section(server_cs, false); + if (!inst->clients) { + cf_log_err(cs, "Failed creating local clients"); + return -1; + } + } + return 0; } @@ -522,6 +547,17 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) // which means we probably want to filter on "networks" even if there are no dynamic clients static RADCLIENT *mod_client_find(UNUSED void *instance, fr_ipaddr_t const *ipaddr, int ipproto) { + proto_vmps_udp_t *inst = talloc_get_type_abort(instance, proto_vmps_udp_t); + RADCLIENT *client; + + /* + * Prefer local clients. + */ + if (inst->clients) { + client = client_find(inst->clients, ipaddr, ipproto); + if (client) return client; + } + return client_find(NULL, ipaddr, ipproto); }