<!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>Tor Utilities — Stem 1.1.0 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/print.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '1.1.0', 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> <script type="text/javascript" src="../../_static/theme_extras.js"></script> <link rel="shortcut icon" href="../../_static/favicon.png"/> <link rel="top" title="Stem 1.1.0 documentation" href="../../index.html" /> <link rel="up" title="Contents" href="../../contents.html" /> <link rel="prev" title="Terminal Utilities" href="term.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>Tor Utilities</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="../../tutorials/the_little_relay_that_could.html">Hello World</a></li> <li><a href="../../tutorials/to_russia_with_love.html">Client Usage</a></li> <li><a href="../../tutorials/tortoise_and_the_hare.html">Event Listening</a></li> <li><a href="../../tutorials/mirror_mirror_on_the_wall.html">Tor Descriptors</a></li> <li><a href="../../tutorials/east_of_the_sun.html">Utilities</a></li> <li><a href="../../tutorials/double_double_toil_and_trouble.html">Examples</a></li> </ul> </li> <li><a href="../../api.html">API</a> <ul> <li><a href="../control.html">stem.control</a></li> <li><a href="../connection.html">stem.connection</a></li> <li><a href="../socket.html">stem.socket</a></li> <li><a href="../process.html">stem.process</a></li> <li><a href="../response.html">stem.response</a></li> <li><a href="../exit_policy.html">stem.exit_policy</a></li> <li><a href="../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://trac.torproject.org/projects/tor/wiki/doc/stem/bugs">Bug Tracker</a></li> <li><a href="../../download.html">Download</a></li> </ul> </li> </ul> </p> </div> <div class="content"> <div class="section" id="module-stem.util.tor_tools"> <span id="tor-utilities"></span><h1>Tor Utilities<a class="headerlink" href="#module-stem.util.tor_tools" title="Permalink to this headline">¶</a></h1> <p>Miscellaneous utility functions for working with tor.</p> <p><strong>These functions are not being vended to stem users. They may change in the future, use them at your own risk.</strong></p> <p><strong>Module Overview:</strong></p> <div class="highlight-python"><pre>is_valid_fingerprint - checks if a string is a valid tor relay fingerprint is_valid_nickname - checks if a string is a valid tor relay nickname is_valid_circuit_id - checks if a string is a valid tor circuit id is_valid_stream_id - checks if a string is a valid tor stream id is_hex_digits - checks if a string is only made up of hex digits</pre> </div> <dl class="function"> <dt id="stem.util.tor_tools.is_valid_fingerprint"> <tt class="descclassname">stem.util.tor_tools.</tt><tt class="descname">is_valid_fingerprint</tt><big>(</big><em>entry</em>, <em>check_prefix=False</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/tor_tools.html#is_valid_fingerprint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.tor_tools.is_valid_fingerprint" title="Permalink to this definition">¶</a></dt> <dd><p>Checks if a string is a properly formatted relay fingerprint. This checks for a ‘$’ prefix if check_prefix is true, otherwise this only validates the hex digits.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>entry</strong> (<em>str</em>) – string to be checked</li> <li><strong>check_prefix</strong> (<em>bool</em>) – checks for a ‘$’ prefix</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><strong>True</strong> if the string could be a relay fingerprint, <strong>False</strong> otherwise</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="stem.util.tor_tools.is_valid_nickname"> <tt class="descclassname">stem.util.tor_tools.</tt><tt class="descname">is_valid_nickname</tt><big>(</big><em>entry</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/tor_tools.html#is_valid_nickname"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.tor_tools.is_valid_nickname" title="Permalink to this definition">¶</a></dt> <dd><p>Checks if a string is a valid format for being a nickname.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>entry</strong> (<em>str</em>) – string to be checked</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> if the string could be a nickname, <strong>False</strong> otherwise</td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="stem.util.tor_tools.is_valid_circuit_id"> <tt class="descclassname">stem.util.tor_tools.</tt><tt class="descname">is_valid_circuit_id</tt><big>(</big><em>entry</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/tor_tools.html#is_valid_circuit_id"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.tor_tools.is_valid_circuit_id" title="Permalink to this definition">¶</a></dt> <dd><p>Checks if a string is a valid format for being a circuit identifier.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> if the string could be a circuit id, <strong>False</strong> otherwise</td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="stem.util.tor_tools.is_valid_stream_id"> <tt class="descclassname">stem.util.tor_tools.</tt><tt class="descname">is_valid_stream_id</tt><big>(</big><em>entry</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/tor_tools.html#is_valid_stream_id"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.tor_tools.is_valid_stream_id" title="Permalink to this definition">¶</a></dt> <dd><p>Checks if a string is a valid format for being a stream identifier. Currently, this is just an alias to <a class="reference internal" href="#stem.util.tor_tools.is_valid_circuit_id" title="stem.util.tor_tools.is_valid_circuit_id"><tt class="xref py py-func docutils literal"><span class="pre">is_valid_circuit_id()</span></tt></a>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> if the string could be a stream id, <strong>False</strong> otherwise</td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="stem.util.tor_tools.is_hex_digits"> <tt class="descclassname">stem.util.tor_tools.</tt><tt class="descname">is_hex_digits</tt><big>(</big><em>entry</em>, <em>count</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/tor_tools.html#is_hex_digits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.tor_tools.is_hex_digits" title="Permalink to this definition">¶</a></dt> <dd><p>Checks if a string is the given number of hex digits. Digits represented by letters are case insensitive.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>entry</strong> (<em>str</em>) – string to be checked</li> <li><strong>count</strong> (<em>int</em>) – number of hex digits to be checked for</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><strong>True</strong> if the string matches this number</p> </td> </tr> </tbody> </table> </dd></dl> </div> </div> <div class="bottomnav"> </div> <div class="footer"> </div> </body> </html>