Take routing table into account when figuring out which IP address to use for talking to CP clients.

This commit is contained in:
jim-p 2011-12-22 10:03:49 -05:00
parent e2939b79f7
commit f86fa91cf9

View File

@ -1571,6 +1571,14 @@ function portal_ip_from_client_ip($cliip) {
return $ip;
}
$iface = exec_command("/sbin/route -n get {$cliip} | /usr/bin/awk '/interface/ { print \$2; };'");
$iface = trim($iface, "\n");
if (!empty($iface)) {
$ip = find_interface_ip($iface);
if (is_ipaddr($ip))
return $ip;
}
// doesn't match up to any particular interface
// so let's set the portal IP to what PHP says
// the server IP issuing the request is.