fsockopen 的替代品 - (非常慢)?
有谁知道 @fsockopen 的替代品吗?我正在尝试检测代理 - 用户访问网站,获取用户 IP 地址,然后使用 @fsockopen 来查看他们是否正在使用特定端口。使用此功能是迄今为止最可靠的检测方法,除了禁止特定 IP / IP 模式。然而,它的速度非常慢,对于访问我的网站的用户来说是不可接受的。还有其他选择,或者有办法让它更快吗?并且将函数超时设置为 1 秒也无济于事:P。
示例代码:
if ( $sock = @fsockopen($ _server['REMOTE_ADDR'], 80, $errno, $errst, 1) ) { echo "proxy!"; }
curl 可以实现这样的功能吗?
提前致谢!
Does anyone know an alternative to @fsockopen? I'm trying to detect proxies -- user hits site, grab users IP address, then use @fsockopen to see if they are using a specific port.Using this function is BY FAR the most reliable for detecting, outside of banning specific IPs / IP Patterns. However, it's very slow and un-acceptable for users visiting my site. Is there any other options, or a way to make it faster? And no setting the timeout of the function to 1 second doesn't help :P.
Example code:
if ( $sock = @fsockopen($ _server['REMOTE_ADDR'], 80, $errno, $errst, 1) ) { echo "proxy!"; }
Can curl achieve something like this?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试
$_SERVER['HTTP_X_FORWARDED_FOR']
:它比您当前的方法更快、更准确。
Test for
$_SERVER['HTTP_X_FORWARDED_FOR']
:It's faster and more accurate than your current method.