From: Alan T. DeKok Date: Sun, 19 Apr 2020 17:44:44 +0000 (-0400) Subject: allow proxying to home servers by name X-Git-Tag: release_3_0_22~606 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=953caec228f8d0fce4839dbde36974a6d53b2af7;p=thirdparty%2Ffreeradius-server.git allow proxying to home servers by name --- diff --git a/share/dictionary.freeradius.internal b/share/dictionary.freeradius.internal index 724e1f7ff67..644b0404259 100644 --- a/share/dictionary.freeradius.internal +++ b/share/dictionary.freeradius.internal @@ -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 diff --git a/src/main/process.c b/src/main/process.c index fcd0a0ad061..3d24a3673a9 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -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; }