获取用户真实IP问题
我使用下面程序查询用户真实IP,Stringsip="";Stringsmac="";sip=request.getHeader("x-forwarded-for");i...
我使用下面程序查询用户真实IP,
String sip="";
String smac="";
sip = request.getHeader("x-forwarded-for");
if(sip == null || sip.length() == 0|| "unknown".equalsIgnoreCase(sip)) {
sip = request.getHeader("Proxy-Client-IP");
}
if(sip == null || sip.length() == 0 || "unknown".equalsIgnoreCase(sip)) {
sip = request.getHeader("WL-Proxy-Client-IP");
}
if(sip == null || sip.length() == 0 || "unknown".equalsIgnoreCase(sip)) {
sip = request.getRemoteAddr();
}
if(!"127.0.0.1".equals(sip)) //本机过滤掉
{
Process process = Runtime.getRuntime().exec("nbtstat -a " + sip);
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
while ((line = input.readLine()) != null)
if (line.indexOf("MAC Address") > 0)
{
smac = line.substring(line.indexOf("-") - 2);
}
}
但是得到的IP一直都是127.0.0.1,这个是什么原因啊? 展开
String sip="";
String smac="";
sip = request.getHeader("x-forwarded-for");
if(sip == null || sip.length() == 0|| "unknown".equalsIgnoreCase(sip)) {
sip = request.getHeader("Proxy-Client-IP");
}
if(sip == null || sip.length() == 0 || "unknown".equalsIgnoreCase(sip)) {
sip = request.getHeader("WL-Proxy-Client-IP");
}
if(sip == null || sip.length() == 0 || "unknown".equalsIgnoreCase(sip)) {
sip = request.getRemoteAddr();
}
if(!"127.0.0.1".equals(sip)) //本机过滤掉
{
Process process = Runtime.getRuntime().exec("nbtstat -a " + sip);
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
while ((line = input.readLine()) != null)
if (line.indexOf("MAC Address") > 0)
{
smac = line.substring(line.indexOf("-") - 2);
}
}
但是得到的IP一直都是127.0.0.1,这个是什么原因啊? 展开
Storm代理
2023-07-25 广告
2023-07-25 广告
StormProxies是一家国内优质海外HTTP代理商,拥有一个庞大的IP资源池,覆盖200多个地区,IP数量大且匿名度高。其优点还包括超高并发、稳定高效、技术服务等特点,同时提供HTTP、HTTPS以及SOCKS5协议支持。此外,Sto...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询