echo "Failed to create Tor control connection: " . $ex->getMessage() . "\n"; exit; } // ask controller for tor version $ver = $tc->getVersion(); echo "*** Connected ***\n*** Controller is running Tor {$ver} ***\n"; 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;