且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

代理检测

更新时间:2022-06-20 09:01:03

除非您使用的是Google缓存之类的代理,否则代理不会更改浏览器所请求页面的地址.代理仅接受您的请求,为您获取请求中任何地址的内容,然后将答复转发给您的计算机.它绝对不会更改地址,因为那意味着您所请求的不是您所得到的.

A proxy doesn't change the address of the page your browser's requesting, unless you're using something like Google cache. The proxy simply accepts your request, fetches the contents of whatever address is in the request for you, and forwards the reply to your machine. At no point should it change the address, as that'd mean what you've requested is not what you're getting.

如果Java中提供了本地IP,则可以简单地检查请求来自的地址是否与Java中检测到的地址匹配,但是Java无法处理该底层网络概念.一个签名的Java applet可以,也可以是Flash/Silverlight applet,尽管我只是在猜测那些.

If the local IP was available in Javascript, you could trivially check that the address the request comes from matches the address detected in Javascript, but Javascript cannot deal with that low-level a networking concept. A signed Java applet could, and maybe a Flash/Silverlight applet as well, though I'm just guessing on those.

但是,使用家庭宽带路由器这样的琐碎检查IP地址也会失败. 本地" IP很可能类似于10.0.0.13,但是您的站点将检测到该请求来自路由器的外部地址.没有涉及代理",只是一个NAT网关,但是请求IP!=客户端IP,哇,您被代理了,伙计!

But checking IP addresses will fail as well with something as trivial as a home broadband router. The "local" IP could very well be something like 10.0.0.13, but your site will detect the request as coming from whatever the router's external address is. There's no "proxy" involved, simply a NAT gateway, but request IP != client IP and woah, you're proxied, dude!

最可靠(但仍然不是特别可靠)的方法是检查各种代理标头,例如X-Forwarded-For.

The most reliable (and still not particularly reliable at all) method is to check for the various proxy headers, such as X-Forwarded-For.