401904 fixed getRemoteAddr to return IP instead of hostname

This commit is contained in:
Greg Wilkins 2013-03-04 17:10:27 +11:00
parent 41f7df18a6
commit 3bc0411e65
1 changed files with 15 additions and 3 deletions

View File

@ -702,7 +702,12 @@ public class Request implements HttpServletRequest
public String getLocalAddr()
{
InetSocketAddress local=_channel.getLocalAddress();
return local.getAddress().getHostAddress();
if (local==null)
return "";
InetAddress address = local.getAddress();
if (address==null)
return local.getHostString();
return address.getHostAddress();
}
/* ------------------------------------------------------------ */
@ -918,8 +923,15 @@ public class Request implements HttpServletRequest
InetSocketAddress remote=_remote;
if (remote==null)
remote=_channel.getRemoteAddress();
return remote==null?"":remote.getHostString();
if (remote==null)
return "";
InetAddress address = remote.getAddress();
if (address==null)
return remote.getHostString();
return address.getHostAddress();
}
/* ------------------------------------------------------------ */