From 6a53de6f7e4d94a67bfdc482f347a475ef1b747f Mon Sep 17 00:00:00 2001 From: NewEraCracker Date: Fri, 18 Mar 2016 16:22:51 +0000 Subject: [PATCH] Fix Redmine #6011 This will add linklocal fallback where no IPv6 is otherwise configured to allow login using this IPs --- src/etc/inc/auth.inc | 3 ++- src/etc/inc/interfaces.inc | 4 ++-- src/etc/inc/util.inc | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/etc/inc/auth.inc b/src/etc/inc/auth.inc index bb42ca2bb7..36cc1518d7 100644 --- a/src/etc/inc/auth.inc +++ b/src/etc/inc/auth.inc @@ -205,8 +205,9 @@ if (function_exists("display_error_form") && !isset($config['system']['webgui'][ break; } } - $interface_list_ipv6s = get_configured_ipv6_addresses(); + $interface_list_ipv6s = get_configured_ipv6_addresses(true); foreach ($interface_list_ipv6s as $ilipv6s) { + $ilipv6s = explode('%', $ilipv6s)[0]; if (strcasecmp($referrer_host, $ilipv6s) == 0) { $found_host = true; break; diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 0d1edb13e4..3133ebfe90 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -5376,7 +5376,7 @@ function get_interface_ip($interface = "wan") { } } -function get_interface_ipv6($interface = "wan", $flush = false) { +function get_interface_ipv6($interface = "wan", $flush = false, $linklocal_fallback = false) { global $config; if (substr($interface, 0, 4) == '_vip') { @@ -5425,7 +5425,7 @@ function get_interface_ipv6($interface = "wan", $flush = false) { * NOTE: On the case when only the prefix is requested, * the communication on WAN will be done over link-local. */ - if (is_array($config['interfaces'][$interface]) && isset($config['interfaces'][$interface]['dhcp6prefixonly'])) { + if ($linklocal_fallback || (is_array($config['interfaces'][$interface]) && isset($config['interfaces'][$interface]['dhcp6prefixonly']))) { $curip = find_interface_ipv6_ll($realif, $flush); if ($curip && is_ipaddrv6($curip) && ($curip != "::")) { return $curip; diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 171483ead0..582c0398e6 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -1469,13 +1469,13 @@ function get_configured_ip_addresses() { * IPv6 addresses. * */ -function get_configured_ipv6_addresses() { +function get_configured_ipv6_addresses($linklocal_fallback = false) { require_once("interfaces.inc"); $ipv6_array = array(); $interfaces = get_configured_interface_list(); if (is_array($interfaces)) { foreach ($interfaces as $int) { - $ipaddrv6 = get_interface_ipv6($int); + $ipaddrv6 = get_interface_ipv6($int, false, $linklocal_fallback); $ipv6_array[$int] = $ipaddrv6; } }