forked from anjuke/qqwry-daemon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqqwry-test.php
43 lines (38 loc) · 914 Bytes
/
qqwry-test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$ip = "250.197.214.126";
$location = getLocation($ip);
echo "$ip - $location\n";
function getLocation($ip) {
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
$ret = socket_connect($socket, "/tmp/qqwry.sock");
if (!$ret) {
return "ERROR";
}
$ret = socket_write($socket, "$ip\n");
if (!$ret) {
return "ERROR";
}
$read = socket_read($socket, 1024);
socket_close($socket);
return $read;
}
function getMicrotimeFloat()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$i = 0;
$time = getMicrotimeFloat();
while (true) {
$a = rand(0, 255);
$b = rand(0, 255);
$c = rand(0, 255);
$d = rand(0, 255);
$ip = "$a.$b.$c.$d";
$location = getLocation($ip);
$i++;
$etime = getMicrotimeFloat() - $time;
$time = getMicrotimeFloat();
echo "$i - $etime - $ip - $location\n";
}
?>