refreshed and renamed docs, added bootstrap server, added default config for sec auditing

This commit is contained in:
Kevin Froman 2020-02-04 14:46:17 -06:00
parent fe36b87c57
commit 6960d9209d
270 changed files with 20816 additions and 8345 deletions

View file

@ -0,0 +1,160 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.banblocks API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.banblocks</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>This file contains the command for banning blocks from the node</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
This file contains the command for banning blocks from the node
&#34;&#34;&#34;
import sys
import logger
from onionrutils import stringvalidators
from onionrstorage import removeblock
from onionrstorage import deleteBlock
from onionrblocks import onionrblacklist
from utils import reconstructhash
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def ban_block():
&#34;&#34;&#34;Delete a block, permanently blacklisting it.&#34;&#34;&#34;
blacklist = onionrblacklist.OnionrBlackList()
try:
ban = sys.argv[2]
except IndexError:
# Get the hash if its not provided as a CLI argument
ban = logger.readline(&#39;Enter a block hash:&#39;).strip()
# Make sure the hash has no truncated zeroes
ban = reconstructhash.reconstruct_hash(ban)
if stringvalidators.validate_hash(ban):
if not blacklist.inBlacklist(ban):
try:
blacklist.addToDB(ban)
removeblock.remove_block(ban)
deleteBlock(ban)
except Exception as error: # pylint: disable=W0703
logger.error(&#39;Could not blacklist block&#39;,
error=error, terminal=True)
else:
logger.info(&#39;Block blacklisted&#39;, terminal=True)
else:
logger.warn(&#39;That block is already blacklisted&#39;, terminal=True)
else:
logger.error(&#39;Invalid block hash&#39;, terminal=True)
ban_block.onionr_help = &#34;&lt;block hash&gt;: &#34; # type: ignore
ban_block.onionr_help += &#34;deletes and blacklists a block&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.banblocks.ban_block"><code class="name flex">
<span>def <span class="ident">ban_block</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Delete a block, permanently blacklisting it.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def ban_block():
&#34;&#34;&#34;Delete a block, permanently blacklisting it.&#34;&#34;&#34;
blacklist = onionrblacklist.OnionrBlackList()
try:
ban = sys.argv[2]
except IndexError:
# Get the hash if its not provided as a CLI argument
ban = logger.readline(&#39;Enter a block hash:&#39;).strip()
# Make sure the hash has no truncated zeroes
ban = reconstructhash.reconstruct_hash(ban)
if stringvalidators.validate_hash(ban):
if not blacklist.inBlacklist(ban):
try:
blacklist.addToDB(ban)
removeblock.remove_block(ban)
deleteBlock(ban)
except Exception as error: # pylint: disable=W0703
logger.error(&#39;Could not blacklist block&#39;,
error=error, terminal=True)
else:
logger.info(&#39;Block blacklisted&#39;, terminal=True)
else:
logger.warn(&#39;That block is already blacklisted&#39;, terminal=True)
else:
logger.error(&#39;Invalid block hash&#39;, terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.banblocks.ban_block" href="#src.onionrcommands.banblocks.ban_block">ban_block</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,133 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.daemonlaunch.getapihost API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.daemonlaunch.getapihost</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Wait for the api host to be available in the public api host file.
returns string of ip for the local public host interface</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Wait for the api host to be available in the public api host file.
returns string of ip for the local public host interface
&#34;&#34;&#34;
from time import sleep
from filepaths import public_API_host_file
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def get_api_host_until_available() -&gt; str:
&#34;&#34;&#34;Wait for the api host to be available in the public api host file.
returns string of ip for the local public host interface
&#34;&#34;&#34;
api_host = &#39;&#39;
while api_host == &#39;&#39;:
try:
with open(public_API_host_file, &#39;r&#39;) as file:
api_host = file.read()
except FileNotFoundError:
pass
sleep(0.5)
return api_host</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.daemonlaunch.getapihost.get_api_host_until_available"><code class="name flex">
<span>def <span class="ident">get_api_host_until_available</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Wait for the api host to be available in the public api host file.</p>
<p>returns string of ip for the local public host interface</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_api_host_until_available() -&gt; str:
&#34;&#34;&#34;Wait for the api host to be available in the public api host file.
returns string of ip for the local public host interface
&#34;&#34;&#34;
api_host = &#39;&#39;
while api_host == &#39;&#39;:
try:
with open(public_API_host_file, &#39;r&#39;) as file:
api_host = file.read()
except FileNotFoundError:
pass
sleep(0.5)
return api_host</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands.daemonlaunch" href="index.html">src.onionrcommands.daemonlaunch</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.daemonlaunch.getapihost.get_api_host_until_available" href="#src.onionrcommands.daemonlaunch.getapihost.get_api_host_until_available">get_api_host_until_available</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,511 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.daemonlaunch API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.daemonlaunch</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>launch the api servers and communicator</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
launch the api servers and communicator
&#34;&#34;&#34;
import os
import sys
import platform
import sqlite3
from threading import Thread
from gevent import time
from gevent import spawn
from stem.connection import IncorrectPassword
import toomanyobjs
import filenuke
import config
import onionrstatistics
from onionrstatistics import serializeddata
import apiservers
import logger
import communicator
from onionrplugins import onionrevents as events
from netcontroller import NetController
from netcontroller import get_open_port
from onionrutils import localcommand
from utils import identifyhome
import filepaths
from etc import onionrvalues, cleanup
from onionrcrypto import getourkeypair
from utils import hastor, logoheader
import runtests
from httpapi import daemoneventsapi
from .. import version
from .getapihost import get_api_host_until_available
from utils.bettersleep import better_sleep
from netcontroller.torcontrol.onionservicecreator import create_onion_service
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def _proper_shutdown():
localcommand.local_command(&#39;shutdown&#39;)
sys.exit(1)
def daemon():
&#34;&#34;&#34;Start the Onionr communication daemon.&#34;&#34;&#34;
offline_mode = config.get(&#39;general.offline_mode&#39;, False)
if not hastor.has_tor():
offline_mode = True
logger.error(&#34;Tor is not present in system path or Onionr directory&#34;,
terminal=True)
# remove runcheck if it exists
if os.path.isfile(filepaths.run_check_file):
logger.debug(&#39;Runcheck file found on daemon start, deleting.&#39;)
os.remove(filepaths.run_check_file)
# Create shared objects
shared_state = toomanyobjs.TooMany()
shared_state.get(daemoneventsapi.DaemonEventsBP)
Thread(target=shared_state.get(apiservers.ClientAPI).start,
daemon=True, name=&#39;client HTTP API&#39;).start()
if not offline_mode:
Thread(target=shared_state.get(apiservers.PublicAPI).start,
daemon=True, name=&#39;public HTTP API&#39;).start()
# Init run time tester
# (ensures Onionr is running right, for testing purposes)
shared_state.get(runtests.OnionrRunTestManager)
shared_state.get(serializeddata.SerializedData)
shared_state.share_object() # share the parent object to the threads
apiHost = &#39;&#39;
if not offline_mode:
apiHost = get_api_host_until_available()
logger.raw(&#39;&#39;, terminal=True)
# print nice header thing :)
if config.get(&#39;general.display_header&#39;, True):
logoheader.header()
version.version(verbosity=5, function=logger.info)
logger.debug(&#39;Python version %s&#39; % platform.python_version())
if onionrvalues.DEVELOPMENT_MODE:
logger.warn(&#39;Development mode enabled&#39;, timestamp=False, terminal=True)
net = NetController(config.get(&#39;client.public.port&#39;, 59497),
apiServerIP=apiHost)
shared_state.add(net)
shared_state.get(onionrstatistics.tor.TorStats)
security_level = config.get(&#39;general.security_level&#39;, 1)
use_existing_tor = config.get(&#39;tor.use_existing_tor&#39;, False)
if not offline_mode:
if use_existing_tor:
try:
os.mkdir(filepaths.tor_hs_loc)
except FileExistsError:
pass
net.socksPort = config.get(&#39;tor.existing_socks_port&#39;)
try:
net.myID = create_onion_service(
port=net.apiServerIP + &#39;:&#39; + str(net.hsPort))[0]
except IncorrectPassword:
logger.error(&#39;Invalid Tor control password&#39;, terminal=True)
localcommand.local_command(&#39;shutdown&#39;)
cleanup.delete_run_files()
sys.exit(1)
if not net.myID.endswith(&#39;.onion&#39;):
net.myID += &#39;.onion&#39;
with open(filepaths.tor_hs_address_file, &#39;w&#39;) as tor_file:
tor_file.write(net.myID)
else:
logger.info(&#39;Tor is starting...&#39;, terminal=True)
if not net.startTor():
localcommand.local_command(&#39;shutdown&#39;)
cleanup.delete_run_files()
sys.exit(1)
if len(net.myID) &gt; 0 and security_level == 0:
logger.debug(&#39;Started .onion service: %s&#39; %
(logger.colors.underline + net.myID))
else:
logger.debug(&#39;.onion service disabled&#39;)
logger.info(&#39;Using public key: %s&#39; %
(logger.colors.underline +
getourkeypair.get_keypair()[0][:52]))
better_sleep(1)
events.event(&#39;init&#39;, threaded=False)
events.event(&#39;daemon_start&#39;)
communicator.startCommunicator(shared_state)
if not offline_mode and not use_existing_tor:
net.killTor()
else:
try:
os.remove(filepaths.tor_hs_address_file)
except FileNotFoundError:
pass
better_sleep(5)
cleanup.delete_run_files()
if config.get(&#39;general.security_level&#39;, 1) &gt;= 2:
filenuke.nuke.clean_tree(identifyhome.identify_home())
def _ignore_sigint(sig, frame): # pylint: disable=W0612,W0613
&#34;&#34;&#34;Space intentionally left blank.&#34;&#34;&#34;
return
def kill_daemon():
&#34;&#34;&#34;Shutdown the Onionr daemon (communicator).&#34;&#34;&#34;
logger.warn(&#39;Stopping the running daemon...&#39;, timestamp=False,
terminal=True)
# On platforms where we can, fork out to prevent locking
try:
pid = os.fork()
if pid != 0:
return
except (AttributeError, OSError):
pass
events.event(&#39;daemon_stop&#39;)
net = NetController(config.get(&#39;client.port&#39;, 59496))
try:
spawn(
localcommand.local_command,
&#39;/shutdownclean&#39;
).get(timeout=5)
except sqlite3.OperationalError:
pass
net.killTor()
kill_daemon.onionr_help = &#34;Gracefully stops the &#34; # type: ignore
kill_daemon.onionr_help += &#34;Onionr API servers&#34; # type: ignore
def start(override: bool = False):
&#34;&#34;&#34;If no lock file, make one and start onionr.
Error exit if there is and its not overridden
&#34;&#34;&#34;
if os.path.exists(filepaths.lock_file) and not override:
logger.fatal(&#39;Cannot start. Daemon is already running,&#39;
+ &#39; or it did not exit cleanly.\n&#39;
+ &#39; (if you are sure that there is not a daemon running,&#39;
+ &#39; delete onionr.lock &amp; try again).&#39;, terminal=True)
else:
if not onionrvalues.DEVELOPMENT_MODE:
lock_file = open(filepaths.lock_file, &#39;w&#39;)
lock_file.write(&#39;delete at your own risk&#39;)
lock_file.close()
# Start Onionr daemon
daemon()
try:
os.remove(filepaths.lock_file)
except FileNotFoundError:
pass
start.onionr_help = &#34;Start Onionr node &#34; # type: ignore
start.onionr_help += &#34;(public and clients API servers)&#34; # type: ignore</code></pre>
</details>
</section>
<section>
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
<dl>
<dt><code class="name"><a title="src.onionrcommands.daemonlaunch.getapihost" href="getapihost.html">src.onionrcommands.daemonlaunch.getapihost</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
</dl>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.daemonlaunch.daemon"><code class="name flex">
<span>def <span class="ident">daemon</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Start the Onionr communication daemon.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def daemon():
&#34;&#34;&#34;Start the Onionr communication daemon.&#34;&#34;&#34;
offline_mode = config.get(&#39;general.offline_mode&#39;, False)
if not hastor.has_tor():
offline_mode = True
logger.error(&#34;Tor is not present in system path or Onionr directory&#34;,
terminal=True)
# remove runcheck if it exists
if os.path.isfile(filepaths.run_check_file):
logger.debug(&#39;Runcheck file found on daemon start, deleting.&#39;)
os.remove(filepaths.run_check_file)
# Create shared objects
shared_state = toomanyobjs.TooMany()
shared_state.get(daemoneventsapi.DaemonEventsBP)
Thread(target=shared_state.get(apiservers.ClientAPI).start,
daemon=True, name=&#39;client HTTP API&#39;).start()
if not offline_mode:
Thread(target=shared_state.get(apiservers.PublicAPI).start,
daemon=True, name=&#39;public HTTP API&#39;).start()
# Init run time tester
# (ensures Onionr is running right, for testing purposes)
shared_state.get(runtests.OnionrRunTestManager)
shared_state.get(serializeddata.SerializedData)
shared_state.share_object() # share the parent object to the threads
apiHost = &#39;&#39;
if not offline_mode:
apiHost = get_api_host_until_available()
logger.raw(&#39;&#39;, terminal=True)
# print nice header thing :)
if config.get(&#39;general.display_header&#39;, True):
logoheader.header()
version.version(verbosity=5, function=logger.info)
logger.debug(&#39;Python version %s&#39; % platform.python_version())
if onionrvalues.DEVELOPMENT_MODE:
logger.warn(&#39;Development mode enabled&#39;, timestamp=False, terminal=True)
net = NetController(config.get(&#39;client.public.port&#39;, 59497),
apiServerIP=apiHost)
shared_state.add(net)
shared_state.get(onionrstatistics.tor.TorStats)
security_level = config.get(&#39;general.security_level&#39;, 1)
use_existing_tor = config.get(&#39;tor.use_existing_tor&#39;, False)
if not offline_mode:
if use_existing_tor:
try:
os.mkdir(filepaths.tor_hs_loc)
except FileExistsError:
pass
net.socksPort = config.get(&#39;tor.existing_socks_port&#39;)
try:
net.myID = create_onion_service(
port=net.apiServerIP + &#39;:&#39; + str(net.hsPort))[0]
except IncorrectPassword:
logger.error(&#39;Invalid Tor control password&#39;, terminal=True)
localcommand.local_command(&#39;shutdown&#39;)
cleanup.delete_run_files()
sys.exit(1)
if not net.myID.endswith(&#39;.onion&#39;):
net.myID += &#39;.onion&#39;
with open(filepaths.tor_hs_address_file, &#39;w&#39;) as tor_file:
tor_file.write(net.myID)
else:
logger.info(&#39;Tor is starting...&#39;, terminal=True)
if not net.startTor():
localcommand.local_command(&#39;shutdown&#39;)
cleanup.delete_run_files()
sys.exit(1)
if len(net.myID) &gt; 0 and security_level == 0:
logger.debug(&#39;Started .onion service: %s&#39; %
(logger.colors.underline + net.myID))
else:
logger.debug(&#39;.onion service disabled&#39;)
logger.info(&#39;Using public key: %s&#39; %
(logger.colors.underline +
getourkeypair.get_keypair()[0][:52]))
better_sleep(1)
events.event(&#39;init&#39;, threaded=False)
events.event(&#39;daemon_start&#39;)
communicator.startCommunicator(shared_state)
if not offline_mode and not use_existing_tor:
net.killTor()
else:
try:
os.remove(filepaths.tor_hs_address_file)
except FileNotFoundError:
pass
better_sleep(5)
cleanup.delete_run_files()
if config.get(&#39;general.security_level&#39;, 1) &gt;= 2:
filenuke.nuke.clean_tree(identifyhome.identify_home())</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.daemonlaunch.kill_daemon"><code class="name flex">
<span>def <span class="ident">kill_daemon</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Shutdown the Onionr daemon (communicator).</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def kill_daemon():
&#34;&#34;&#34;Shutdown the Onionr daemon (communicator).&#34;&#34;&#34;
logger.warn(&#39;Stopping the running daemon...&#39;, timestamp=False,
terminal=True)
# On platforms where we can, fork out to prevent locking
try:
pid = os.fork()
if pid != 0:
return
except (AttributeError, OSError):
pass
events.event(&#39;daemon_stop&#39;)
net = NetController(config.get(&#39;client.port&#39;, 59496))
try:
spawn(
localcommand.local_command,
&#39;/shutdownclean&#39;
).get(timeout=5)
except sqlite3.OperationalError:
pass
net.killTor()</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.daemonlaunch.start"><code class="name flex">
<span>def <span class="ident">start</span></span>(<span>override=False)</span>
</code></dt>
<dd>
<section class="desc"><p>If no lock file, make one and start onionr.</p>
<p>Error exit if there is and its not overridden</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def start(override: bool = False):
&#34;&#34;&#34;If no lock file, make one and start onionr.
Error exit if there is and its not overridden
&#34;&#34;&#34;
if os.path.exists(filepaths.lock_file) and not override:
logger.fatal(&#39;Cannot start. Daemon is already running,&#39;
+ &#39; or it did not exit cleanly.\n&#39;
+ &#39; (if you are sure that there is not a daemon running,&#39;
+ &#39; delete onionr.lock &amp; try again).&#39;, terminal=True)
else:
if not onionrvalues.DEVELOPMENT_MODE:
lock_file = open(filepaths.lock_file, &#39;w&#39;)
lock_file.write(&#39;delete at your own risk&#39;)
lock_file.close()
# Start Onionr daemon
daemon()
try:
os.remove(filepaths.lock_file)
except FileNotFoundError:
pass</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="../index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-submodules">Sub-modules</a></h3>
<ul>
<li><code><a title="src.onionrcommands.daemonlaunch.getapihost" href="getapihost.html">src.onionrcommands.daemonlaunch.getapihost</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.daemonlaunch.daemon" href="#src.onionrcommands.daemonlaunch.daemon">daemon</a></code></li>
<li><code><a title="src.onionrcommands.daemonlaunch.kill_daemon" href="#src.onionrcommands.daemonlaunch.kill_daemon">kill_daemon</a></code></li>
<li><code><a title="src.onionrcommands.daemonlaunch.start" href="#src.onionrcommands.daemonlaunch.start">start</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,142 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.exportblocks API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.exportblocks</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>This file handles the command for exporting blocks to disk</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
This file handles the command for exporting blocks to disk
&#34;&#34;&#34;
import sys
import logger
import onionrstorage
from utils import createdirs
from onionrutils import stringvalidators
import filepaths
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def _do_export(b_hash):
createdirs.create_dirs()
data = onionrstorage.getData(b_hash)
with open(&#39;%s/%s.dat&#39; % (filepaths.export_location,
b_hash), &#39;wb&#39;) as export:
export.write(data)
logger.info(&#39;Block exported as file&#39;, terminal=True)
def export_block():
&#34;&#34;&#34;Export block based on hash from stdin or argv.&#34;&#34;&#34;
try:
if not stringvalidators.validate_hash(sys.argv[2]):
raise ValueError
except (IndexError, ValueError):
logger.error(&#39;No valid block hash specified.&#39;, terminal=True)
sys.exit(1)
else:
b_hash = sys.argv[2]
_do_export(b_hash)
export_block.onionr_help = &#34;&lt;block hash&gt;: Export block to &#34; # type: ignore
export_block.onionr_help += &#34;a file. Export directory is in &#34; # type: ignore
export_block.onionr_help += &#34;Onionr home under block-export&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.exportblocks.export_block"><code class="name flex">
<span>def <span class="ident">export_block</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Export block based on hash from stdin or argv.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def export_block():
&#34;&#34;&#34;Export block based on hash from stdin or argv.&#34;&#34;&#34;
try:
if not stringvalidators.validate_hash(sys.argv[2]):
raise ValueError
except (IndexError, ValueError):
logger.error(&#39;No valid block hash specified.&#39;, terminal=True)
sys.exit(1)
else:
b_hash = sys.argv[2]
_do_export(b_hash)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.exportblocks.export_block" href="#src.onionrcommands.exportblocks.export_block">export_block</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,262 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.filecommands API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.filecommands</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>This file handles the commands for adding
and getting files from the Onionr network</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
This file handles the commands for adding
and getting files from the Onionr network
&#34;&#34;&#34;
import sys
import os
import logger
from onionrblocks.onionrblockapi import Block
import onionrexceptions
from onionrutils import stringvalidators
from etc import onionrvalues
from onionrblocks import insert
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
_ORIG_DIR = onionrvalues.ORIG_RUN_DIR_ENV_VAR
def _get_dir(path: str) -&gt; str:
if not os.getenv(_ORIG_DIR) is None:
return os.getenv(_ORIG_DIR) + &#39;/&#39; + path # type: ignore
else:
return path
def add_html(singleBlock=True, blockType=&#39;html&#39;):
&#34;&#34;&#34;Create one-off web page from HTML file, no ext resources.&#34;&#34;&#34;
add_file(blockType=blockType)
add_html.onionr_help = &#34;Adds an HTML file into Onionr. Does &#34; # type: ignore
add_html.onionr_help += &#34;not include dependant resources&#34; # type: ignore
def add_file(blockType=&#39;bin&#39;):
&#34;&#34;&#34;Add a file to the onionr network.&#34;&#34;&#34;
if len(sys.argv) &gt;= 3:
filename = sys.argv[2]
if not os.path.exists(_get_dir(filename)):
logger.error(
&#39;That file does not exist. Improper path (specify full path)?&#39;,
terminal=True)
return
logger.info(&#39;Adding file, this might take a long time.&#39;,
terminal=True)
try:
with open(_get_dir(filename), &#39;rb&#39;) as single_file:
blockhash = insert(single_file.read(), header=blockType)
if len(blockhash) &gt; 0:
logger.info(&#39;File %s saved in block %s&#39; %
(filename, blockhash), terminal=True)
except Exception as err: # pylint: disable=W0703
logger.error(&#39;Failed to save file in block &#39; +
str(err), timestamp=False, terminal=True)
else:
logger.error(&#39;%s add-file &lt;filename&gt;&#39; %
sys.argv[0], timestamp=False, terminal=True)
add_file.onionr_help = &#34;&lt;file path&gt; Add a file into &#34; # type: ignore
add_file.onionr_help += &#34;the Onionr network&#34; # type: ignore
def get_file():
&#34;&#34;&#34;Get a file from onionr blocks.&#34;&#34;&#34;
try:
file_name = _get_dir(sys.argv[2])
bHash = sys.argv[3]
except IndexError:
logger.error(&#34;Syntax %s %s&#34; % (
sys.argv[0], &#39;/path/to/filename &lt;blockhash&gt;&#39;), terminal=True)
else:
logger.info(file_name, terminal=True)
if os.path.exists(file_name):
logger.error(&#34;File already exists&#34;, terminal=True)
return
if not stringvalidators.validate_hash(bHash):
logger.error(&#39;Block hash is invalid&#39;, terminal=True)
return
try:
with open(file_name, &#39;wb&#39;) as my_file:
my_file.write(Block(bHash).bcontent)
except onionrexceptions.NoDataAvailable:
logger.error(
&#39;That block is not available. Trying again later may work.&#39;,
terminal=True)
get_file.onionr_help = &#34;&lt;file path&gt; &lt;block hash&gt;: Download &#34; # type: ignore
get_file.onionr_help += &#34;a file from the onionr network.&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.filecommands.add_file"><code class="name flex">
<span>def <span class="ident">add_file</span></span>(<span>blockType='bin')</span>
</code></dt>
<dd>
<section class="desc"><p>Add a file to the onionr network.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def add_file(blockType=&#39;bin&#39;):
&#34;&#34;&#34;Add a file to the onionr network.&#34;&#34;&#34;
if len(sys.argv) &gt;= 3:
filename = sys.argv[2]
if not os.path.exists(_get_dir(filename)):
logger.error(
&#39;That file does not exist. Improper path (specify full path)?&#39;,
terminal=True)
return
logger.info(&#39;Adding file, this might take a long time.&#39;,
terminal=True)
try:
with open(_get_dir(filename), &#39;rb&#39;) as single_file:
blockhash = insert(single_file.read(), header=blockType)
if len(blockhash) &gt; 0:
logger.info(&#39;File %s saved in block %s&#39; %
(filename, blockhash), terminal=True)
except Exception as err: # pylint: disable=W0703
logger.error(&#39;Failed to save file in block &#39; +
str(err), timestamp=False, terminal=True)
else:
logger.error(&#39;%s add-file &lt;filename&gt;&#39; %
sys.argv[0], timestamp=False, terminal=True)</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.filecommands.add_html"><code class="name flex">
<span>def <span class="ident">add_html</span></span>(<span>singleBlock=True, blockType='html')</span>
</code></dt>
<dd>
<section class="desc"><p>Create one-off web page from HTML file, no ext resources.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def add_html(singleBlock=True, blockType=&#39;html&#39;):
&#34;&#34;&#34;Create one-off web page from HTML file, no ext resources.&#34;&#34;&#34;
add_file(blockType=blockType)</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.filecommands.get_file"><code class="name flex">
<span>def <span class="ident">get_file</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Get a file from onionr blocks.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_file():
&#34;&#34;&#34;Get a file from onionr blocks.&#34;&#34;&#34;
try:
file_name = _get_dir(sys.argv[2])
bHash = sys.argv[3]
except IndexError:
logger.error(&#34;Syntax %s %s&#34; % (
sys.argv[0], &#39;/path/to/filename &lt;blockhash&gt;&#39;), terminal=True)
else:
logger.info(file_name, terminal=True)
if os.path.exists(file_name):
logger.error(&#34;File already exists&#34;, terminal=True)
return
if not stringvalidators.validate_hash(bHash):
logger.error(&#39;Block hash is invalid&#39;, terminal=True)
return
try:
with open(file_name, &#39;wb&#39;) as my_file:
my_file.write(Block(bHash).bcontent)
except onionrexceptions.NoDataAvailable:
logger.error(
&#39;That block is not available. Trying again later may work.&#39;,
terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.filecommands.add_file" href="#src.onionrcommands.filecommands.add_file">add_file</a></code></li>
<li><code><a title="src.onionrcommands.filecommands.add_html" href="#src.onionrcommands.filecommands.add_html">add_html</a></code></li>
<li><code><a title="src.onionrcommands.filecommands.get_file" href="#src.onionrcommands.filecommands.get_file">get_file</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,150 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands API documentation</title>
<meta name="description" content="" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands</code></h1>
</header>
<section id="section-intro">
</section>
<section>
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
<dl>
<dt><code class="name"><a title="src.onionrcommands.banblocks" href="banblocks.html">src.onionrcommands.banblocks</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.daemonlaunch" href="daemonlaunch/index.html">src.onionrcommands.daemonlaunch</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.exportblocks" href="exportblocks.html">src.onionrcommands.exportblocks</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.filecommands" href="filecommands.html">src.onionrcommands.filecommands</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.keyadders" href="keyadders.html">src.onionrcommands.keyadders</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.motdcreator" href="motdcreator.html">src.onionrcommands.motdcreator</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.onionrstatistics" href="onionrstatistics.html">src.onionrcommands.onionrstatistics</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.openwebinterface" href="openwebinterface.html">src.onionrcommands.openwebinterface</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.parser" href="parser/index.html">src.onionrcommands.parser</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.pubkeymanager" href="pubkeymanager.html">src.onionrcommands.pubkeymanager</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.resetplugins" href="resetplugins.html">src.onionrcommands.resetplugins</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.resettor" href="resettor.html">src.onionrcommands.resettor</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.restartonionr" href="restartonionr.html">src.onionrcommands.restartonionr</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.runtimetestcmd" href="runtimetestcmd.html">src.onionrcommands.runtimetestcmd</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.sitecreator" href="sitecreator.html">src.onionrcommands.sitecreator</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.softreset" href="softreset.html">src.onionrcommands.softreset</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.togglebootstrap" href="togglebootstrap.html">src.onionrcommands.togglebootstrap</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.version" href="version.html">src.onionrcommands.version</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
</dl>
</section>
<section>
</section>
<section>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src" href="../index.html">src</a></code></li>
</ul>
</li>
<li><h3><a href="#header-submodules">Sub-modules</a></h3>
<ul>
<li><code><a title="src.onionrcommands.banblocks" href="banblocks.html">src.onionrcommands.banblocks</a></code></li>
<li><code><a title="src.onionrcommands.daemonlaunch" href="daemonlaunch/index.html">src.onionrcommands.daemonlaunch</a></code></li>
<li><code><a title="src.onionrcommands.exportblocks" href="exportblocks.html">src.onionrcommands.exportblocks</a></code></li>
<li><code><a title="src.onionrcommands.filecommands" href="filecommands.html">src.onionrcommands.filecommands</a></code></li>
<li><code><a title="src.onionrcommands.keyadders" href="keyadders.html">src.onionrcommands.keyadders</a></code></li>
<li><code><a title="src.onionrcommands.motdcreator" href="motdcreator.html">src.onionrcommands.motdcreator</a></code></li>
<li><code><a title="src.onionrcommands.onionrstatistics" href="onionrstatistics.html">src.onionrcommands.onionrstatistics</a></code></li>
<li><code><a title="src.onionrcommands.openwebinterface" href="openwebinterface.html">src.onionrcommands.openwebinterface</a></code></li>
<li><code><a title="src.onionrcommands.parser" href="parser/index.html">src.onionrcommands.parser</a></code></li>
<li><code><a title="src.onionrcommands.pubkeymanager" href="pubkeymanager.html">src.onionrcommands.pubkeymanager</a></code></li>
<li><code><a title="src.onionrcommands.resetplugins" href="resetplugins.html">src.onionrcommands.resetplugins</a></code></li>
<li><code><a title="src.onionrcommands.resettor" href="resettor.html">src.onionrcommands.resettor</a></code></li>
<li><code><a title="src.onionrcommands.restartonionr" href="restartonionr.html">src.onionrcommands.restartonionr</a></code></li>
<li><code><a title="src.onionrcommands.runtimetestcmd" href="runtimetestcmd.html">src.onionrcommands.runtimetestcmd</a></code></li>
<li><code><a title="src.onionrcommands.sitecreator" href="sitecreator.html">src.onionrcommands.sitecreator</a></code></li>
<li><code><a title="src.onionrcommands.softreset" href="softreset.html">src.onionrcommands.softreset</a></code></li>
<li><code><a title="src.onionrcommands.togglebootstrap" href="togglebootstrap.html">src.onionrcommands.togglebootstrap</a></code></li>
<li><code><a title="src.onionrcommands.version" href="version.html">src.onionrcommands.version</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,133 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.keyadders API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.keyadders</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>add keys (transport and pubkey)</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
add keys (transport and pubkey)
&#34;&#34;&#34;
import sys
import logger
from coredb import keydb
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def add_address():
&#34;&#34;&#34;Command to add a peer address from either an arg or stdin.&#34;&#34;&#34;
try:
newAddress = sys.argv[2]
newAddress = newAddress.replace(&#39;http:&#39;, &#39;&#39;).replace(&#39;/&#39;, &#39;&#39;)
except IndexError:
pass
else:
logger.info(&#34;Adding address: &#34; + logger.colors.underline + newAddress,
terminal=True)
if keydb.addkeys.add_address(newAddress):
logger.info(&#34;Successfully added address.&#34;, terminal=True)
else:
logger.warn(&#34;Unable to add address.&#34;, terminal=True)
add_address.onionr_help = &#34;Adds a node transport address&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.keyadders.add_address"><code class="name flex">
<span>def <span class="ident">add_address</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Command to add a peer address from either an arg or stdin.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def add_address():
&#34;&#34;&#34;Command to add a peer address from either an arg or stdin.&#34;&#34;&#34;
try:
newAddress = sys.argv[2]
newAddress = newAddress.replace(&#39;http:&#39;, &#39;&#39;).replace(&#39;/&#39;, &#39;&#39;)
except IndexError:
pass
else:
logger.info(&#34;Adding address: &#34; + logger.colors.underline + newAddress,
terminal=True)
if keydb.addkeys.add_address(newAddress):
logger.info(&#34;Successfully added address.&#34;, terminal=True)
else:
logger.warn(&#34;Unable to add address.&#34;, terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.keyadders.add_address" href="#src.onionrcommands.keyadders.add_address">add_address</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,127 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.motdcreator API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.motdcreator</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Command to make new network-wide MOTD message. Only network admin can do this
The key is set in onionrvalues</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Command to make new network-wide MOTD message. Only network admin can do this
The key is set in onionrvalues
&#34;&#34;&#34;
import onionrblocks
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def motd_creator():
&#34;&#34;&#34;Create a new MOTD message for the Onionr network.&#34;&#34;&#34;
motd = &#39;&#39;
new = &#39;&#39;
print(&#39;Enter a new MOTD, quit on a new line:&#39;)
while new != &#39;quit&#39;:
new = input() # nosec B323
if new != &#39;quit&#39;:
motd += new
bl = onionrblocks.insert(motd, header=&#39;motd&#39;, sign=True)
print(f&#34;inserted in {bl}&#34;)
motd_creator.onionr_help = &#34;Create a new MOTD for the network&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.motdcreator.motd_creator"><code class="name flex">
<span>def <span class="ident">motd_creator</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Create a new MOTD message for the Onionr network.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def motd_creator():
&#34;&#34;&#34;Create a new MOTD message for the Onionr network.&#34;&#34;&#34;
motd = &#39;&#39;
new = &#39;&#39;
print(&#39;Enter a new MOTD, quit on a new line:&#39;)
while new != &#39;quit&#39;:
new = input() # nosec B323
if new != &#39;quit&#39;:
motd += new
bl = onionrblocks.insert(motd, header=&#39;motd&#39;, sign=True)
print(f&#34;inserted in {bl}&#34;)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.motdcreator.motd_creator" href="#src.onionrcommands.motdcreator.motd_creator">motd_creator</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,367 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.onionrstatistics API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.onionrstatistics</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>This module defines commands to show stats/details about the local node</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
This module defines commands to show stats/details about the local node
&#34;&#34;&#34;
import os
import logger
from onionrblocks import onionrblockapi
from onionrblocks import onionrblacklist
from onionrutils import checkcommunicator, mnemonickeys
from utils import sizeutils, gethostname, getconsolewidth, identifyhome
from coredb import blockmetadb, keydb
import onionrcrypto
import config
from etc import onionrvalues
check_communicator = checkcommunicator.is_communicator_running
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def show_stats():
&#34;&#34;&#34;Print/log statistic info about our Onionr install.&#34;&#34;&#34;
try:
# define stats messages here
totalBlocks = len(blockmetadb.get_block_list())
home = identifyhome.identify_home()
totalBanned = len(onionrblacklist.OnionrBlackList().getList())
messages = {
# info about local client
&#39;Onionr Daemon Status&#39;:
((logger.colors.fg.green + &#39;Online&#39;)
if check_communicator(timeout=9)
else logger.colors.fg.red + &#39;Offline&#39;),
# file and folder size stats
&#39;div1&#39;: True, # this creates a solid line across the screen, a div
&#39;Total Block Size&#39;:
sizeutils.human_size(sizeutils.size(home + &#39;blocks/&#39;)),
&#39;Total Plugin Size&#39;:
sizeutils.human_size(sizeutils.size(home + &#39;plugins/&#39;)),
&#39;Log File Size&#39;:
sizeutils.human_size(sizeutils.size(home + &#39;output.log&#39;)),
# count stats
&#39;div2&#39;: True,
&#39;Known Peers (nodes)&#39;:
str(max(len(keydb.listkeys.list_adders()) - 1, 0)),
&#39;Enabled Plugins&#39;:
str(len(config.get(&#39;plugins.enabled&#39;, list()))) + &#39; / &#39; +
str(len(os.listdir(home + &#39;plugins/&#39;))),
&#39;Stored Blocks&#39;: str(totalBlocks),
&#39;Deleted Blocks&#39;: str(totalBanned)
}
# color configuration
colors = {
&#39;title&#39;: logger.colors.bold,
&#39;key&#39;: logger.colors.fg.lightgreen,
&#39;val&#39;: logger.colors.fg.green,
&#39;border&#39;: logger.colors.fg.lightblue,
&#39;reset&#39;: logger.colors.reset
}
# pre-processing
maxlength = 0
width = getconsolewidth.get_console_width()
for key, val in messages.items():
if not (type(val) is bool and val is True):
maxlength = max(len(key), maxlength)
prewidth = maxlength + len(&#39; | &#39;)
groupsize = width - prewidth - len(&#39;[+] &#39;)
# generate stats table
logger.info(colors[&#39;title&#39;] + &#39;Onionr v%s Statistics&#39; %
onionrvalues.ONIONR_VERSION + colors[&#39;reset&#39;],
terminal=True)
logger.info(colors[&#39;border&#39;] + &#39;-&#39; * (maxlength + 1) +
&#39;+&#39; + colors[&#39;reset&#39;], terminal=True)
for key, val in messages.items():
if not (type(val) is bool and val is True):
val = [str(val)[i:i + groupsize]
for i in range(0, len(str(val)), groupsize)]
logger.info(colors[&#39;key&#39;] + str(key).rjust(maxlength) +
colors[&#39;reset&#39;] + colors[&#39;border&#39;] +
&#39; | &#39; + colors[&#39;reset&#39;] + colors[&#39;val&#39;] +
str(val.pop(0)) + colors[&#39;reset&#39;], terminal=True)
for value in val:
logger.info(&#39; &#39; * maxlength + colors[&#39;border&#39;] + &#39; | &#39; +
colors[&#39;reset&#39;] + colors[&#39;val&#39;] + str(
value) + colors[&#39;reset&#39;], terminal=True)
else:
logger.info(colors[&#39;border&#39;] + &#39;-&#39; * (maxlength +
1) + &#39;+&#39; +
colors[&#39;reset&#39;], terminal=True)
logger.info(colors[&#39;border&#39;] + &#39;-&#39; * (maxlength + 1) +
&#39;+&#39; + colors[&#39;reset&#39;], terminal=True)
except Exception as e: # pylint: disable=W0703
logger.error(&#39;Failed to generate statistics table. &#39; +
str(e), error=e, timestamp=False, terminal=True)
def show_details():
&#34;&#34;&#34;Print out details.
node transport address(es)
active user ID
active user ID in mnemonic form
&#34;&#34;&#34;
details = {
&#39;Node Address&#39;: gethostname.get_hostname(),
&#39;Public Key&#39;: onionrcrypto.pub_key.replace(&#39;=&#39;, &#39;&#39;),
&#39;Human-readable Public Key&#39;: mnemonickeys.get_human_readable_ID()
}
for detail in details:
logger.info(&#39;%s%s: \n%s%s\n&#39; % (logger.colors.fg.lightgreen,
detail, logger.colors.fg.green,
details[detail]), terminal=True)
show_details.onionr_help = &#34;Shows relevant information &#34; # type: ignore
show_details.onionr_help += &#34;for your Onionr install: node &#34; # type: ignore
show_details.onionr_help += &#34;address, and active public key.&#34; # type: ignore
show_stats.onionr_help = &#34;Shows statistics for your Onionr &#34; # type: ignore
show_stats.onionr_help += &#34;node. Slow if Onionr is not running&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.onionrstatistics.check_communicator"><code class="name flex">
<span>def <span class="ident">check_communicator</span></span>(<span>timeout=5, interval=0.1)</span>
</code></dt>
<dd>
<section class="desc"></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_communicator_running(timeout = 5, interval = 0.1):
try:
runcheck_file = filepaths.run_check_file
if not os.path.isfile(runcheck_file):
open(runcheck_file, &#39;w+&#39;).close()
starttime = time.time()
while True:
time.sleep(interval)
if not os.path.isfile(runcheck_file):
return True
elif time.time() - starttime &gt;= timeout:
return False
except:
return False</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.onionrstatistics.show_details"><code class="name flex">
<span>def <span class="ident">show_details</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Print out details.</p>
<p>node transport address(es)
active user ID
active user ID in mnemonic form</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def show_details():
&#34;&#34;&#34;Print out details.
node transport address(es)
active user ID
active user ID in mnemonic form
&#34;&#34;&#34;
details = {
&#39;Node Address&#39;: gethostname.get_hostname(),
&#39;Public Key&#39;: onionrcrypto.pub_key.replace(&#39;=&#39;, &#39;&#39;),
&#39;Human-readable Public Key&#39;: mnemonickeys.get_human_readable_ID()
}
for detail in details:
logger.info(&#39;%s%s: \n%s%s\n&#39; % (logger.colors.fg.lightgreen,
detail, logger.colors.fg.green,
details[detail]), terminal=True)</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.onionrstatistics.show_stats"><code class="name flex">
<span>def <span class="ident">show_stats</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Print/log statistic info about our Onionr install.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def show_stats():
&#34;&#34;&#34;Print/log statistic info about our Onionr install.&#34;&#34;&#34;
try:
# define stats messages here
totalBlocks = len(blockmetadb.get_block_list())
home = identifyhome.identify_home()
totalBanned = len(onionrblacklist.OnionrBlackList().getList())
messages = {
# info about local client
&#39;Onionr Daemon Status&#39;:
((logger.colors.fg.green + &#39;Online&#39;)
if check_communicator(timeout=9)
else logger.colors.fg.red + &#39;Offline&#39;),
# file and folder size stats
&#39;div1&#39;: True, # this creates a solid line across the screen, a div
&#39;Total Block Size&#39;:
sizeutils.human_size(sizeutils.size(home + &#39;blocks/&#39;)),
&#39;Total Plugin Size&#39;:
sizeutils.human_size(sizeutils.size(home + &#39;plugins/&#39;)),
&#39;Log File Size&#39;:
sizeutils.human_size(sizeutils.size(home + &#39;output.log&#39;)),
# count stats
&#39;div2&#39;: True,
&#39;Known Peers (nodes)&#39;:
str(max(len(keydb.listkeys.list_adders()) - 1, 0)),
&#39;Enabled Plugins&#39;:
str(len(config.get(&#39;plugins.enabled&#39;, list()))) + &#39; / &#39; +
str(len(os.listdir(home + &#39;plugins/&#39;))),
&#39;Stored Blocks&#39;: str(totalBlocks),
&#39;Deleted Blocks&#39;: str(totalBanned)
}
# color configuration
colors = {
&#39;title&#39;: logger.colors.bold,
&#39;key&#39;: logger.colors.fg.lightgreen,
&#39;val&#39;: logger.colors.fg.green,
&#39;border&#39;: logger.colors.fg.lightblue,
&#39;reset&#39;: logger.colors.reset
}
# pre-processing
maxlength = 0
width = getconsolewidth.get_console_width()
for key, val in messages.items():
if not (type(val) is bool and val is True):
maxlength = max(len(key), maxlength)
prewidth = maxlength + len(&#39; | &#39;)
groupsize = width - prewidth - len(&#39;[+] &#39;)
# generate stats table
logger.info(colors[&#39;title&#39;] + &#39;Onionr v%s Statistics&#39; %
onionrvalues.ONIONR_VERSION + colors[&#39;reset&#39;],
terminal=True)
logger.info(colors[&#39;border&#39;] + &#39;-&#39; * (maxlength + 1) +
&#39;+&#39; + colors[&#39;reset&#39;], terminal=True)
for key, val in messages.items():
if not (type(val) is bool and val is True):
val = [str(val)[i:i + groupsize]
for i in range(0, len(str(val)), groupsize)]
logger.info(colors[&#39;key&#39;] + str(key).rjust(maxlength) +
colors[&#39;reset&#39;] + colors[&#39;border&#39;] +
&#39; | &#39; + colors[&#39;reset&#39;] + colors[&#39;val&#39;] +
str(val.pop(0)) + colors[&#39;reset&#39;], terminal=True)
for value in val:
logger.info(&#39; &#39; * maxlength + colors[&#39;border&#39;] + &#39; | &#39; +
colors[&#39;reset&#39;] + colors[&#39;val&#39;] + str(
value) + colors[&#39;reset&#39;], terminal=True)
else:
logger.info(colors[&#39;border&#39;] + &#39;-&#39; * (maxlength +
1) + &#39;+&#39; +
colors[&#39;reset&#39;], terminal=True)
logger.info(colors[&#39;border&#39;] + &#39;-&#39; * (maxlength + 1) +
&#39;+&#39; + colors[&#39;reset&#39;], terminal=True)
except Exception as e: # pylint: disable=W0703
logger.error(&#39;Failed to generate statistics table. &#39; +
str(e), error=e, timestamp=False, terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.onionrstatistics.check_communicator" href="#src.onionrcommands.onionrstatistics.check_communicator">check_communicator</a></code></li>
<li><code><a title="src.onionrcommands.onionrstatistics.show_details" href="#src.onionrcommands.onionrstatistics.show_details">show_details</a></code></li>
<li><code><a title="src.onionrcommands.onionrstatistics.show_stats" href="#src.onionrcommands.onionrstatistics.show_stats">show_stats</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,179 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.openwebinterface API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.openwebinterface</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Open the web interface properly into a web browser</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Open the web interface properly into a web browser
&#34;&#34;&#34;
import webbrowser
import logger
from onionrutils import getclientapiserver
import config
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def get_url() -&gt; str:
&#34;&#34;&#34;Build UI URL string and return it.&#34;&#34;&#34;
try:
url = getclientapiserver.get_client_API_server()
except FileNotFoundError:
url = &#34;&#34;
logger.error(
&#39;Onionr seems to not be running (could not get api host)&#39;,
terminal=True)
else:
url = &#39;http://%s/#%s&#39; % (url, config.get(&#39;client.webpassword&#39;))
logger.info(&#39;Onionr web interface URL: &#39; + url, terminal=True)
return url
get_url.onionr_help = &#34;Shows the Onionr &#34; # type: ignore
get_url.onionr_help += &#34;web interface URL with API key&#34; # type: ignore
def open_home():
&#34;&#34;&#34;Command to open web interface URL in default browser.&#34;&#34;&#34;
try:
url = getclientapiserver.get_client_API_server()
except FileNotFoundError:
logger.error(
&#39;Onionr seems to not be running (could not get api host)&#39;,
terminal=True)
else:
url = &#39;http://%s/#%s&#39; % (url, config.get(&#39;client.webpassword&#39;))
logger.info(
&#39;If Onionr does not open automatically, use this URL: &#39; + url,
terminal=True)
webbrowser.open_new_tab(url)
open_home.onionr_help = &#34;Opens the Onionr UI in the default &#34; # type: ignore
open_home.onionr_help += &#34;browser. Node must be running.&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.openwebinterface.get_url"><code class="name flex">
<span>def <span class="ident">get_url</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Build UI URL string and return it.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_url() -&gt; str:
&#34;&#34;&#34;Build UI URL string and return it.&#34;&#34;&#34;
try:
url = getclientapiserver.get_client_API_server()
except FileNotFoundError:
url = &#34;&#34;
logger.error(
&#39;Onionr seems to not be running (could not get api host)&#39;,
terminal=True)
else:
url = &#39;http://%s/#%s&#39; % (url, config.get(&#39;client.webpassword&#39;))
logger.info(&#39;Onionr web interface URL: &#39; + url, terminal=True)
return url</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.openwebinterface.open_home"><code class="name flex">
<span>def <span class="ident">open_home</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Command to open web interface URL in default browser.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def open_home():
&#34;&#34;&#34;Command to open web interface URL in default browser.&#34;&#34;&#34;
try:
url = getclientapiserver.get_client_API_server()
except FileNotFoundError:
logger.error(
&#39;Onionr seems to not be running (could not get api host)&#39;,
terminal=True)
else:
url = &#39;http://%s/#%s&#39; % (url, config.get(&#39;client.webpassword&#39;))
logger.info(
&#39;If Onionr does not open automatically, use this URL: &#39; + url,
terminal=True)
webbrowser.open_new_tab(url)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.openwebinterface.get_url" href="#src.onionrcommands.openwebinterface.get_url">get_url</a></code></li>
<li><code><a title="src.onionrcommands.openwebinterface.open_home" href="#src.onionrcommands.openwebinterface.open_home">open_home</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,274 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.parser.arguments API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.parser.arguments</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Sets CLI arguments for Onionr</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Sets CLI arguments for Onionr
&#34;&#34;&#34;
from typing import Callable
from .. import onionrstatistics, version, daemonlaunch, keyadders
from .. import openwebinterface
from .. import banblocks # Command to blacklist a block by its hash
from .. import filecommands # commands to share files with onionr
from .. import exportblocks # commands to export blocks
from .. import pubkeymanager # commands to add or change id
from .. import resettor # cmds to reset the tor data folder/transport keypair
from .. import resetplugins # command to reinstall default plugins
from .. import softreset # command to delete onionr blocks
from .. import restartonionr # command to restart Onionr
from .. import runtimetestcmd # cmd to execute the runtime integration tests
from .. import motdcreator # cmd to generate new Onionr MOTDs
from .. import sitecreator # cmd to create multi-page sites
from .. import togglebootstrap # cmd to toggle bootstrap file usage
import onionrexceptions
from onionrutils import importnewblocks # func to import new blocks
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def get_arguments() -&gt; dict:
&#34;&#34;&#34;Return command argument dict, minus plugin cmds.
This is a function because we need to be able to
dynamically modify them with plugins
&#34;&#34;&#34;
args = {
(&#39;blacklist&#39;, &#39;blacklist-block&#39;, &#39;remove-block&#39;,
&#39;removeblock&#39;, &#39;banblock&#39;, &#39;ban-block&#39;): banblocks.ban_block,
(&#39;details&#39;, &#39;info&#39;): onionrstatistics.show_details,
(&#39;stats&#39;, &#39;statistics&#39;): onionrstatistics.show_stats,
(&#39;version&#39;,): version.version,
(&#39;start&#39;, &#39;daemon&#39;): daemonlaunch.start,
(&#39;stop&#39;, &#39;kill&#39;): daemonlaunch.kill_daemon,
(&#39;restart&#39;,): restartonionr.restart,
(&#39;add-address&#39;, &#39;addaddress&#39;, &#39;addadder&#39;): keyadders.add_address,
(&#39;openhome&#39;, &#39;gui&#39;, &#39;openweb&#39;,
&#39;open-home&#39;, &#39;open-web&#39;): openwebinterface.open_home,
(&#39;get-url&#39;, &#39;url&#39;, &#39;get-web&#39;): openwebinterface.get_url,
(&#39;addhtml&#39;, &#39;add-html&#39;): filecommands.add_html,
(&#39;addsite&#39;, &#39;add-site&#39;,
&#39;update-site&#39;, &#39;updatesite&#39;): sitecreator.create_multipage_site,
(&#39;addfile&#39;, &#39;add-file&#39;): filecommands.add_file,
(&#39;get-file&#39;, &#39;getfile&#39;): filecommands.get_file,
(&#39;export-block&#39;, &#39;exportblock&#39;): exportblocks.export_block,
(&#39;importblocks&#39;,
&#39;import-blocks&#39;, &#39;import-block&#39;): importnewblocks.import_new_blocks,
(&#39;addid&#39;, &#39;add-id&#39;): pubkeymanager.add_ID,
(&#39;changeid&#39;, &#39;change-id&#39;): pubkeymanager.change_ID,
(&#39;add-vanity&#39;, &#39;addvanity&#39;): pubkeymanager.add_vanity,
(&#39;resettor&#39;, &#39;reset-tor&#39;): resettor.reset_tor,
(&#39;resetplugins&#39;, &#39;reset-plugins&#39;): resetplugins.reset,
(&#39;reset-tor-node-transport&#39;,): resettor.reset_tor_key_pair,
(&#39;soft-reset&#39;, &#39;softreset&#39;): softreset.soft_reset,
(&#39;toggle-bootstrap&#39;, &#39;togglebootstrap&#39;):
togglebootstrap.toggle_bootstrap_config,
(&#39;runtime-test&#39;, &#39;runtimetest&#39;): runtimetestcmd.do_runtime_test,
(&#39;makemotd&#39;, &#39;make-motd&#39;): motdcreator.motd_creator
}
return args
def get_help(arg: str) -&gt; str:
&#34;&#34;&#34;Return the help info string from a given command.&#34;&#34;&#34;
arguments = get_arguments()
# Iterate the command alias tuples
for argument in arguments:
# Return the help message if its found in a command alias tuple
if arg in argument:
return arguments[argument].onionr_help
raise KeyError
def get_func(argument: str) -&gt; Callable:
&#34;&#34;&#34;Return the function for a given command argument.&#34;&#34;&#34;
argument = argument.lower()
args = get_arguments()
for arg in args.keys(): # Iterate command alias sets
&#34;&#34;&#34;
If our argument is in the current alias set,
return the command function
&#34;&#34;&#34;
if argument in arg:
return args[arg]
raise onionrexceptions.NotFound</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.parser.arguments.get_arguments"><code class="name flex">
<span>def <span class="ident">get_arguments</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Return command argument dict, minus plugin cmds.</p>
<p>This is a function because we need to be able to
dynamically modify them with plugins</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_arguments() -&gt; dict:
&#34;&#34;&#34;Return command argument dict, minus plugin cmds.
This is a function because we need to be able to
dynamically modify them with plugins
&#34;&#34;&#34;
args = {
(&#39;blacklist&#39;, &#39;blacklist-block&#39;, &#39;remove-block&#39;,
&#39;removeblock&#39;, &#39;banblock&#39;, &#39;ban-block&#39;): banblocks.ban_block,
(&#39;details&#39;, &#39;info&#39;): onionrstatistics.show_details,
(&#39;stats&#39;, &#39;statistics&#39;): onionrstatistics.show_stats,
(&#39;version&#39;,): version.version,
(&#39;start&#39;, &#39;daemon&#39;): daemonlaunch.start,
(&#39;stop&#39;, &#39;kill&#39;): daemonlaunch.kill_daemon,
(&#39;restart&#39;,): restartonionr.restart,
(&#39;add-address&#39;, &#39;addaddress&#39;, &#39;addadder&#39;): keyadders.add_address,
(&#39;openhome&#39;, &#39;gui&#39;, &#39;openweb&#39;,
&#39;open-home&#39;, &#39;open-web&#39;): openwebinterface.open_home,
(&#39;get-url&#39;, &#39;url&#39;, &#39;get-web&#39;): openwebinterface.get_url,
(&#39;addhtml&#39;, &#39;add-html&#39;): filecommands.add_html,
(&#39;addsite&#39;, &#39;add-site&#39;,
&#39;update-site&#39;, &#39;updatesite&#39;): sitecreator.create_multipage_site,
(&#39;addfile&#39;, &#39;add-file&#39;): filecommands.add_file,
(&#39;get-file&#39;, &#39;getfile&#39;): filecommands.get_file,
(&#39;export-block&#39;, &#39;exportblock&#39;): exportblocks.export_block,
(&#39;importblocks&#39;,
&#39;import-blocks&#39;, &#39;import-block&#39;): importnewblocks.import_new_blocks,
(&#39;addid&#39;, &#39;add-id&#39;): pubkeymanager.add_ID,
(&#39;changeid&#39;, &#39;change-id&#39;): pubkeymanager.change_ID,
(&#39;add-vanity&#39;, &#39;addvanity&#39;): pubkeymanager.add_vanity,
(&#39;resettor&#39;, &#39;reset-tor&#39;): resettor.reset_tor,
(&#39;resetplugins&#39;, &#39;reset-plugins&#39;): resetplugins.reset,
(&#39;reset-tor-node-transport&#39;,): resettor.reset_tor_key_pair,
(&#39;soft-reset&#39;, &#39;softreset&#39;): softreset.soft_reset,
(&#39;toggle-bootstrap&#39;, &#39;togglebootstrap&#39;):
togglebootstrap.toggle_bootstrap_config,
(&#39;runtime-test&#39;, &#39;runtimetest&#39;): runtimetestcmd.do_runtime_test,
(&#39;makemotd&#39;, &#39;make-motd&#39;): motdcreator.motd_creator
}
return args</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.parser.arguments.get_func"><code class="name flex">
<span>def <span class="ident">get_func</span></span>(<span>argument)</span>
</code></dt>
<dd>
<section class="desc"><p>Return the function for a given command argument.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_func(argument: str) -&gt; Callable:
&#34;&#34;&#34;Return the function for a given command argument.&#34;&#34;&#34;
argument = argument.lower()
args = get_arguments()
for arg in args.keys(): # Iterate command alias sets
&#34;&#34;&#34;
If our argument is in the current alias set,
return the command function
&#34;&#34;&#34;
if argument in arg:
return args[arg]
raise onionrexceptions.NotFound</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.parser.arguments.get_help"><code class="name flex">
<span>def <span class="ident">get_help</span></span>(<span>arg)</span>
</code></dt>
<dd>
<section class="desc"><p>Return the help info string from a given command.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_help(arg: str) -&gt; str:
&#34;&#34;&#34;Return the help info string from a given command.&#34;&#34;&#34;
arguments = get_arguments()
# Iterate the command alias tuples
for argument in arguments:
# Return the help message if its found in a command alias tuple
if arg in argument:
return arguments[argument].onionr_help
raise KeyError</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands.parser" href="index.html">src.onionrcommands.parser</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.parser.arguments.get_arguments" href="#src.onionrcommands.parser.arguments.get_arguments">get_arguments</a></code></li>
<li><code><a title="src.onionrcommands.parser.arguments.get_func" href="#src.onionrcommands.parser.arguments.get_func">get_func</a></code></li>
<li><code><a title="src.onionrcommands.parser.arguments.get_help" href="#src.onionrcommands.parser.arguments.get_help">get_help</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,342 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.parser API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.parser</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>This module loads in the Onionr arguments and their help messages</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
This module loads in the Onionr arguments and their help messages
&#34;&#34;&#34;
import sys
import os
import logger
import onionrexceptions
import onionrplugins
from onionrplugins import onionrpluginapi
from . import arguments, recommend
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def plugin_command(cmd):
&#34;&#34;&#34;Build a plugin command function name.&#34;&#34;&#34;
return f&#39;on_{cmd}_cmd&#39;
def register_plugin_commands(cmd) -&gt; bool:
&#34;&#34;&#34;Find a plugin command hook and execute it for a given cmd.&#34;&#34;&#34;
plugin_cmd = plugin_command(cmd)
for pl in onionrplugins.get_enabled_plugins():
pl = onionrplugins.get_plugin(pl)
if hasattr(pl, plugin_cmd):
getattr(pl, plugin_cmd)(onionrpluginapi.PluginAPI)
return True
return False
def _show_term(msg: str):
logger.info(msg, terminal=True)
def register():
&#34;&#34;&#34;Register commands and handles help command processing.&#34;&#34;&#34;
def get_help_message(cmd: str,
default: str = &#39;No help available for this command&#39;):
&#34;&#34;&#34;Print help message for a given command, supports plugin commands.&#34;&#34;&#34;
pl_cmd = plugin_command(cmd)
for pl in onionrplugins.get_enabled_plugins():
pl = onionrplugins.get_plugin(pl)
if hasattr(pl, pl_cmd):
try:
return getattr(pl, pl_cmd).onionr_help
except AttributeError:
pass
for i in arguments.get_arguments():
for _ in i:
try:
return arguments.get_help(cmd)
except AttributeError:
pass
return default # Return the help string
PROGRAM_NAME = &#34;onionr&#34;
# Get the command
try:
cmd = sys.argv[1]
except IndexError:
logger.debug(&#34;Detected Onionr run with no commands specified&#34;)
return
is_help_cmd = False
if cmd.replace(&#39;--&#39;, &#39;&#39;).lower() == &#39;help&#39;:
is_help_cmd = True
try:
try:
if cmd not in (&#39;start&#39;, &#39;details&#39;, &#39;show-details&#39;):
os.chdir(os.environ[&#39;ORIG_ONIONR_RUN_DIR&#39;])
except KeyError:
pass
try:
arguments.get_func(cmd)()
except KeyboardInterrupt:
pass
except onionrexceptions.NotFound:
if not register_plugin_commands(cmd) and not is_help_cmd:
recommend.recommend()
sys.exit(3)
if is_help_cmd:
try:
sys.argv[2]
except IndexError:
for i in arguments.get_arguments():
_show_term(&#39;%s &lt;%s&gt;: %s&#39; % (PROGRAM_NAME, &#39;/&#39;.join(i),
get_help_message(i[0])))
for pl in onionrplugins.get_enabled_plugins():
pl = onionrplugins.get_plugin(pl)
if hasattr(pl, &#39;ONIONR_COMMANDS&#39;):
print(&#39;&#39;)
try:
_show_term(&#39;%s commands:&#39; % (pl.plugin_name,))
except AttributeError:
_show_term(&#39;%s commands:&#39; % (pl.__name__,))
for plugin_cmd in pl.ONIONR_COMMANDS:
_show_term(&#39;%s %s: %s&#39; %
(PROGRAM_NAME,
plugin_cmd,
get_help_message(plugin_cmd)),)
print(&#39;&#39;)
else:
try:
_show_term(&#39;%s %s: %s&#39; % (PROGRAM_NAME,
sys.argv[2],
get_help_message(sys.argv[2])))
except KeyError:
logger.error(&#39;%s: command does not exist.&#39; % [sys.argv[2]],
terminal=True)
sys.exit(3)
return</code></pre>
</details>
</section>
<section>
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
<dl>
<dt><code class="name"><a title="src.onionrcommands.parser.arguments" href="arguments.html">src.onionrcommands.parser.arguments</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
<dt><code class="name"><a title="src.onionrcommands.parser.recommend" href="recommend.html">src.onionrcommands.parser.recommend</a></code></dt>
<dd>
<section class="desc"><p>Onionr - Private P2P Communication …</p></section>
</dd>
</dl>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.parser.plugin_command"><code class="name flex">
<span>def <span class="ident">plugin_command</span></span>(<span>cmd)</span>
</code></dt>
<dd>
<section class="desc"><p>Build a plugin command function name.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def plugin_command(cmd):
&#34;&#34;&#34;Build a plugin command function name.&#34;&#34;&#34;
return f&#39;on_{cmd}_cmd&#39;</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.parser.register"><code class="name flex">
<span>def <span class="ident">register</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Register commands and handles help command processing.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def register():
&#34;&#34;&#34;Register commands and handles help command processing.&#34;&#34;&#34;
def get_help_message(cmd: str,
default: str = &#39;No help available for this command&#39;):
&#34;&#34;&#34;Print help message for a given command, supports plugin commands.&#34;&#34;&#34;
pl_cmd = plugin_command(cmd)
for pl in onionrplugins.get_enabled_plugins():
pl = onionrplugins.get_plugin(pl)
if hasattr(pl, pl_cmd):
try:
return getattr(pl, pl_cmd).onionr_help
except AttributeError:
pass
for i in arguments.get_arguments():
for _ in i:
try:
return arguments.get_help(cmd)
except AttributeError:
pass
return default # Return the help string
PROGRAM_NAME = &#34;onionr&#34;
# Get the command
try:
cmd = sys.argv[1]
except IndexError:
logger.debug(&#34;Detected Onionr run with no commands specified&#34;)
return
is_help_cmd = False
if cmd.replace(&#39;--&#39;, &#39;&#39;).lower() == &#39;help&#39;:
is_help_cmd = True
try:
try:
if cmd not in (&#39;start&#39;, &#39;details&#39;, &#39;show-details&#39;):
os.chdir(os.environ[&#39;ORIG_ONIONR_RUN_DIR&#39;])
except KeyError:
pass
try:
arguments.get_func(cmd)()
except KeyboardInterrupt:
pass
except onionrexceptions.NotFound:
if not register_plugin_commands(cmd) and not is_help_cmd:
recommend.recommend()
sys.exit(3)
if is_help_cmd:
try:
sys.argv[2]
except IndexError:
for i in arguments.get_arguments():
_show_term(&#39;%s &lt;%s&gt;: %s&#39; % (PROGRAM_NAME, &#39;/&#39;.join(i),
get_help_message(i[0])))
for pl in onionrplugins.get_enabled_plugins():
pl = onionrplugins.get_plugin(pl)
if hasattr(pl, &#39;ONIONR_COMMANDS&#39;):
print(&#39;&#39;)
try:
_show_term(&#39;%s commands:&#39; % (pl.plugin_name,))
except AttributeError:
_show_term(&#39;%s commands:&#39; % (pl.__name__,))
for plugin_cmd in pl.ONIONR_COMMANDS:
_show_term(&#39;%s %s: %s&#39; %
(PROGRAM_NAME,
plugin_cmd,
get_help_message(plugin_cmd)),)
print(&#39;&#39;)
else:
try:
_show_term(&#39;%s %s: %s&#39; % (PROGRAM_NAME,
sys.argv[2],
get_help_message(sys.argv[2])))
except KeyError:
logger.error(&#39;%s: command does not exist.&#39; % [sys.argv[2]],
terminal=True)
sys.exit(3)
return</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.parser.register_plugin_commands"><code class="name flex">
<span>def <span class="ident">register_plugin_commands</span></span>(<span>cmd)</span>
</code></dt>
<dd>
<section class="desc"><p>Find a plugin command hook and execute it for a given cmd.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def register_plugin_commands(cmd) -&gt; bool:
&#34;&#34;&#34;Find a plugin command hook and execute it for a given cmd.&#34;&#34;&#34;
plugin_cmd = plugin_command(cmd)
for pl in onionrplugins.get_enabled_plugins():
pl = onionrplugins.get_plugin(pl)
if hasattr(pl, plugin_cmd):
getattr(pl, plugin_cmd)(onionrpluginapi.PluginAPI)
return True
return False</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="../index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-submodules">Sub-modules</a></h3>
<ul>
<li><code><a title="src.onionrcommands.parser.arguments" href="arguments.html">src.onionrcommands.parser.arguments</a></code></li>
<li><code><a title="src.onionrcommands.parser.recommend" href="recommend.html">src.onionrcommands.parser.recommend</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.parser.plugin_command" href="#src.onionrcommands.parser.plugin_command">plugin_command</a></code></li>
<li><code><a title="src.onionrcommands.parser.register" href="#src.onionrcommands.parser.register">register</a></code></li>
<li><code><a title="src.onionrcommands.parser.register_plugin_commands" href="#src.onionrcommands.parser.register_plugin_commands">register_plugin_commands</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,131 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.parser.recommend API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.parser.recommend</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Try to provide recommendations for invalid Onionr commands</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Try to provide recommendations for invalid Onionr commands
&#34;&#34;&#34;
import sys
from difflib import SequenceMatcher
import logger
from . import arguments
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def recommend(print_default: bool = True):
&#34;&#34;&#34;Print out a recommendation for argv cmd if one is available.&#34;&#34;&#34;
tried = sys.argv[1]
args = arguments.get_arguments()
print_message = &#39;Command not found:&#39;
for key in args.keys():
for word in key:
if SequenceMatcher(None, tried, word).ratio() &gt;= 0.75:
logger.warn(f&#39;{print_message} &#34;{tried}&#34;, &#39;
+ f&#39;did you mean &#34;{word}&#34;?&#39;,
terminal=True)
return
if print_default:
logger.error(&#39;%s &#34;%s&#34;&#39; % (print_message, tried), terminal=True)</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.parser.recommend.recommend"><code class="name flex">
<span>def <span class="ident">recommend</span></span>(<span>print_default=True)</span>
</code></dt>
<dd>
<section class="desc"><p>Print out a recommendation for argv cmd if one is available.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def recommend(print_default: bool = True):
&#34;&#34;&#34;Print out a recommendation for argv cmd if one is available.&#34;&#34;&#34;
tried = sys.argv[1]
args = arguments.get_arguments()
print_message = &#39;Command not found:&#39;
for key in args.keys():
for word in key:
if SequenceMatcher(None, tried, word).ratio() &gt;= 0.75:
logger.warn(f&#39;{print_message} &#34;{tried}&#34;, &#39;
+ f&#39;did you mean &#34;{word}&#34;?&#39;,
terminal=True)
return
if print_default:
logger.error(&#39;%s &#34;%s&#34;&#39; % (print_message, tried), terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands.parser" href="index.html">src.onionrcommands.parser</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.parser.recommend.recommend" href="#src.onionrcommands.parser.recommend.recommend">recommend</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,366 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.pubkeymanager API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.pubkeymanager</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>This module defines user ID-related CLI commands</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
This module defines user ID-related CLI commands
&#34;&#34;&#34;
import sys
import getpass
import unpaddedbase32
import niceware
import vanityonionr
import logger
import onionrexceptions
from onionrutils import stringvalidators, bytesconverter
import config
import keymanager
import onionrcrypto
from etc import onionrvalues
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
DETERMINISTIC_REQUIREMENT = onionrvalues.PASSWORD_LENGTH
def add_ID():
&#34;&#34;&#34;Command to create a new user ID key pair.&#34;&#34;&#34;
key_manager = keymanager.KeyManager()
try:
sys.argv[2] # pylint: disable=W0104
if not sys.argv[2].lower() == &#39;true&#39;:
raise ValueError
except (IndexError, ValueError):
newID = key_manager.addKey()[0]
else:
logger.warn(
&#39;Deterministic keys require random and long passphrases.&#39;,
terminal=True)
logger.warn(
&#39;If a good passphrase is not used, your key can be easily stolen.&#39;,
terminal=True)
logger.warn(
&#39;You should use a series of hard to guess words, &#39; +
&#39;see this for reference: https://www.xkcd.com/936/&#39;,
terminal=True)
try:
pass1 = getpass.getpass(
prompt=&#39;Enter at least %s characters: &#39; %
(DETERMINISTIC_REQUIREMENT,))
pass2 = getpass.getpass(prompt=&#39;Confirm entry: &#39;)
except KeyboardInterrupt:
sys.exit(42)
if onionrcrypto.cryptoutils.safe_compare(pass1, pass2):
try:
logger.info(
&#39;Generating deterministic key. This can take a while.&#39;,
terminal=True)
newID, privKey = onionrcrypto.generate_deterministic(pass1)
except onionrexceptions.PasswordStrengthError:
logger.error(&#39;Passphrase must use at least %s characters.&#39; % (
DETERMINISTIC_REQUIREMENT,), terminal=True)
sys.exit(1)
else:
logger.error(&#39;Passwords do not match.&#39;, terminal=True)
sys.exit(1)
try:
key_manager.addKey(pubKey=newID,
privKey=privKey)
except ValueError:
logger.error(
&#39;That ID is already available, you can change to it &#39; +
&#39;with the change-id command.&#39;, terminal=True)
return
logger.info(&#39;Added ID: %s&#39; %
(bytesconverter.bytes_to_str(newID),), terminal=True)
add_ID.onionr_help = &#34;If the first argument is true, &#34; # type: ignore
add_ID.onionr_help += &#34;Onionr will show a deterministic &#34; # type: ignore
add_ID.onionr_help += &#34;generation prompt. Otherwise it will &#34; # type: ignore
add_ID.onionr_help += &#34;generate &amp; save a new random key pair.&#34; # type: ignore
def change_ID():
&#34;&#34;&#34;Command to change active ID from argv or stdin.&#34;&#34;&#34;
key_manager = keymanager.KeyManager()
try:
key = sys.argv[2]
key = unpaddedbase32.repad(key.encode()).decode()
except IndexError:
logger.warn(&#39;Specify pubkey to use&#39;, terminal=True)
else:
if stringvalidators.validate_pub_key(key):
key_list = key_manager.getPubkeyList()
if key in key_list or key.replace(&#39;=&#39;, &#39;&#39;) in key_list:
config.set(&#39;general.public_key&#39;, key)
config.save()
logger.info(&#39;Set active key to: %s&#39; % (key,), terminal=True)
logger.info(&#39;Restart Onionr if it is running.&#39;, terminal=True)
else:
logger.warn(&#39;That key does not exist&#39;, terminal=True)
else:
logger.warn(&#39;Invalid key %s&#39; % (key,), terminal=True)
change_ID.onionr_help = &#34;&lt;pubkey&gt;: Switches Onionr to &#34; # type: ignore
change_ID.onionr_help += &#34;use a different user ID key. &#34; # type: ignore
change_ID.onionr_help += &#34;You should immediately restart &#34; # type: ignore
change_ID.onionr_help += &#34;Onionr if it is running.&#34; # type: ignore
def add_vanity():
&#34;&#34;&#34;Command to generate menmonic vanity key pair.&#34;&#34;&#34;
key_manager = keymanager.KeyManager()
def tell(tell):
return logger.info(tell, terminal=True)
words = &#39;&#39;
length = len(sys.argv) - 2
if length == 0:
return
for i in range(2, len(sys.argv)):
words += &#39; &#39;
words += sys.argv[i]
try:
if length == 1:
tell(&#39;Finding vanity, this should only take a few moments.&#39;)
else:
tell(&#39;Finding vanity, this will probably take a really long time.&#39;)
try:
vanity = vanityonionr.find_multiprocess(words)
except ValueError:
logger.warn(&#39;Vanity words must be valid english bip39&#39;,
terminal=True)
else:
b32_pub = unpaddedbase32.b32encode(vanity[0])
tell(&#39;Found vanity address:\n&#39; +
niceware.bytes_to_passphrase(vanity[0]))
tell(&#39;Base32 Public key: %s&#39; % (b32_pub.decode(),))
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
except KeyboardInterrupt:
pass
add_vanity.onionr_help = &#34;&lt;space separated words&gt; - &#34; # type: ignore
add_vanity.onionr_help += &#34;Generates and stores an &#34; # type: ignore
add_vanity.onionr_help += &#34;Onionr vanity address &#34; # type: ignore
add_vanity.onionr_help += &#34;(see is.gd/YklHGe)&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.pubkeymanager.add_ID"><code class="name flex">
<span>def <span class="ident">add_ID</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Command to create a new user ID key pair.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def add_ID():
&#34;&#34;&#34;Command to create a new user ID key pair.&#34;&#34;&#34;
key_manager = keymanager.KeyManager()
try:
sys.argv[2] # pylint: disable=W0104
if not sys.argv[2].lower() == &#39;true&#39;:
raise ValueError
except (IndexError, ValueError):
newID = key_manager.addKey()[0]
else:
logger.warn(
&#39;Deterministic keys require random and long passphrases.&#39;,
terminal=True)
logger.warn(
&#39;If a good passphrase is not used, your key can be easily stolen.&#39;,
terminal=True)
logger.warn(
&#39;You should use a series of hard to guess words, &#39; +
&#39;see this for reference: https://www.xkcd.com/936/&#39;,
terminal=True)
try:
pass1 = getpass.getpass(
prompt=&#39;Enter at least %s characters: &#39; %
(DETERMINISTIC_REQUIREMENT,))
pass2 = getpass.getpass(prompt=&#39;Confirm entry: &#39;)
except KeyboardInterrupt:
sys.exit(42)
if onionrcrypto.cryptoutils.safe_compare(pass1, pass2):
try:
logger.info(
&#39;Generating deterministic key. This can take a while.&#39;,
terminal=True)
newID, privKey = onionrcrypto.generate_deterministic(pass1)
except onionrexceptions.PasswordStrengthError:
logger.error(&#39;Passphrase must use at least %s characters.&#39; % (
DETERMINISTIC_REQUIREMENT,), terminal=True)
sys.exit(1)
else:
logger.error(&#39;Passwords do not match.&#39;, terminal=True)
sys.exit(1)
try:
key_manager.addKey(pubKey=newID,
privKey=privKey)
except ValueError:
logger.error(
&#39;That ID is already available, you can change to it &#39; +
&#39;with the change-id command.&#39;, terminal=True)
return
logger.info(&#39;Added ID: %s&#39; %
(bytesconverter.bytes_to_str(newID),), terminal=True)</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.pubkeymanager.add_vanity"><code class="name flex">
<span>def <span class="ident">add_vanity</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Command to generate menmonic vanity key pair.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def add_vanity():
&#34;&#34;&#34;Command to generate menmonic vanity key pair.&#34;&#34;&#34;
key_manager = keymanager.KeyManager()
def tell(tell):
return logger.info(tell, terminal=True)
words = &#39;&#39;
length = len(sys.argv) - 2
if length == 0:
return
for i in range(2, len(sys.argv)):
words += &#39; &#39;
words += sys.argv[i]
try:
if length == 1:
tell(&#39;Finding vanity, this should only take a few moments.&#39;)
else:
tell(&#39;Finding vanity, this will probably take a really long time.&#39;)
try:
vanity = vanityonionr.find_multiprocess(words)
except ValueError:
logger.warn(&#39;Vanity words must be valid english bip39&#39;,
terminal=True)
else:
b32_pub = unpaddedbase32.b32encode(vanity[0])
tell(&#39;Found vanity address:\n&#39; +
niceware.bytes_to_passphrase(vanity[0]))
tell(&#39;Base32 Public key: %s&#39; % (b32_pub.decode(),))
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
except KeyboardInterrupt:
pass</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.pubkeymanager.change_ID"><code class="name flex">
<span>def <span class="ident">change_ID</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Command to change active ID from argv or stdin.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def change_ID():
&#34;&#34;&#34;Command to change active ID from argv or stdin.&#34;&#34;&#34;
key_manager = keymanager.KeyManager()
try:
key = sys.argv[2]
key = unpaddedbase32.repad(key.encode()).decode()
except IndexError:
logger.warn(&#39;Specify pubkey to use&#39;, terminal=True)
else:
if stringvalidators.validate_pub_key(key):
key_list = key_manager.getPubkeyList()
if key in key_list or key.replace(&#39;=&#39;, &#39;&#39;) in key_list:
config.set(&#39;general.public_key&#39;, key)
config.save()
logger.info(&#39;Set active key to: %s&#39; % (key,), terminal=True)
logger.info(&#39;Restart Onionr if it is running.&#39;, terminal=True)
else:
logger.warn(&#39;That key does not exist&#39;, terminal=True)
else:
logger.warn(&#39;Invalid key %s&#39; % (key,), terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.pubkeymanager.add_ID" href="#src.onionrcommands.pubkeymanager.add_ID">add_ID</a></code></li>
<li><code><a title="src.onionrcommands.pubkeymanager.add_vanity" href="#src.onionrcommands.pubkeymanager.add_vanity">add_vanity</a></code></li>
<li><code><a title="src.onionrcommands.pubkeymanager.change_ID" href="#src.onionrcommands.pubkeymanager.change_ID">change_ID</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,129 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.resetplugins API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.resetplugins</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Reset default plugins from source</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Reset default plugins from source
&#34;&#34;&#34;
import os
import shutil
from utils import identifyhome
import logger
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def reset():
&#34;&#34;&#34;Reinstalls Onionr default plugins.&#34;&#34;&#34;
home = identifyhome.identify_home()
plugin_dir = home + &#39;/plugins/&#39;
if not os.path.exists(home):
return
if os.path.exists(plugin_dir):
shutil.rmtree(plugin_dir)
logger.info(&#39;Default plugins have been reset.&#39;, terminal=True)
reset.onionr_help = &#34;reinstalls default Onionr plugins&#34; # type: ignore
reset.onionr_help += &#34;(e.g. mail). Should be done after &#34; # type: ignore
reset.onionr_help += &#34;git pulls or plugin modification.&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.resetplugins.reset"><code class="name flex">
<span>def <span class="ident">reset</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Reinstalls Onionr default plugins.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def reset():
&#34;&#34;&#34;Reinstalls Onionr default plugins.&#34;&#34;&#34;
home = identifyhome.identify_home()
plugin_dir = home + &#39;/plugins/&#39;
if not os.path.exists(home):
return
if os.path.exists(plugin_dir):
shutil.rmtree(plugin_dir)
logger.info(&#39;Default plugins have been reset.&#39;, terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.resetplugins.reset" href="#src.onionrcommands.resetplugins.reset">reset</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,158 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.resettor API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.resettor</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Command to delete the Tor data directory if its safe to do so</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Command to delete the Tor data directory if its safe to do so
&#34;&#34;&#34;
import os
import shutil
import logger
from onionrutils import localcommand
from utils import identifyhome
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def __delete(directory):
tor_dir = &#39;%s/%s/&#39; % (identifyhome.identify_home(), directory)
if os.path.exists(tor_dir):
if localcommand.local_command(&#39;/ping&#39;) == &#39;pong!&#39;:
logger.warn(
&#39;Cannot delete Tor data while Onionr is running&#39;,
terminal=True)
else:
shutil.rmtree(tor_dir)
logger.info(&#39;Tor reset&#39;, terminal=True)
def reset_tor():
&#34;&#34;&#34;Delete tor data directory.&#34;&#34;&#34;
__delete(&#39;tordata&#39;)
reset_tor.onionr_help = &#34;Deletes Onionr&#39;s Tor data directory. &#34; # type: ignore
reset_tor.onionr_help += &#34;Only do this as a last resort if &#34; # type: ignore
reset_tor.onionr_help += &#34;you have serious Tor issues.&#34; # type: ignore
def reset_tor_key_pair():
&#34;&#34;&#34;Delete Tor HS key pair for our node.&#34;&#34;&#34;
__delete(&#39;hs&#39;)
reset_tor_key_pair.onionr_help = &#34;Delete&#39;s your Tor &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;node address permanently. &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;Note that through &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;fingerprinting attackers &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;may be able to know that &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;your new generated node &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;address belongs to &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;the same node &#34; # type: ignore
reset_tor_key_pair.onionr_help += &#34;as the deleted one.&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.resettor.reset_tor"><code class="name flex">
<span>def <span class="ident">reset_tor</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Delete tor data directory.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def reset_tor():
&#34;&#34;&#34;Delete tor data directory.&#34;&#34;&#34;
__delete(&#39;tordata&#39;)</code></pre>
</details>
</dd>
<dt id="src.onionrcommands.resettor.reset_tor_key_pair"><code class="name flex">
<span>def <span class="ident">reset_tor_key_pair</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Delete Tor HS key pair for our node.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def reset_tor_key_pair():
&#34;&#34;&#34;Delete Tor HS key pair for our node.&#34;&#34;&#34;
__delete(&#39;hs&#39;)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.resettor.reset_tor" href="#src.onionrcommands.resettor.reset_tor">reset_tor</a></code></li>
<li><code><a title="src.onionrcommands.resettor.reset_tor_key_pair" href="#src.onionrcommands.resettor.reset_tor_key_pair">reset_tor_key_pair</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,164 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.restartonionr API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.restartonionr</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Command to restart Onionr</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Command to restart Onionr
&#34;&#34;&#34;
import time
import os
import subprocess # nosec
import platform
from etc import onionrvalues
from etc import cleanup
from onionrutils import localcommand
import logger
import filepaths
from . import daemonlaunch
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
SCRIPT_NAME = os.path.dirname(os.path.realpath(
__file__)) + f&#39;/../../{onionrvalues.SCRIPT_NAME}&#39;
def restart():
&#34;&#34;&#34;Tell the Onionr daemon to restart.&#34;&#34;&#34;
logger.info(&#39;Restarting Onionr&#39;, terminal=True)
# On platforms where we can, fork out to prevent locking
try:
pid = os.fork()
if pid != 0:
return
except (AttributeError, OSError):
if platform.platform() != &#39;Windows&#39;:
logger.warn(&#39;Could not fork on restart&#39;)
daemonlaunch.kill_daemon()
while localcommand.local_command(&#39;ping&#39;, maxWait=8) == &#39;pong!&#39;:
time.sleep(0.3)
time.sleep(15)
while (os.path.exists(filepaths.private_API_host_file) or
(os.path.exists(filepaths.daemon_mark_file))):
time.sleep(1)
cleanup.delete_run_files()
subprocess.Popen([SCRIPT_NAME, &#39;start&#39;])
restart.onionr_help = &#39;Gracefully restart Onionr&#39; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.restartonionr.restart"><code class="name flex">
<span>def <span class="ident">restart</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Tell the Onionr daemon to restart.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def restart():
&#34;&#34;&#34;Tell the Onionr daemon to restart.&#34;&#34;&#34;
logger.info(&#39;Restarting Onionr&#39;, terminal=True)
# On platforms where we can, fork out to prevent locking
try:
pid = os.fork()
if pid != 0:
return
except (AttributeError, OSError):
if platform.platform() != &#39;Windows&#39;:
logger.warn(&#39;Could not fork on restart&#39;)
daemonlaunch.kill_daemon()
while localcommand.local_command(&#39;ping&#39;, maxWait=8) == &#39;pong!&#39;:
time.sleep(0.3)
time.sleep(15)
while (os.path.exists(filepaths.private_API_host_file) or
(os.path.exists(filepaths.daemon_mark_file))):
time.sleep(1)
cleanup.delete_run_files()
subprocess.Popen([SCRIPT_NAME, &#39;start&#39;])</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.restartonionr.restart" href="#src.onionrcommands.restartonionr.restart">restart</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,126 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.runtimetestcmd API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.runtimetestcmd</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Command to tell daemon to do run time tests</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Command to tell daemon to do run time tests
&#34;&#34;&#34;
from gevent import spawn
from onionrutils import localcommand
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def do_runtime_test():
&#34;&#34;&#34;Send runtime test daemon queue command.&#34;&#34;&#34;
spawn(
localcommand.local_command,
f&#39;daemon-event/test_runtime&#39;,
post=True,
is_json=True,
postData={},
maxWait=300
).get(300)
do_runtime_test.onionr_help = &#34;If Onionr is running, &#34; # type: ignore
do_runtime_test.onionr_help += &#34;run runtime tests (check logs)&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.runtimetestcmd.do_runtime_test"><code class="name flex">
<span>def <span class="ident">do_runtime_test</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Send runtime test daemon queue command.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def do_runtime_test():
&#34;&#34;&#34;Send runtime test daemon queue command.&#34;&#34;&#34;
spawn(
localcommand.local_command,
f&#39;daemon-event/test_runtime&#39;,
post=True,
is_json=True,
postData={},
maxWait=300
).get(300)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.runtimetestcmd.do_runtime_test" href="#src.onionrcommands.runtimetestcmd.do_runtime_test">do_runtime_test</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,187 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.sitecreator API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.sitecreator</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Command to create Onionr mutli-page sites</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Command to create Onionr mutli-page sites
&#34;&#34;&#34;
import sys
import getpass
from httpapi import onionrsitesapi
import logger
from etc import onionrvalues
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def create_multipage_site():
&#34;&#34;&#34;Command to create mutlipage sites with specified dir and password.&#34;&#34;&#34;
error_encountered = False
try:
directory = sys.argv[2]
except IndexError:
directory = &#39;.&#39;
try:
passphrase = sys.argv[3]
except IndexError:
logger.warn(&#39;&#39;&#39;It is critical that this passphrase is long.
If you want to update your site later you must remember the passphrase.&#39;&#39;&#39;,
terminal=True)
passphrase = getpass.getpass(
&#39;Please enter a site passphrase of at least &#39; +
str(onionrvalues.PASSWORD_LENGTH) + &#39; characters.&#39;)
confirm = getpass.getpass(&#39;Confirm passphrase:&#39;)
if passphrase != confirm:
logger.error(&#39;Passphrases do not match&#39;, terminal=True)
error_encountered = True
if len(passphrase) &lt; onionrvalues.PASSWORD_LENGTH:
error_encountered = True
logger.error(
f&#39;Passphrase must be at least {onionrvalues.PASSWORD_LENGTH}&#39; +
&#39;characters.&#39;, terminal=True)
if error_encountered:
sys.exit(1)
results = onionrsitesapi.sitefiles.create_site(
passphrase, directory=directory)
results = (results[0].replace(&#39;=&#39;, &#39;&#39;), results[1])
logger.info(f&#39;Site address {results[0]}&#39;, terminal=True)
logger.info(f&#39;Block for this version {results[1]}&#39;, terminal=True)
create_multipage_site.onionr_help = &#34;[directory path &#34; # type: ignore
create_multipage_site.onionr_help += &#34;(default relative)] &#34; # type: ignore
create_multipage_site.onionr_help += &#34;- packages a whole &#34; # type: ignore
create_multipage_site.onionr_help += &#34;directory and makes &#34; # type: ignore
create_multipage_site.onionr_help += &#34;it available as &#34; # type: ignore
create_multipage_site.onionr_help += &#34;an Onionr site.&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.sitecreator.create_multipage_site"><code class="name flex">
<span>def <span class="ident">create_multipage_site</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Command to create mutlipage sites with specified dir and password.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def create_multipage_site():
&#34;&#34;&#34;Command to create mutlipage sites with specified dir and password.&#34;&#34;&#34;
error_encountered = False
try:
directory = sys.argv[2]
except IndexError:
directory = &#39;.&#39;
try:
passphrase = sys.argv[3]
except IndexError:
logger.warn(&#39;&#39;&#39;It is critical that this passphrase is long.
If you want to update your site later you must remember the passphrase.&#39;&#39;&#39;,
terminal=True)
passphrase = getpass.getpass(
&#39;Please enter a site passphrase of at least &#39; +
str(onionrvalues.PASSWORD_LENGTH) + &#39; characters.&#39;)
confirm = getpass.getpass(&#39;Confirm passphrase:&#39;)
if passphrase != confirm:
logger.error(&#39;Passphrases do not match&#39;, terminal=True)
error_encountered = True
if len(passphrase) &lt; onionrvalues.PASSWORD_LENGTH:
error_encountered = True
logger.error(
f&#39;Passphrase must be at least {onionrvalues.PASSWORD_LENGTH}&#39; +
&#39;characters.&#39;, terminal=True)
if error_encountered:
sys.exit(1)
results = onionrsitesapi.sitefiles.create_site(
passphrase, directory=directory)
results = (results[0].replace(&#39;=&#39;, &#39;&#39;), results[1])
logger.info(f&#39;Site address {results[0]}&#39;, terminal=True)
logger.info(f&#39;Block for this version {results[1]}&#39;, terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.sitecreator.create_multipage_site" href="#src.onionrcommands.sitecreator.create_multipage_site">create_multipage_site</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,154 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.softreset API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.softreset</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Command to soft-reset Onionr (deletes blocks)</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Command to soft-reset Onionr (deletes blocks)
&#34;&#34;&#34;
import os
import shutil
from onionrutils import localcommand
from coredb import dbfiles
import filepaths
from onionrplugins import onionrevents
import logger
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def _ignore_not_found_delete(path):
try:
os.remove(path)
except FileNotFoundError:
pass
def soft_reset():
&#34;&#34;&#34;Command to soft reset Onionr home data.
Onionr must not be running
&#34;&#34;&#34;
if localcommand.local_command(&#39;/ping&#39;) == &#39;pong!&#39;:
logger.warn(&#39;Cannot soft reset while Onionr is running&#39;,
terminal=True)
return
path = filepaths.block_data_location
shutil.rmtree(path)
_ignore_not_found_delete(dbfiles.block_meta_db)
_ignore_not_found_delete(filepaths.upload_list)
_ignore_not_found_delete(filepaths.usage_file)
onionrevents.event(&#39;softreset&#39;)
logger.info(&#34;Soft reset Onionr&#34;, terminal=True)
soft_reset.onionr_help = &#34;Deletes Onionr blocks and their &#34; # type: ignore
soft_reset.onionr_help += &#34;associated metadata, except for &#34; # type: ignore
soft_reset.onionr_help += &#34;any exported block files. Does NOT &#34; # type: ignore
soft_reset.onionr_help += &#34;delete data on &#34; # type: ignore
soft_reset.onionr_help += &#34;other nodes in the network.&#34; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.softreset.soft_reset"><code class="name flex">
<span>def <span class="ident">soft_reset</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Command to soft reset Onionr home data.</p>
<p>Onionr must not be running</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def soft_reset():
&#34;&#34;&#34;Command to soft reset Onionr home data.
Onionr must not be running
&#34;&#34;&#34;
if localcommand.local_command(&#39;/ping&#39;) == &#39;pong!&#39;:
logger.warn(&#39;Cannot soft reset while Onionr is running&#39;,
terminal=True)
return
path = filepaths.block_data_location
shutil.rmtree(path)
_ignore_not_found_delete(dbfiles.block_meta_db)
_ignore_not_found_delete(filepaths.upload_list)
_ignore_not_found_delete(filepaths.usage_file)
onionrevents.event(&#39;softreset&#39;)
logger.info(&#34;Soft reset Onionr&#34;, terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.softreset.soft_reset" href="#src.onionrcommands.softreset.soft_reset">soft_reset</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,119 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.togglebootstrap API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.togglebootstrap</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Toggle the bootstrap configuration</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Toggle the bootstrap configuration
&#34;&#34;&#34;
import sys
import config
import logger
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def toggle_bootstrap_config():
&#34;&#34;&#34;Toggles the bootstrap configuration.&#34;&#34;&#34;
print(&#34;test&#34;)
if config.get(&#39;general.use_bootstrap_list&#39;) is None:
logger.error(&#39;No general.bootstrap_list setting found&#39;)
sys.exit(3)
flipped: bool = not config.get(&#39;general.use_bootstrap_list&#39;)
config.set(&#39;general.use_bootstrap_list&#39;, flipped, savefile=True)</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.togglebootstrap.toggle_bootstrap_config"><code class="name flex">
<span>def <span class="ident">toggle_bootstrap_config</span></span>(<span>)</span>
</code></dt>
<dd>
<section class="desc"><p>Toggles the bootstrap configuration.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def toggle_bootstrap_config():
&#34;&#34;&#34;Toggles the bootstrap configuration.&#34;&#34;&#34;
print(&#34;test&#34;)
if config.get(&#39;general.use_bootstrap_list&#39;) is None:
logger.error(&#39;No general.bootstrap_list setting found&#39;)
sys.exit(3)
flipped: bool = not config.get(&#39;general.use_bootstrap_list&#39;)
config.set(&#39;general.use_bootstrap_list&#39;, flipped, savefile=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.togglebootstrap.toggle_bootstrap_config" href="#src.onionrcommands.togglebootstrap.toggle_bootstrap_config">toggle_bootstrap_config</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>

View file

@ -0,0 +1,144 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.7.4" />
<title>src.onionrcommands.version API documentation</title>
<meta name="description" content="Onionr - Private P2P Communication …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>src.onionrcommands.version</code></h1>
</header>
<section id="section-intro">
<p>Onionr - Private P2P Communication.</p>
<p>Command to show version info</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Onionr - Private P2P Communication.
Command to show version info
&#34;&#34;&#34;
import platform
from utils import identifyhome
from etc import onionrvalues
import logger
&#34;&#34;&#34;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
&#34;&#34;&#34;
def version(verbosity=5, function=logger.info):
&#34;&#34;&#34;Display the Onionr version.&#34;&#34;&#34;
function(&#39;Onionr v%s (%s) (API v%s)&#39; % (onionrvalues.ONIONR_VERSION,
platform.machine(),
onionrvalues.API_VERSION),
terminal=True)
if verbosity &gt;= 1:
function(onionrvalues.ONIONR_TAGLINE, terminal=True)
if verbosity &gt;= 2:
pf = platform.platform()
release = platform.release()
python_imp = platform.python_implementation()
python_version = platform.python_version()
function(
f&#39;{python_imp} {python_version} on {pf} {release}&#39;,
terminal=True)
function(&#39;Onionr data dir: %s&#39; %
identifyhome.identify_home(), terminal=True)
version.onionr_help = &#39;Shows environment details including &#39; # type: ignore
version.onionr_help += &#39;Onionr version &amp; data directory, &#39; # type: ignore
version.onionr_help += &#39;OS and Python version&#39; # type: ignore</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="src.onionrcommands.version.version"><code class="name flex">
<span>def <span class="ident">version</span></span>(<span>verbosity=5, function=&lt;function info&gt;)</span>
</code></dt>
<dd>
<section class="desc"><p>Display the Onionr version.</p></section>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def version(verbosity=5, function=logger.info):
&#34;&#34;&#34;Display the Onionr version.&#34;&#34;&#34;
function(&#39;Onionr v%s (%s) (API v%s)&#39; % (onionrvalues.ONIONR_VERSION,
platform.machine(),
onionrvalues.API_VERSION),
terminal=True)
if verbosity &gt;= 1:
function(onionrvalues.ONIONR_TAGLINE, terminal=True)
if verbosity &gt;= 2:
pf = platform.platform()
release = platform.release()
python_imp = platform.python_implementation()
python_version = platform.python_version()
function(
f&#39;{python_imp} {python_version} on {pf} {release}&#39;,
terminal=True)
function(&#39;Onionr data dir: %s&#39; %
identifyhome.identify_home(), terminal=True)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="src.onionrcommands" href="index.html">src.onionrcommands</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="src.onionrcommands.version.version" href="#src.onionrcommands.version.version">version</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.7.4</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
</body>
</html>