]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add local clients here, too
authorAlan T. DeKok <aland@freeradius.org>
Thu, 10 May 2018 14:29:47 +0000 (10:29 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 10 May 2018 15:11:43 +0000 (11:11 -0400)
src/modules/proto_vmps/proto_vmps_udp.c

index e18fb7eef5bcab516333d6fedcf4b13bfb459ab1..f3627eef852c64663dd6dfb82f8b60fe8886842d 100644 (file)
@@ -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);
 }