146 lines
9.3 KiB
HTML
146 lines
9.3 KiB
HTML
|
|
||
|
|
||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
|
||
|
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
|
||
|
<title>List Circuits — Stem 1.8.1-maint documentation</title>
|
||
|
|
||
|
<link rel="stylesheet" href="../../_static/haiku.css" type="text/css" />
|
||
|
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||
|
<link rel="stylesheet" href="../../_static/style.css" type="text/css" />
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
var DOCUMENTATION_OPTIONS = {
|
||
|
URL_ROOT: '../../',
|
||
|
VERSION: '1.8.1-maint',
|
||
|
COLLAPSE_INDEX: false,
|
||
|
FILE_SUFFIX: '.html',
|
||
|
HAS_SOURCE: true
|
||
|
};
|
||
|
</script>
|
||
|
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||
|
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||
|
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||
|
<link rel="shortcut icon" href="../../_static/favicon.png"/>
|
||
|
<link rel="top" title="Stem 1.8.1-maint documentation" href="../../index.html" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="header"><img class="rightlogo" src="../../_static/logo.png" alt="Logo"/><h1 class="heading"><a href="../../index.html">
|
||
|
<span>Stem Docs</span></a></h1>
|
||
|
<h2 class="heading"><span>List Circuits</span></h2>
|
||
|
</div>
|
||
|
<div class="topnav">
|
||
|
|
||
|
<p>
|
||
|
|
||
|
<ul id="navbar">
|
||
|
<li><a href="../../index.html">Home</a></li>
|
||
|
<li><a href="../../tutorials.html">Tutorials</a>
|
||
|
<ul>
|
||
|
<li><a href="../the_little_relay_that_could.html">Hello World</a></li>
|
||
|
<li><a href="../to_russia_with_love.html">Client Usage</a></li>
|
||
|
<li><a href="../tortoise_and_the_hare.html">Event Listening</a></li>
|
||
|
<li><a href="../over_the_river.html">Hidden Services</a></li>
|
||
|
<li><a href="../mirror_mirror_on_the_wall.html">Tor Descriptors</a></li>
|
||
|
<li><a href="../east_of_the_sun.html">Utilities</a></li>
|
||
|
<li><a href="../down_the_rabbit_hole.html">Interpreter</a></li>
|
||
|
<li><a href="../double_double_toil_and_trouble.html">Examples</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
<li><a href="../../api.html">API</a>
|
||
|
<ul>
|
||
|
<li><a href="../../api/control.html">stem.control</a></li>
|
||
|
<li><a href="../../api/connection.html">stem.connection</a></li>
|
||
|
<li><a href="../../api/socket.html">stem.socket</a></li>
|
||
|
<li><a href="../../api/process.html">stem.process</a></li>
|
||
|
<li><a href="../../api/response.html">stem.response</a></li>
|
||
|
<li><a href="../../api/exit_policy.html">stem.exit_policy</a></li>
|
||
|
<li><a href="../../api/version.html">stem.version</a></li>
|
||
|
<li><a href="../../api.html#descriptors">Descriptors</a></li>
|
||
|
<li><a href="../../api.html#utilities">Utilities</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
<li><a href="https://trac.torproject.org/projects/tor/wiki/doc/stem">Development</a>
|
||
|
<ul>
|
||
|
<li><a href="../../faq.html">FAQ</a></li>
|
||
|
<li><a href="../../change_log.html">Change Log</a></li>
|
||
|
<li><a href="https://github.com/torproject/stem/issues/">Bug Tracker</a></li>
|
||
|
<li><a href="https://jenkins.torproject.org/job/stem-tor-ci/">Jenkins</a></li>
|
||
|
<li><a href="../../download.html">Download</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
<li><a href="../../faq.html#where-can-i-get-help">Contact</a>
|
||
|
<ul>
|
||
|
<li><a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev">Email List</a></li>
|
||
|
<li><a href="https://www.torproject.org/about/contact.html.en#irc">IRC</a></li>
|
||
|
<li><a href="https://www.atagar.com/contact/">Author</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
<div class="content">
|
||
|
|
||
|
|
||
|
<div class="section" id="list-circuits">
|
||
|
<h1>List Circuits<a class="headerlink" href="#list-circuits" title="Permalink to this headline">¶</a></h1>
|
||
|
<a class="reference external image-reference" href="../double_double_toil_and_trouble.html"><img alt="../../_images/back.png" src="../../_images/back.png" /></a>
|
||
|
<p>Tor creates new circuits and tears down old ones on your behalf, so how can you
|
||
|
get information about circuits Tor currently has available?</p>
|
||
|
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">stem</span> <span class="kn">import</span> <span class="n">CircStatus</span>
|
||
|
<span class="kn">from</span> <span class="nn">stem.control</span> <span class="kn">import</span> <span class="n">Controller</span>
|
||
|
|
||
|
<span class="k">with</span> <span class="n">Controller</span><span class="o">.</span><span class="n">from_port</span><span class="p">(</span><span class="n">port</span> <span class="o">=</span> <span class="mi">9051</span><span class="p">)</span> <span class="k">as</span> <span class="n">controller</span><span class="p">:</span>
|
||
|
<span class="n">controller</span><span class="o">.</span><span class="n">authenticate</span><span class="p">()</span>
|
||
|
|
||
|
<span class="k">for</span> <span class="n">circ</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">controller</span><span class="o">.</span><span class="n">get_circuits</span><span class="p">()):</span>
|
||
|
<span class="k">if</span> <span class="n">circ</span><span class="o">.</span><span class="n">status</span> <span class="o">!=</span> <span class="n">CircStatus</span><span class="o">.</span><span class="n">BUILT</span><span class="p">:</span>
|
||
|
<span class="k">continue</span>
|
||
|
|
||
|
<span class="k">print</span><span class="p">(</span><span class="s">""</span><span class="p">)</span>
|
||
|
<span class="k">print</span><span class="p">(</span><span class="s">"Circuit </span><span class="si">%s</span><span class="s"> (</span><span class="si">%s</span><span class="s">)"</span> <span class="o">%</span> <span class="p">(</span><span class="n">circ</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="n">circ</span><span class="o">.</span><span class="n">purpose</span><span class="p">))</span>
|
||
|
|
||
|
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">circ</span><span class="o">.</span><span class="n">path</span><span class="p">):</span>
|
||
|
<span class="n">div</span> <span class="o">=</span> <span class="s">'+'</span> <span class="k">if</span> <span class="p">(</span><span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">circ</span><span class="o">.</span><span class="n">path</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="k">else</span> <span class="s">'|'</span>
|
||
|
<span class="n">fingerprint</span><span class="p">,</span> <span class="n">nickname</span> <span class="o">=</span> <span class="n">entry</span>
|
||
|
|
||
|
<span class="n">desc</span> <span class="o">=</span> <span class="n">controller</span><span class="o">.</span><span class="n">get_network_status</span><span class="p">(</span><span class="n">fingerprint</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
|
||
|
<span class="n">address</span> <span class="o">=</span> <span class="n">desc</span><span class="o">.</span><span class="n">address</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="s">'unknown'</span>
|
||
|
|
||
|
<span class="k">print</span><span class="p">(</span><span class="s">" </span><span class="si">%s</span><span class="s">- </span><span class="si">%s</span><span class="s"> (</span><span class="si">%s</span><span class="s">, </span><span class="si">%s</span><span class="s">)"</span> <span class="o">%</span> <span class="p">(</span><span class="n">div</span><span class="p">,</span> <span class="n">fingerprint</span><span class="p">,</span> <span class="n">nickname</span><span class="p">,</span> <span class="n">address</span><span class="p">))</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<div class="highlight-python"><pre>% python list_circuits.py
|
||
|
|
||
|
Circuit 4 (GENERAL)
|
||
|
|- B1FA7D51B8B6F0CB585D944F450E7C06EDE7E44C (ByTORAndTheSnowDog, 173.209.180.61)
|
||
|
|- 0DD9935C5E939CFA1E07B8DDA6D91C1A2A9D9338 (afo02, 87.238.194.176)
|
||
|
+- DB3B1CFBD3E4D97B84B548ADD5B9A31451EEC4CC (edwardsnowden3, 109.163.234.10)
|
||
|
|
||
|
Circuit 6 (GENERAL)
|
||
|
|- B1FA7D51B8B6F0CB585D944F450E7C06EDE7E44C (ByTORAndTheSnowDog, 173.209.180.61)
|
||
|
|- EC01CB4766BADC1611678555CE793F2A7EB2D723 (sprockets, 46.165.197.96)
|
||
|
+- 9EA317EECA56BDF30CAEB208A253FB456EDAB1A0 (bolobolo1, 96.47.226.20)
|
||
|
|
||
|
Circuit 10 (GENERAL)
|
||
|
|- B1FA7D51B8B6F0CB585D944F450E7C06EDE7E44C (ByTORAndTheSnowDog, 173.209.180.61)
|
||
|
|- 00C2C2A16AEDB51D5E5FB7D6168FC66B343D822F (ph3x, 86.59.119.83)
|
||
|
+- 65242C91BFF30F165DA4D132C81A9EBA94B71D62 (torexit16, 176.67.169.171)</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
<div class="bottomnav">
|
||
|
</div>
|
||
|
|
||
|
<div class="footer">
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|