stem_examples/docs/outdated_relays.html
emdee@spm.plastiras.org e41515a8a7 second
2024-01-14 14:28:53 +00:00

139 lines
8.0 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 Outdated Relays &mdash; 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 Outdated Relays</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-outdated-relays">
<h1>List Outdated Relays<a class="headerlink" href="#list-outdated-relays" 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>Time marches on. Tor makes new releases, and at some point needs to drop
support for old ones. Below is the script we used on <a class="reference external" href="https://trac.torproject.org/9476">ticket 9476</a> to reach out
to relay operators that needed to upgrade.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">stem.descriptor.remote</span> <span class="kn">import</span> <span class="n">DescriptorDownloader</span>
<span class="kn">from</span> <span class="nn">stem.version</span> <span class="kn">import</span> <span class="n">Version</span>
<span class="n">downloader</span> <span class="o">=</span> <span class="n">DescriptorDownloader</span><span class="p">()</span>
<span class="n">count</span><span class="p">,</span> <span class="n">with_contact</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span>
<span class="k">print</span><span class="p">(</span><span class="s">&quot;Checking for outdated relays...&quot;</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s">&quot;&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">desc</span> <span class="ow">in</span> <span class="n">downloader</span><span class="o">.</span><span class="n">get_server_descriptors</span><span class="p">():</span>
<span class="k">if</span> <span class="n">desc</span><span class="o">.</span><span class="n">tor_version</span> <span class="o">&lt;</span> <span class="n">Version</span><span class="p">(</span><span class="s">&#39;0.2.3.0&#39;</span><span class="p">):</span>
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">if</span> <span class="n">desc</span><span class="o">.</span><span class="n">contact</span><span class="p">:</span>
<span class="k">print</span><span class="p">(</span><span class="s">&#39; </span><span class="si">%-15s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">desc</span><span class="o">.</span><span class="n">tor_version</span><span class="p">,</span> <span class="n">desc</span><span class="o">.</span><span class="n">contact</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s">&quot;utf-8&quot;</span><span class="p">,</span> <span class="s">&quot;replace&quot;</span><span class="p">)))</span>
<span class="n">with_contact</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">print</span><span class="p">(</span><span class="s">&quot;&quot;</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%i</span><span class="s"> outdated relays found, </span><span class="si">%i</span><span class="s"> had contact information&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">count</span><span class="p">,</span> <span class="n">with_contact</span><span class="p">))</span>
</pre></div>
</div>
<div class="highlight-python"><pre>% python outdated_relays.py
Checking for outdated relays...
0.2.2.39 Random Person admin@gtr-10.de
0.2.2.36 dobrovich_psckaal at vietrievus dot ok
0.2.2.39 anonymous6 anonymous@mailinator.com
0.2.2.39 anonymous12 anonymous@mailinator.com
...
316 outdated relays found, 120 had contact information</pre>
</div>
</div>
</div>
<div class="bottomnav">
</div>
<div class="footer">
</div>
</body>
</html>