使用给定的代码段时,只会收到“目标无法访问”的回复(处理程序是来自https://github.com/volftomas/pyicmp的pyicmp.handler.Handler):
$return = array();
if (!empty($contacts['feed']['entry'])) {
foreach($contacts['feed']['entry'] as $contact) {
//retrieve user photo
if (isset($contact['link'][0]['href'])) {
$url = $contact['link'][0]['href'];
$url = $url . '&access_token=' . urlencode($accesstoken);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_VERBOSE, true);
$image = curl_exec($curl);
curl_close($curl);
}
$return[] = array (
'name'=> $contact['title']['$t'],
'email' => $contact['gd$email'][0]['address'],
'image' =>$image,
);
}
}
foreach ($return as $contact) {
$image=$contact['image'];
echo $image;?>
<br> <br> <br>
<img src="data:image/jpeg;base64,<?php echo $image ?>" /> <br>;
<?php
}
有些主机发送目标无法访问,其他主机阻止回应请求,我无法共享dumpfile因为dumpfile我现在拥有公司机构的IP映射。我可以通过Windows的def IPScanner(handler, ip, file, lock):
for ttl in (32,):
# putting 32 in a tuple was necessary here,
# otherwise do_ping() acts as a noop
ctr = 0
for j in range(0,4):
t = PrintThread(str("Dest:" + ip + " TTL" + str(ttl)), lock)
t.start()
ping_result = handler.do_ping(ip, ttl)
if ping_result['packet_loss'] == 0:
ping_result['packet_loss'] = j
break
else:
ping_result['packet_loss'] = 0
d = DumpFileThread(file, ping_result, lock)
d.start()
ping传递给该函数的IP。为什么我不能从pyicmp库接收ping。我的主机上没有阻止ICMP echo。