forked from TheBlueMatt/dnsseed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitcoin-scan.php
executable file
·61 lines (48 loc) · 1.17 KB
/
bitcoin-scan.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/php
<?php
require("config.php");
require("bitcoin-node.php");
require("global.php");
if ($argc != 2)
exit;
$arr = explode(":", $argv[1]);
if (count($arr) > 2 || count($arr) == 0)
exit;
$port = count($arr)==1 ? 8333 : $arr[1];
try {
$origNode = new Bitcoin\Node($arr[0], $port, $CONFIG['CONNECT_TIMEOUT']);
$origNode->getAddr();
$nodes = $origNode->getAddr();
if (!empty($nodes)) {
start_db_transaction();
add_node_to_dns($arr[0], $port, $origNode->getVersion());
foreach ($nodes as &$node) {
if ($node["services1"] == 1 && $node["services2"] == 0 && $node["timestamp"] >= time() - $CONFIG['MIN_LAST_SEEN'])
add_untested_node($node["ipv4"], $node["port"]);
}
commit_db_transaction();
}else{
start_db_transaction();
remove_node($arr[0], $port);
commit_db_transaction();
}
} catch (Exception $e) {
start_db_transaction();
remove_node($arr[0], $port);
commit_db_transaction();
}
exit;
/*
$c = new Node('127.0.0.1');
var_dump($c->getVersionStr());
echo "completed, waiting...\n";
var_dump($c->getAddr());
while(true) {
$pkt = $c->readPacket();
if ($pkt) {
echo $pkt['type'].': '.bin2hex($pkt['payload'])."\n";
} else {
exit;
}
}*/
?>