【发布时间】:2021-12-27 08:45:16
【问题描述】:
需要将所有 Tor 用户从我的页面转发出去,并在 Tor 列表中检查 ip。 单项检查适用于 ipv4,但不适用于 ipv6 和多个列表检查。 无法理解我在哪里得到错误。 代码:
$torip = file("https://check.torproject.org/torbulkexitlist", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$torexits = file("https://lists.fissionrelays.net/tor/exits-ipv6.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$tornode = file("https://lists.fissionrelays.net/tor/relays-ipv6.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$client_ip = $_SERVER['REMOTE_ADDR'];
if (in_array($client_ip, $torip)){
header('Location: https://www.google.com/');
}
if (in_array($client_ip, $tornode)){
header('Location: https://www.google.com/');
}
if (in_array($client_ip, $torexits)){
header('Location: https://www.google.com/');
}
正在尝试不同的方式
if(in_array($client_ip, $torip) or in_array($client_ip, $tornode) or in_array($client_ip, $torexits))
如果 ... elseif .. elseif
same 可以通过 tor 进入列表中的 ip 并且无法理解问题出在哪里。 感谢大家的帮助。
UDP: 代码部分
$tornode = file("https://lists.fissionrelays.net/tor/relays-ipv6.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$client_ip = $_SERVER['REMOTE_ADDR'];
if (in_array($client_ip, $tornode)){
header('Location: https://www.google.com/');
die();
}
工作 100% - 问题 - 如何以正确的方式添加其他列表?
【问题讨论】:
-
$torip $tornode $torexits的结果是什么?是数组吗?如果它的数组为什么不循环遍历它并在标题位置之前进行验证 -
@AtoliGaming -
file()将始终返回一个数组,其中每一行作为一个元素(如果发生错误,则返回 false)。为什么他们需要遍历它们?他们正在使用in_array()来检查客户端的IP 是否在每个数组中。 -
对不起,我弄错了你的目标,所以你只需要检查数组是否存在。 ipv6 和多列表检查的结果是什么?
-
我们需要将所有的 Tor 用户(从列表中获得 ip 的用户)转发离开我们的网页
-
当您测试代码时,client-ip 实际上是否在这些 IP 地址列表中?也就是说,您的代码是否正常工作,也许列表不正确?