]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow proxying to home servers by name
authorAlan T. DeKok <aland@freeradius.org>
Sun, 19 Apr 2020 17:44:44 +0000 (13:44 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 20 Apr 2020 12:37:49 +0000 (08:37 -0400)
share/dictionary.freeradius.internal
src/main/process.c

index 724e1f7ff67e0cf3294e5947f4e3aa4675811787..644b04042597b4c353a61c2a2a6def1f88a1fda2 100644 (file)
@@ -278,6 +278,7 @@ ATTRIBUTE   SSHA2-384-Password                      1179    octets
 ATTRIBUTE      SSHA2-512-Password                      1180    octets
 
 ATTRIBUTE      MS-CHAP-Peer-Challenge                  1192    octets
+ATTRIBUTE      Home-Server-Name                        1193    string
 
 #
 #      Range:  1200-1279
index fcd0a0ad06175d954cbc85928c74e87d415eda4e..3d24a3673a9d216cbfa34681ee2e1c10fed16af3 100644 (file)
@@ -2898,8 +2898,9 @@ static void proxy_running(REQUEST *request, int action)
  * The key attributes are:
  *   - PW_PROXY_TO_REALM          - Specifies a realm the request should be proxied to.
  *   - PW_HOME_SERVER_POOL        - Specifies a specific home server pool to proxy to.
- *   - PW_PACKET_DST_IP_ADDRESS   - Specifies a specific IPv4 home server to proxy to.
- *   - PW_PACKET_DST_IPV6_ADDRESS - Specifies a specific IPv6 home server to proxy to.
+ *   - PW_HOME_SERVER_NAME        - Specifies a home server by name
+ *   - PW_PACKET_DST_IP_ADDRESS   - Specifies a home server by IPv4 address
+ *   - PW_PACKET_DST_IPV6_ADDRESS - Specifies a home server by IPv5 address
  *
  * Certain packet types such as #PW_CODE_STATUS_SERVER will never be proxied.
  *
@@ -3073,6 +3074,54 @@ static int request_will_proxy(REQUEST *request)
 
                return 0;
 
+       } else if ((vp = fr_pair_find_by_num(request->config, PW_HOME_SERVER_NAME, 0, TAG_ANY)) != NULL) {
+               int type;
+
+               switch (request->packet->code) {
+               case PW_CODE_ACCESS_REQUEST:
+                       type = HOME_TYPE_AUTH;
+                       break;
+
+#ifdef WITH_ACCOUNTING
+               case PW_CODE_ACCOUNTING_REQUEST:
+                       type = HOME_TYPE_ACCT;
+                       break;
+#endif
+
+#ifdef WITH_COA
+               case PW_CODE_COA_REQUEST:
+               case PW_CODE_DISCONNECT_REQUEST:
+                       type = HOME_TYPE_COA;
+                       break;
+#endif
+
+               default:
+                       return 0;
+               }
+
+               /*
+                *      Find the home server by name.
+                */
+               home = home_server_byname(vp->vp_strvalue, type);
+               if (!home) {
+                       RWDEBUG("No such home server %s", vp->vp_strvalue);
+                       return 0;
+               }
+
+               /*
+                *      The home server is alive (or may be alive).
+                *      Send the packet to the IP.
+                */
+               if (home->state < HOME_STATE_IS_DEAD) goto do_home;
+
+               /*
+                *      The home server is dead.  If you wanted
+                *      fail-over, you should have proxied to a pool.
+                *      Sucks to be you.
+                */
+
+               return 0;
+
        } else {
                return 0;
        }