Esempio n. 1
0
try {
    // get tor node's external ip, if known.
    // If Tor could not determine IP, an exception is thrown
    $address = $tc->getInfoAddress();
} catch (ProtocolError $pex) {
    $address = 'Unknown';
}
try {
    // get router fingerprint (if any) - clients will not have a fingerprint
    $fingerprint = $tc->getInfoFingerprint();
} catch (ProtocolError $pex) {
    $fingerprint = $pex->getMessage();
}
echo sprintf("*** Controller IP Address: %s  / Fingerprint: %s ***\n", $address, $fingerprint);
// ask controller how many bytes Tor has transferred
$read = $tc->getInfoTrafficRead();
$writ = $tc->getInfoTrafficWritten();
echo sprintf("*** Tor traffic (read / written): %s / %s ***\n", humanFilesize($read), humanFilesize($writ));
echo "\n";
try {
    // fetch info for this descriptor from controller
    $descriptor = $tc->getInfoDescriptor('drew010relay01');
    // if descriptor found, query directory info to get flags
    $dirinfo = $tc->getInfoDirectoryStatus($descriptor->fingerprint);
    echo "== Descriptor Info ==\n" . "Nickname      : {$descriptor->nickname}\n" . "Fingerprint   : {$descriptor->fingerprint}\n" . "Running       : {$descriptor->platform}\n" . "Uptime        : " . uptimeToString($descriptor->getCurrentUptime(), false) . "\n" . "OR Address(es): " . $descriptor->ip_address . ':' . $descriptor->or_port;
    if (sizeof($descriptor->or_address) > 0) {
        echo ', ' . implode(', ', $descriptor->or_address);
    }
    echo "\n" . "Contact       : {$descriptor->contact}\n" . "BW (observed) : " . number_format($descriptor->bandwidth_observed) . " B/s\n" . "BW (average)  : " . number_format($descriptor->bandwidth_average) . " B/s\n" . "Flags         : " . implode(' ', $dirinfo->flags) . "\n\n";
} catch (ProtocolError $pe) {
    // doesn't necessarily mean the node doesn't exist