refreshed and renamed docs, added bootstrap server, added default config for sec auditing
This commit is contained in:
parent
fe36b87c57
commit
6960d9209d
270 changed files with 20816 additions and 8345 deletions
160
docs/html/src/onionrcommands/banblocks.html
Normal file
160
docs/html/src/onionrcommands/banblocks.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
This file contains the command for banning blocks from the node
|
||||
"""
|
||||
import sys
|
||||
import logger
|
||||
from onionrutils import stringvalidators
|
||||
from onionrstorage import removeblock
|
||||
from onionrstorage import deleteBlock
|
||||
from onionrblocks import onionrblacklist
|
||||
from utils import reconstructhash
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def ban_block():
|
||||
"""Delete a block, permanently blacklisting it."""
|
||||
blacklist = onionrblacklist.OnionrBlackList()
|
||||
try:
|
||||
ban = sys.argv[2]
|
||||
except IndexError:
|
||||
# Get the hash if its not provided as a CLI argument
|
||||
ban = logger.readline('Enter a block hash:').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('Could not blacklist block',
|
||||
error=error, terminal=True)
|
||||
else:
|
||||
logger.info('Block blacklisted', terminal=True)
|
||||
else:
|
||||
logger.warn('That block is already blacklisted', terminal=True)
|
||||
else:
|
||||
logger.error('Invalid block hash', terminal=True)
|
||||
|
||||
|
||||
ban_block.onionr_help = "<block hash>: " # type: ignore
|
||||
ban_block.onionr_help += "deletes and blacklists a block" # 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():
|
||||
"""Delete a block, permanently blacklisting it."""
|
||||
blacklist = onionrblacklist.OnionrBlackList()
|
||||
try:
|
||||
ban = sys.argv[2]
|
||||
except IndexError:
|
||||
# Get the hash if its not provided as a CLI argument
|
||||
ban = logger.readline('Enter a block hash:').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('Could not blacklist block',
|
||||
error=error, terminal=True)
|
||||
else:
|
||||
logger.info('Block blacklisted', terminal=True)
|
||||
else:
|
||||
logger.warn('That block is already blacklisted', terminal=True)
|
||||
else:
|
||||
logger.error('Invalid block hash', 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>
|
133
docs/html/src/onionrcommands/daemonlaunch/getapihost.html
Normal file
133
docs/html/src/onionrcommands/daemonlaunch/getapihost.html
Normal 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">"""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
|
||||
"""
|
||||
from time import sleep
|
||||
|
||||
from filepaths import public_API_host_file
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def get_api_host_until_available() -> str:
|
||||
"""Wait for the api host to be available in the public api host file.
|
||||
|
||||
returns string of ip for the local public host interface
|
||||
"""
|
||||
api_host = ''
|
||||
while api_host == '':
|
||||
try:
|
||||
with open(public_API_host_file, 'r') 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() -> str:
|
||||
"""Wait for the api host to be available in the public api host file.
|
||||
|
||||
returns string of ip for the local public host interface
|
||||
"""
|
||||
api_host = ''
|
||||
while api_host == '':
|
||||
try:
|
||||
with open(public_API_host_file, 'r') 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>
|
511
docs/html/src/onionrcommands/daemonlaunch/index.html
Normal file
511
docs/html/src/onionrcommands/daemonlaunch/index.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
launch the api servers and communicator
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def _proper_shutdown():
|
||||
localcommand.local_command('shutdown')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def daemon():
|
||||
"""Start the Onionr communication daemon."""
|
||||
offline_mode = config.get('general.offline_mode', False)
|
||||
|
||||
if not hastor.has_tor():
|
||||
offline_mode = True
|
||||
logger.error("Tor is not present in system path or Onionr directory",
|
||||
terminal=True)
|
||||
|
||||
# remove runcheck if it exists
|
||||
if os.path.isfile(filepaths.run_check_file):
|
||||
logger.debug('Runcheck file found on daemon start, deleting.')
|
||||
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='client HTTP API').start()
|
||||
if not offline_mode:
|
||||
Thread(target=shared_state.get(apiservers.PublicAPI).start,
|
||||
daemon=True, name='public HTTP API').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 = ''
|
||||
if not offline_mode:
|
||||
apiHost = get_api_host_until_available()
|
||||
|
||||
logger.raw('', terminal=True)
|
||||
# print nice header thing :)
|
||||
if config.get('general.display_header', True):
|
||||
logoheader.header()
|
||||
version.version(verbosity=5, function=logger.info)
|
||||
logger.debug('Python version %s' % platform.python_version())
|
||||
|
||||
if onionrvalues.DEVELOPMENT_MODE:
|
||||
logger.warn('Development mode enabled', timestamp=False, terminal=True)
|
||||
|
||||
net = NetController(config.get('client.public.port', 59497),
|
||||
apiServerIP=apiHost)
|
||||
shared_state.add(net)
|
||||
|
||||
shared_state.get(onionrstatistics.tor.TorStats)
|
||||
|
||||
security_level = config.get('general.security_level', 1)
|
||||
use_existing_tor = config.get('tor.use_existing_tor', False)
|
||||
|
||||
if not offline_mode:
|
||||
|
||||
if use_existing_tor:
|
||||
try:
|
||||
os.mkdir(filepaths.tor_hs_loc)
|
||||
except FileExistsError:
|
||||
pass
|
||||
net.socksPort = config.get('tor.existing_socks_port')
|
||||
try:
|
||||
net.myID = create_onion_service(
|
||||
port=net.apiServerIP + ':' + str(net.hsPort))[0]
|
||||
except IncorrectPassword:
|
||||
logger.error('Invalid Tor control password', terminal=True)
|
||||
localcommand.local_command('shutdown')
|
||||
cleanup.delete_run_files()
|
||||
sys.exit(1)
|
||||
|
||||
if not net.myID.endswith('.onion'):
|
||||
net.myID += '.onion'
|
||||
with open(filepaths.tor_hs_address_file, 'w') as tor_file:
|
||||
tor_file.write(net.myID)
|
||||
else:
|
||||
logger.info('Tor is starting...', terminal=True)
|
||||
if not net.startTor():
|
||||
localcommand.local_command('shutdown')
|
||||
cleanup.delete_run_files()
|
||||
sys.exit(1)
|
||||
if len(net.myID) > 0 and security_level == 0:
|
||||
logger.debug('Started .onion service: %s' %
|
||||
(logger.colors.underline + net.myID))
|
||||
else:
|
||||
logger.debug('.onion service disabled')
|
||||
|
||||
logger.info('Using public key: %s' %
|
||||
(logger.colors.underline +
|
||||
getourkeypair.get_keypair()[0][:52]))
|
||||
|
||||
better_sleep(1)
|
||||
|
||||
events.event('init', threaded=False)
|
||||
events.event('daemon_start')
|
||||
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('general.security_level', 1) >= 2:
|
||||
filenuke.nuke.clean_tree(identifyhome.identify_home())
|
||||
|
||||
|
||||
def _ignore_sigint(sig, frame): # pylint: disable=W0612,W0613
|
||||
"""Space intentionally left blank."""
|
||||
return
|
||||
|
||||
|
||||
def kill_daemon():
|
||||
"""Shutdown the Onionr daemon (communicator)."""
|
||||
logger.warn('Stopping the running daemon...', 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('daemon_stop')
|
||||
net = NetController(config.get('client.port', 59496))
|
||||
try:
|
||||
spawn(
|
||||
localcommand.local_command,
|
||||
'/shutdownclean'
|
||||
).get(timeout=5)
|
||||
except sqlite3.OperationalError:
|
||||
pass
|
||||
|
||||
net.killTor()
|
||||
|
||||
|
||||
kill_daemon.onionr_help = "Gracefully stops the " # type: ignore
|
||||
kill_daemon.onionr_help += "Onionr API servers" # type: ignore
|
||||
|
||||
|
||||
def start(override: bool = False):
|
||||
"""If no lock file, make one and start onionr.
|
||||
|
||||
Error exit if there is and its not overridden
|
||||
"""
|
||||
if os.path.exists(filepaths.lock_file) and not override:
|
||||
logger.fatal('Cannot start. Daemon is already running,'
|
||||
+ ' or it did not exit cleanly.\n'
|
||||
+ ' (if you are sure that there is not a daemon running,'
|
||||
+ ' delete onionr.lock & try again).', terminal=True)
|
||||
else:
|
||||
if not onionrvalues.DEVELOPMENT_MODE:
|
||||
lock_file = open(filepaths.lock_file, 'w')
|
||||
lock_file.write('delete at your own risk')
|
||||
lock_file.close()
|
||||
|
||||
# Start Onionr daemon
|
||||
daemon()
|
||||
|
||||
try:
|
||||
os.remove(filepaths.lock_file)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
start.onionr_help = "Start Onionr node " # type: ignore
|
||||
start.onionr_help += "(public and clients API servers)" # 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():
|
||||
"""Start the Onionr communication daemon."""
|
||||
offline_mode = config.get('general.offline_mode', False)
|
||||
|
||||
if not hastor.has_tor():
|
||||
offline_mode = True
|
||||
logger.error("Tor is not present in system path or Onionr directory",
|
||||
terminal=True)
|
||||
|
||||
# remove runcheck if it exists
|
||||
if os.path.isfile(filepaths.run_check_file):
|
||||
logger.debug('Runcheck file found on daemon start, deleting.')
|
||||
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='client HTTP API').start()
|
||||
if not offline_mode:
|
||||
Thread(target=shared_state.get(apiservers.PublicAPI).start,
|
||||
daemon=True, name='public HTTP API').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 = ''
|
||||
if not offline_mode:
|
||||
apiHost = get_api_host_until_available()
|
||||
|
||||
logger.raw('', terminal=True)
|
||||
# print nice header thing :)
|
||||
if config.get('general.display_header', True):
|
||||
logoheader.header()
|
||||
version.version(verbosity=5, function=logger.info)
|
||||
logger.debug('Python version %s' % platform.python_version())
|
||||
|
||||
if onionrvalues.DEVELOPMENT_MODE:
|
||||
logger.warn('Development mode enabled', timestamp=False, terminal=True)
|
||||
|
||||
net = NetController(config.get('client.public.port', 59497),
|
||||
apiServerIP=apiHost)
|
||||
shared_state.add(net)
|
||||
|
||||
shared_state.get(onionrstatistics.tor.TorStats)
|
||||
|
||||
security_level = config.get('general.security_level', 1)
|
||||
use_existing_tor = config.get('tor.use_existing_tor', False)
|
||||
|
||||
if not offline_mode:
|
||||
|
||||
if use_existing_tor:
|
||||
try:
|
||||
os.mkdir(filepaths.tor_hs_loc)
|
||||
except FileExistsError:
|
||||
pass
|
||||
net.socksPort = config.get('tor.existing_socks_port')
|
||||
try:
|
||||
net.myID = create_onion_service(
|
||||
port=net.apiServerIP + ':' + str(net.hsPort))[0]
|
||||
except IncorrectPassword:
|
||||
logger.error('Invalid Tor control password', terminal=True)
|
||||
localcommand.local_command('shutdown')
|
||||
cleanup.delete_run_files()
|
||||
sys.exit(1)
|
||||
|
||||
if not net.myID.endswith('.onion'):
|
||||
net.myID += '.onion'
|
||||
with open(filepaths.tor_hs_address_file, 'w') as tor_file:
|
||||
tor_file.write(net.myID)
|
||||
else:
|
||||
logger.info('Tor is starting...', terminal=True)
|
||||
if not net.startTor():
|
||||
localcommand.local_command('shutdown')
|
||||
cleanup.delete_run_files()
|
||||
sys.exit(1)
|
||||
if len(net.myID) > 0 and security_level == 0:
|
||||
logger.debug('Started .onion service: %s' %
|
||||
(logger.colors.underline + net.myID))
|
||||
else:
|
||||
logger.debug('.onion service disabled')
|
||||
|
||||
logger.info('Using public key: %s' %
|
||||
(logger.colors.underline +
|
||||
getourkeypair.get_keypair()[0][:52]))
|
||||
|
||||
better_sleep(1)
|
||||
|
||||
events.event('init', threaded=False)
|
||||
events.event('daemon_start')
|
||||
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('general.security_level', 1) >= 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():
|
||||
"""Shutdown the Onionr daemon (communicator)."""
|
||||
logger.warn('Stopping the running daemon...', 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('daemon_stop')
|
||||
net = NetController(config.get('client.port', 59496))
|
||||
try:
|
||||
spawn(
|
||||
localcommand.local_command,
|
||||
'/shutdownclean'
|
||||
).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):
|
||||
"""If no lock file, make one and start onionr.
|
||||
|
||||
Error exit if there is and its not overridden
|
||||
"""
|
||||
if os.path.exists(filepaths.lock_file) and not override:
|
||||
logger.fatal('Cannot start. Daemon is already running,'
|
||||
+ ' or it did not exit cleanly.\n'
|
||||
+ ' (if you are sure that there is not a daemon running,'
|
||||
+ ' delete onionr.lock & try again).', terminal=True)
|
||||
else:
|
||||
if not onionrvalues.DEVELOPMENT_MODE:
|
||||
lock_file = open(filepaths.lock_file, 'w')
|
||||
lock_file.write('delete at your own risk')
|
||||
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>
|
142
docs/html/src/onionrcommands/exportblocks.html
Normal file
142
docs/html/src/onionrcommands/exportblocks.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
This file handles the command for exporting blocks to disk
|
||||
"""
|
||||
import sys
|
||||
|
||||
import logger
|
||||
import onionrstorage
|
||||
from utils import createdirs
|
||||
from onionrutils import stringvalidators
|
||||
import filepaths
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def _do_export(b_hash):
|
||||
createdirs.create_dirs()
|
||||
data = onionrstorage.getData(b_hash)
|
||||
with open('%s/%s.dat' % (filepaths.export_location,
|
||||
b_hash), 'wb') as export:
|
||||
export.write(data)
|
||||
logger.info('Block exported as file', terminal=True)
|
||||
|
||||
|
||||
def export_block():
|
||||
"""Export block based on hash from stdin or argv."""
|
||||
try:
|
||||
if not stringvalidators.validate_hash(sys.argv[2]):
|
||||
raise ValueError
|
||||
except (IndexError, ValueError):
|
||||
logger.error('No valid block hash specified.', terminal=True)
|
||||
sys.exit(1)
|
||||
else:
|
||||
b_hash = sys.argv[2]
|
||||
_do_export(b_hash)
|
||||
|
||||
|
||||
export_block.onionr_help = "<block hash>: Export block to " # type: ignore
|
||||
export_block.onionr_help += "a file. Export directory is in " # type: ignore
|
||||
export_block.onionr_help += "Onionr home under block-export" # 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():
|
||||
"""Export block based on hash from stdin or argv."""
|
||||
try:
|
||||
if not stringvalidators.validate_hash(sys.argv[2]):
|
||||
raise ValueError
|
||||
except (IndexError, ValueError):
|
||||
logger.error('No valid block hash specified.', 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>
|
262
docs/html/src/onionrcommands/filecommands.html
Normal file
262
docs/html/src/onionrcommands/filecommands.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
This file handles the commands for adding
|
||||
and getting files from the Onionr network
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
_ORIG_DIR = onionrvalues.ORIG_RUN_DIR_ENV_VAR
|
||||
|
||||
|
||||
def _get_dir(path: str) -> str:
|
||||
if not os.getenv(_ORIG_DIR) is None:
|
||||
return os.getenv(_ORIG_DIR) + '/' + path # type: ignore
|
||||
else:
|
||||
return path
|
||||
|
||||
|
||||
def add_html(singleBlock=True, blockType='html'):
|
||||
"""Create one-off web page from HTML file, no ext resources."""
|
||||
add_file(blockType=blockType)
|
||||
|
||||
|
||||
add_html.onionr_help = "Adds an HTML file into Onionr. Does " # type: ignore
|
||||
add_html.onionr_help += "not include dependant resources" # type: ignore
|
||||
|
||||
|
||||
def add_file(blockType='bin'):
|
||||
"""Add a file to the onionr network."""
|
||||
if len(sys.argv) >= 3:
|
||||
filename = sys.argv[2]
|
||||
|
||||
if not os.path.exists(_get_dir(filename)):
|
||||
logger.error(
|
||||
'That file does not exist. Improper path (specify full path)?',
|
||||
terminal=True)
|
||||
return
|
||||
logger.info('Adding file, this might take a long time.',
|
||||
terminal=True)
|
||||
try:
|
||||
with open(_get_dir(filename), 'rb') as single_file:
|
||||
blockhash = insert(single_file.read(), header=blockType)
|
||||
if len(blockhash) > 0:
|
||||
logger.info('File %s saved in block %s' %
|
||||
(filename, blockhash), terminal=True)
|
||||
except Exception as err: # pylint: disable=W0703
|
||||
logger.error('Failed to save file in block ' +
|
||||
str(err), timestamp=False, terminal=True)
|
||||
else:
|
||||
logger.error('%s add-file <filename>' %
|
||||
sys.argv[0], timestamp=False, terminal=True)
|
||||
|
||||
|
||||
add_file.onionr_help = "<file path> Add a file into " # type: ignore
|
||||
add_file.onionr_help += "the Onionr network" # type: ignore
|
||||
|
||||
|
||||
def get_file():
|
||||
"""Get a file from onionr blocks."""
|
||||
try:
|
||||
file_name = _get_dir(sys.argv[2])
|
||||
bHash = sys.argv[3]
|
||||
except IndexError:
|
||||
logger.error("Syntax %s %s" % (
|
||||
sys.argv[0], '/path/to/filename <blockhash>'), terminal=True)
|
||||
else:
|
||||
logger.info(file_name, terminal=True)
|
||||
|
||||
if os.path.exists(file_name):
|
||||
logger.error("File already exists", terminal=True)
|
||||
return
|
||||
if not stringvalidators.validate_hash(bHash):
|
||||
logger.error('Block hash is invalid', terminal=True)
|
||||
return
|
||||
|
||||
try:
|
||||
with open(file_name, 'wb') as my_file:
|
||||
my_file.write(Block(bHash).bcontent)
|
||||
except onionrexceptions.NoDataAvailable:
|
||||
logger.error(
|
||||
'That block is not available. Trying again later may work.',
|
||||
terminal=True)
|
||||
|
||||
|
||||
get_file.onionr_help = "<file path> <block hash>: Download " # type: ignore
|
||||
get_file.onionr_help += "a file from the onionr network." # 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='bin'):
|
||||
"""Add a file to the onionr network."""
|
||||
if len(sys.argv) >= 3:
|
||||
filename = sys.argv[2]
|
||||
|
||||
if not os.path.exists(_get_dir(filename)):
|
||||
logger.error(
|
||||
'That file does not exist. Improper path (specify full path)?',
|
||||
terminal=True)
|
||||
return
|
||||
logger.info('Adding file, this might take a long time.',
|
||||
terminal=True)
|
||||
try:
|
||||
with open(_get_dir(filename), 'rb') as single_file:
|
||||
blockhash = insert(single_file.read(), header=blockType)
|
||||
if len(blockhash) > 0:
|
||||
logger.info('File %s saved in block %s' %
|
||||
(filename, blockhash), terminal=True)
|
||||
except Exception as err: # pylint: disable=W0703
|
||||
logger.error('Failed to save file in block ' +
|
||||
str(err), timestamp=False, terminal=True)
|
||||
else:
|
||||
logger.error('%s add-file <filename>' %
|
||||
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='html'):
|
||||
"""Create one-off web page from HTML file, no ext resources."""
|
||||
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():
|
||||
"""Get a file from onionr blocks."""
|
||||
try:
|
||||
file_name = _get_dir(sys.argv[2])
|
||||
bHash = sys.argv[3]
|
||||
except IndexError:
|
||||
logger.error("Syntax %s %s" % (
|
||||
sys.argv[0], '/path/to/filename <blockhash>'), terminal=True)
|
||||
else:
|
||||
logger.info(file_name, terminal=True)
|
||||
|
||||
if os.path.exists(file_name):
|
||||
logger.error("File already exists", terminal=True)
|
||||
return
|
||||
if not stringvalidators.validate_hash(bHash):
|
||||
logger.error('Block hash is invalid', terminal=True)
|
||||
return
|
||||
|
||||
try:
|
||||
with open(file_name, 'wb') as my_file:
|
||||
my_file.write(Block(bHash).bcontent)
|
||||
except onionrexceptions.NoDataAvailable:
|
||||
logger.error(
|
||||
'That block is not available. Trying again later may work.',
|
||||
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>
|
150
docs/html/src/onionrcommands/index.html
Normal file
150
docs/html/src/onionrcommands/index.html
Normal 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>
|
133
docs/html/src/onionrcommands/keyadders.html
Normal file
133
docs/html/src/onionrcommands/keyadders.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
add keys (transport and pubkey)
|
||||
"""
|
||||
import sys
|
||||
import logger
|
||||
from coredb import keydb
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def add_address():
|
||||
"""Command to add a peer address from either an arg or stdin."""
|
||||
try:
|
||||
newAddress = sys.argv[2]
|
||||
newAddress = newAddress.replace('http:', '').replace('/', '')
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
logger.info("Adding address: " + logger.colors.underline + newAddress,
|
||||
terminal=True)
|
||||
if keydb.addkeys.add_address(newAddress):
|
||||
logger.info("Successfully added address.", terminal=True)
|
||||
else:
|
||||
logger.warn("Unable to add address.", terminal=True)
|
||||
|
||||
|
||||
add_address.onionr_help = "Adds a node transport address" # 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():
|
||||
"""Command to add a peer address from either an arg or stdin."""
|
||||
try:
|
||||
newAddress = sys.argv[2]
|
||||
newAddress = newAddress.replace('http:', '').replace('/', '')
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
logger.info("Adding address: " + logger.colors.underline + newAddress,
|
||||
terminal=True)
|
||||
if keydb.addkeys.add_address(newAddress):
|
||||
logger.info("Successfully added address.", terminal=True)
|
||||
else:
|
||||
logger.warn("Unable to add address.", 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>
|
127
docs/html/src/onionrcommands/motdcreator.html
Normal file
127
docs/html/src/onionrcommands/motdcreator.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Command to make new network-wide MOTD message. Only network admin can do this
|
||||
The key is set in onionrvalues
|
||||
"""
|
||||
import onionrblocks
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def motd_creator():
|
||||
"""Create a new MOTD message for the Onionr network."""
|
||||
motd = ''
|
||||
new = ''
|
||||
print('Enter a new MOTD, quit on a new line:')
|
||||
while new != 'quit':
|
||||
new = input() # nosec B323
|
||||
if new != 'quit':
|
||||
motd += new
|
||||
bl = onionrblocks.insert(motd, header='motd', sign=True)
|
||||
print(f"inserted in {bl}")
|
||||
|
||||
|
||||
motd_creator.onionr_help = "Create a new MOTD for the network" # 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():
|
||||
"""Create a new MOTD message for the Onionr network."""
|
||||
motd = ''
|
||||
new = ''
|
||||
print('Enter a new MOTD, quit on a new line:')
|
||||
while new != 'quit':
|
||||
new = input() # nosec B323
|
||||
if new != 'quit':
|
||||
motd += new
|
||||
bl = onionrblocks.insert(motd, header='motd', sign=True)
|
||||
print(f"inserted in {bl}")</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>
|
367
docs/html/src/onionrcommands/onionrstatistics.html
Normal file
367
docs/html/src/onionrcommands/onionrstatistics.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
This module defines commands to show stats/details about the local node
|
||||
"""
|
||||
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
|
||||
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def show_stats():
|
||||
"""Print/log statistic info about our Onionr install."""
|
||||
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
|
||||
'Onionr Daemon Status':
|
||||
((logger.colors.fg.green + 'Online')
|
||||
if check_communicator(timeout=9)
|
||||
else logger.colors.fg.red + 'Offline'),
|
||||
|
||||
# file and folder size stats
|
||||
'div1': True, # this creates a solid line across the screen, a div
|
||||
'Total Block Size':
|
||||
sizeutils.human_size(sizeutils.size(home + 'blocks/')),
|
||||
'Total Plugin Size':
|
||||
sizeutils.human_size(sizeutils.size(home + 'plugins/')),
|
||||
'Log File Size':
|
||||
sizeutils.human_size(sizeutils.size(home + 'output.log')),
|
||||
|
||||
# count stats
|
||||
'div2': True,
|
||||
'Known Peers (nodes)':
|
||||
str(max(len(keydb.listkeys.list_adders()) - 1, 0)),
|
||||
'Enabled Plugins':
|
||||
str(len(config.get('plugins.enabled', list()))) + ' / ' +
|
||||
str(len(os.listdir(home + 'plugins/'))),
|
||||
'Stored Blocks': str(totalBlocks),
|
||||
'Deleted Blocks': str(totalBanned)
|
||||
}
|
||||
|
||||
# color configuration
|
||||
colors = {
|
||||
'title': logger.colors.bold,
|
||||
'key': logger.colors.fg.lightgreen,
|
||||
'val': logger.colors.fg.green,
|
||||
'border': logger.colors.fg.lightblue,
|
||||
|
||||
'reset': 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(' | ')
|
||||
groupsize = width - prewidth - len('[+] ')
|
||||
|
||||
# generate stats table
|
||||
logger.info(colors['title'] + 'Onionr v%s Statistics' %
|
||||
onionrvalues.ONIONR_VERSION + colors['reset'],
|
||||
terminal=True)
|
||||
logger.info(colors['border'] + '-' * (maxlength + 1) +
|
||||
'+' + colors['reset'], 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['key'] + str(key).rjust(maxlength) +
|
||||
colors['reset'] + colors['border'] +
|
||||
' | ' + colors['reset'] + colors['val'] +
|
||||
str(val.pop(0)) + colors['reset'], terminal=True)
|
||||
|
||||
for value in val:
|
||||
logger.info(' ' * maxlength + colors['border'] + ' | ' +
|
||||
colors['reset'] + colors['val'] + str(
|
||||
value) + colors['reset'], terminal=True)
|
||||
else:
|
||||
logger.info(colors['border'] + '-' * (maxlength +
|
||||
1) + '+' +
|
||||
colors['reset'], terminal=True)
|
||||
logger.info(colors['border'] + '-' * (maxlength + 1) +
|
||||
'+' + colors['reset'], terminal=True)
|
||||
except Exception as e: # pylint: disable=W0703
|
||||
logger.error('Failed to generate statistics table. ' +
|
||||
str(e), error=e, timestamp=False, terminal=True)
|
||||
|
||||
|
||||
def show_details():
|
||||
"""Print out details.
|
||||
|
||||
node transport address(es)
|
||||
active user ID
|
||||
active user ID in mnemonic form
|
||||
"""
|
||||
details = {
|
||||
'Node Address': gethostname.get_hostname(),
|
||||
'Public Key': onionrcrypto.pub_key.replace('=', ''),
|
||||
'Human-readable Public Key': mnemonickeys.get_human_readable_ID()
|
||||
}
|
||||
|
||||
for detail in details:
|
||||
logger.info('%s%s: \n%s%s\n' % (logger.colors.fg.lightgreen,
|
||||
detail, logger.colors.fg.green,
|
||||
details[detail]), terminal=True)
|
||||
|
||||
|
||||
show_details.onionr_help = "Shows relevant information " # type: ignore
|
||||
show_details.onionr_help += "for your Onionr install: node " # type: ignore
|
||||
show_details.onionr_help += "address, and active public key." # type: ignore
|
||||
|
||||
show_stats.onionr_help = "Shows statistics for your Onionr " # type: ignore
|
||||
show_stats.onionr_help += "node. Slow if Onionr is not running" # 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, 'w+').close()
|
||||
|
||||
starttime = time.time()
|
||||
|
||||
while True:
|
||||
time.sleep(interval)
|
||||
|
||||
if not os.path.isfile(runcheck_file):
|
||||
return True
|
||||
elif time.time() - starttime >= 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():
|
||||
"""Print out details.
|
||||
|
||||
node transport address(es)
|
||||
active user ID
|
||||
active user ID in mnemonic form
|
||||
"""
|
||||
details = {
|
||||
'Node Address': gethostname.get_hostname(),
|
||||
'Public Key': onionrcrypto.pub_key.replace('=', ''),
|
||||
'Human-readable Public Key': mnemonickeys.get_human_readable_ID()
|
||||
}
|
||||
|
||||
for detail in details:
|
||||
logger.info('%s%s: \n%s%s\n' % (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():
|
||||
"""Print/log statistic info about our Onionr install."""
|
||||
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
|
||||
'Onionr Daemon Status':
|
||||
((logger.colors.fg.green + 'Online')
|
||||
if check_communicator(timeout=9)
|
||||
else logger.colors.fg.red + 'Offline'),
|
||||
|
||||
# file and folder size stats
|
||||
'div1': True, # this creates a solid line across the screen, a div
|
||||
'Total Block Size':
|
||||
sizeutils.human_size(sizeutils.size(home + 'blocks/')),
|
||||
'Total Plugin Size':
|
||||
sizeutils.human_size(sizeutils.size(home + 'plugins/')),
|
||||
'Log File Size':
|
||||
sizeutils.human_size(sizeutils.size(home + 'output.log')),
|
||||
|
||||
# count stats
|
||||
'div2': True,
|
||||
'Known Peers (nodes)':
|
||||
str(max(len(keydb.listkeys.list_adders()) - 1, 0)),
|
||||
'Enabled Plugins':
|
||||
str(len(config.get('plugins.enabled', list()))) + ' / ' +
|
||||
str(len(os.listdir(home + 'plugins/'))),
|
||||
'Stored Blocks': str(totalBlocks),
|
||||
'Deleted Blocks': str(totalBanned)
|
||||
}
|
||||
|
||||
# color configuration
|
||||
colors = {
|
||||
'title': logger.colors.bold,
|
||||
'key': logger.colors.fg.lightgreen,
|
||||
'val': logger.colors.fg.green,
|
||||
'border': logger.colors.fg.lightblue,
|
||||
|
||||
'reset': 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(' | ')
|
||||
groupsize = width - prewidth - len('[+] ')
|
||||
|
||||
# generate stats table
|
||||
logger.info(colors['title'] + 'Onionr v%s Statistics' %
|
||||
onionrvalues.ONIONR_VERSION + colors['reset'],
|
||||
terminal=True)
|
||||
logger.info(colors['border'] + '-' * (maxlength + 1) +
|
||||
'+' + colors['reset'], 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['key'] + str(key).rjust(maxlength) +
|
||||
colors['reset'] + colors['border'] +
|
||||
' | ' + colors['reset'] + colors['val'] +
|
||||
str(val.pop(0)) + colors['reset'], terminal=True)
|
||||
|
||||
for value in val:
|
||||
logger.info(' ' * maxlength + colors['border'] + ' | ' +
|
||||
colors['reset'] + colors['val'] + str(
|
||||
value) + colors['reset'], terminal=True)
|
||||
else:
|
||||
logger.info(colors['border'] + '-' * (maxlength +
|
||||
1) + '+' +
|
||||
colors['reset'], terminal=True)
|
||||
logger.info(colors['border'] + '-' * (maxlength + 1) +
|
||||
'+' + colors['reset'], terminal=True)
|
||||
except Exception as e: # pylint: disable=W0703
|
||||
logger.error('Failed to generate statistics table. ' +
|
||||
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>
|
179
docs/html/src/onionrcommands/openwebinterface.html
Normal file
179
docs/html/src/onionrcommands/openwebinterface.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Open the web interface properly into a web browser
|
||||
"""
|
||||
import webbrowser
|
||||
import logger
|
||||
from onionrutils import getclientapiserver
|
||||
import config
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def get_url() -> str:
|
||||
"""Build UI URL string and return it."""
|
||||
try:
|
||||
url = getclientapiserver.get_client_API_server()
|
||||
except FileNotFoundError:
|
||||
url = ""
|
||||
logger.error(
|
||||
'Onionr seems to not be running (could not get api host)',
|
||||
terminal=True)
|
||||
else:
|
||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
||||
logger.info('Onionr web interface URL: ' + url, terminal=True)
|
||||
return url
|
||||
|
||||
|
||||
get_url.onionr_help = "Shows the Onionr " # type: ignore
|
||||
get_url.onionr_help += "web interface URL with API key" # type: ignore
|
||||
|
||||
|
||||
def open_home():
|
||||
"""Command to open web interface URL in default browser."""
|
||||
try:
|
||||
url = getclientapiserver.get_client_API_server()
|
||||
except FileNotFoundError:
|
||||
logger.error(
|
||||
'Onionr seems to not be running (could not get api host)',
|
||||
terminal=True)
|
||||
else:
|
||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
||||
logger.info(
|
||||
'If Onionr does not open automatically, use this URL: ' + url,
|
||||
terminal=True)
|
||||
webbrowser.open_new_tab(url)
|
||||
|
||||
|
||||
open_home.onionr_help = "Opens the Onionr UI in the default " # type: ignore
|
||||
open_home.onionr_help += "browser. Node must be running." # 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() -> str:
|
||||
"""Build UI URL string and return it."""
|
||||
try:
|
||||
url = getclientapiserver.get_client_API_server()
|
||||
except FileNotFoundError:
|
||||
url = ""
|
||||
logger.error(
|
||||
'Onionr seems to not be running (could not get api host)',
|
||||
terminal=True)
|
||||
else:
|
||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
||||
logger.info('Onionr web interface URL: ' + 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():
|
||||
"""Command to open web interface URL in default browser."""
|
||||
try:
|
||||
url = getclientapiserver.get_client_API_server()
|
||||
except FileNotFoundError:
|
||||
logger.error(
|
||||
'Onionr seems to not be running (could not get api host)',
|
||||
terminal=True)
|
||||
else:
|
||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
||||
logger.info(
|
||||
'If Onionr does not open automatically, use this URL: ' + 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>
|
274
docs/html/src/onionrcommands/parser/arguments.html
Normal file
274
docs/html/src/onionrcommands/parser/arguments.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Sets CLI arguments for Onionr
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def get_arguments() -> dict:
|
||||
"""Return command argument dict, minus plugin cmds.
|
||||
|
||||
This is a function because we need to be able to
|
||||
dynamically modify them with plugins
|
||||
"""
|
||||
args = {
|
||||
('blacklist', 'blacklist-block', 'remove-block',
|
||||
'removeblock', 'banblock', 'ban-block'): banblocks.ban_block,
|
||||
('details', 'info'): onionrstatistics.show_details,
|
||||
('stats', 'statistics'): onionrstatistics.show_stats,
|
||||
('version',): version.version,
|
||||
('start', 'daemon'): daemonlaunch.start,
|
||||
('stop', 'kill'): daemonlaunch.kill_daemon,
|
||||
('restart',): restartonionr.restart,
|
||||
('add-address', 'addaddress', 'addadder'): keyadders.add_address,
|
||||
('openhome', 'gui', 'openweb',
|
||||
'open-home', 'open-web'): openwebinterface.open_home,
|
||||
('get-url', 'url', 'get-web'): openwebinterface.get_url,
|
||||
('addhtml', 'add-html'): filecommands.add_html,
|
||||
('addsite', 'add-site',
|
||||
'update-site', 'updatesite'): sitecreator.create_multipage_site,
|
||||
('addfile', 'add-file'): filecommands.add_file,
|
||||
('get-file', 'getfile'): filecommands.get_file,
|
||||
('export-block', 'exportblock'): exportblocks.export_block,
|
||||
('importblocks',
|
||||
'import-blocks', 'import-block'): importnewblocks.import_new_blocks,
|
||||
('addid', 'add-id'): pubkeymanager.add_ID,
|
||||
('changeid', 'change-id'): pubkeymanager.change_ID,
|
||||
('add-vanity', 'addvanity'): pubkeymanager.add_vanity,
|
||||
('resettor', 'reset-tor'): resettor.reset_tor,
|
||||
('resetplugins', 'reset-plugins'): resetplugins.reset,
|
||||
('reset-tor-node-transport',): resettor.reset_tor_key_pair,
|
||||
('soft-reset', 'softreset'): softreset.soft_reset,
|
||||
('toggle-bootstrap', 'togglebootstrap'):
|
||||
togglebootstrap.toggle_bootstrap_config,
|
||||
('runtime-test', 'runtimetest'): runtimetestcmd.do_runtime_test,
|
||||
('makemotd', 'make-motd'): motdcreator.motd_creator
|
||||
|
||||
}
|
||||
return args
|
||||
|
||||
|
||||
def get_help(arg: str) -> str:
|
||||
"""Return the help info string from a given command."""
|
||||
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) -> Callable:
|
||||
"""Return the function for a given command argument."""
|
||||
argument = argument.lower()
|
||||
args = get_arguments()
|
||||
|
||||
for arg in args.keys(): # Iterate command alias sets
|
||||
"""
|
||||
If our argument is in the current alias set,
|
||||
return the command function
|
||||
"""
|
||||
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() -> dict:
|
||||
"""Return command argument dict, minus plugin cmds.
|
||||
|
||||
This is a function because we need to be able to
|
||||
dynamically modify them with plugins
|
||||
"""
|
||||
args = {
|
||||
('blacklist', 'blacklist-block', 'remove-block',
|
||||
'removeblock', 'banblock', 'ban-block'): banblocks.ban_block,
|
||||
('details', 'info'): onionrstatistics.show_details,
|
||||
('stats', 'statistics'): onionrstatistics.show_stats,
|
||||
('version',): version.version,
|
||||
('start', 'daemon'): daemonlaunch.start,
|
||||
('stop', 'kill'): daemonlaunch.kill_daemon,
|
||||
('restart',): restartonionr.restart,
|
||||
('add-address', 'addaddress', 'addadder'): keyadders.add_address,
|
||||
('openhome', 'gui', 'openweb',
|
||||
'open-home', 'open-web'): openwebinterface.open_home,
|
||||
('get-url', 'url', 'get-web'): openwebinterface.get_url,
|
||||
('addhtml', 'add-html'): filecommands.add_html,
|
||||
('addsite', 'add-site',
|
||||
'update-site', 'updatesite'): sitecreator.create_multipage_site,
|
||||
('addfile', 'add-file'): filecommands.add_file,
|
||||
('get-file', 'getfile'): filecommands.get_file,
|
||||
('export-block', 'exportblock'): exportblocks.export_block,
|
||||
('importblocks',
|
||||
'import-blocks', 'import-block'): importnewblocks.import_new_blocks,
|
||||
('addid', 'add-id'): pubkeymanager.add_ID,
|
||||
('changeid', 'change-id'): pubkeymanager.change_ID,
|
||||
('add-vanity', 'addvanity'): pubkeymanager.add_vanity,
|
||||
('resettor', 'reset-tor'): resettor.reset_tor,
|
||||
('resetplugins', 'reset-plugins'): resetplugins.reset,
|
||||
('reset-tor-node-transport',): resettor.reset_tor_key_pair,
|
||||
('soft-reset', 'softreset'): softreset.soft_reset,
|
||||
('toggle-bootstrap', 'togglebootstrap'):
|
||||
togglebootstrap.toggle_bootstrap_config,
|
||||
('runtime-test', 'runtimetest'): runtimetestcmd.do_runtime_test,
|
||||
('makemotd', 'make-motd'): 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) -> Callable:
|
||||
"""Return the function for a given command argument."""
|
||||
argument = argument.lower()
|
||||
args = get_arguments()
|
||||
|
||||
for arg in args.keys(): # Iterate command alias sets
|
||||
"""
|
||||
If our argument is in the current alias set,
|
||||
return the command function
|
||||
"""
|
||||
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) -> str:
|
||||
"""Return the help info string from a given command."""
|
||||
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>
|
342
docs/html/src/onionrcommands/parser/index.html
Normal file
342
docs/html/src/onionrcommands/parser/index.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
This module loads in the Onionr arguments and their help messages
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
import logger
|
||||
import onionrexceptions
|
||||
import onionrplugins
|
||||
from onionrplugins import onionrpluginapi
|
||||
from . import arguments, recommend
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def plugin_command(cmd):
|
||||
"""Build a plugin command function name."""
|
||||
return f'on_{cmd}_cmd'
|
||||
|
||||
|
||||
def register_plugin_commands(cmd) -> bool:
|
||||
"""Find a plugin command hook and execute it for a given cmd."""
|
||||
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():
|
||||
"""Register commands and handles help command processing."""
|
||||
def get_help_message(cmd: str,
|
||||
default: str = 'No help available for this command'):
|
||||
"""Print help message for a given command, supports plugin commands."""
|
||||
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 = "onionr"
|
||||
|
||||
# Get the command
|
||||
try:
|
||||
cmd = sys.argv[1]
|
||||
except IndexError:
|
||||
logger.debug("Detected Onionr run with no commands specified")
|
||||
return
|
||||
|
||||
is_help_cmd = False
|
||||
if cmd.replace('--', '').lower() == 'help':
|
||||
is_help_cmd = True
|
||||
|
||||
try:
|
||||
try:
|
||||
if cmd not in ('start', 'details', 'show-details'):
|
||||
os.chdir(os.environ['ORIG_ONIONR_RUN_DIR'])
|
||||
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('%s <%s>: %s' % (PROGRAM_NAME, '/'.join(i),
|
||||
get_help_message(i[0])))
|
||||
for pl in onionrplugins.get_enabled_plugins():
|
||||
pl = onionrplugins.get_plugin(pl)
|
||||
if hasattr(pl, 'ONIONR_COMMANDS'):
|
||||
print('')
|
||||
try:
|
||||
_show_term('%s commands:' % (pl.plugin_name,))
|
||||
except AttributeError:
|
||||
_show_term('%s commands:' % (pl.__name__,))
|
||||
for plugin_cmd in pl.ONIONR_COMMANDS:
|
||||
_show_term('%s %s: %s' %
|
||||
(PROGRAM_NAME,
|
||||
plugin_cmd,
|
||||
get_help_message(plugin_cmd)),)
|
||||
print('')
|
||||
else:
|
||||
try:
|
||||
_show_term('%s %s: %s' % (PROGRAM_NAME,
|
||||
sys.argv[2],
|
||||
get_help_message(sys.argv[2])))
|
||||
except KeyError:
|
||||
logger.error('%s: command does not exist.' % [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):
|
||||
"""Build a plugin command function name."""
|
||||
return f'on_{cmd}_cmd'</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():
|
||||
"""Register commands and handles help command processing."""
|
||||
def get_help_message(cmd: str,
|
||||
default: str = 'No help available for this command'):
|
||||
"""Print help message for a given command, supports plugin commands."""
|
||||
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 = "onionr"
|
||||
|
||||
# Get the command
|
||||
try:
|
||||
cmd = sys.argv[1]
|
||||
except IndexError:
|
||||
logger.debug("Detected Onionr run with no commands specified")
|
||||
return
|
||||
|
||||
is_help_cmd = False
|
||||
if cmd.replace('--', '').lower() == 'help':
|
||||
is_help_cmd = True
|
||||
|
||||
try:
|
||||
try:
|
||||
if cmd not in ('start', 'details', 'show-details'):
|
||||
os.chdir(os.environ['ORIG_ONIONR_RUN_DIR'])
|
||||
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('%s <%s>: %s' % (PROGRAM_NAME, '/'.join(i),
|
||||
get_help_message(i[0])))
|
||||
for pl in onionrplugins.get_enabled_plugins():
|
||||
pl = onionrplugins.get_plugin(pl)
|
||||
if hasattr(pl, 'ONIONR_COMMANDS'):
|
||||
print('')
|
||||
try:
|
||||
_show_term('%s commands:' % (pl.plugin_name,))
|
||||
except AttributeError:
|
||||
_show_term('%s commands:' % (pl.__name__,))
|
||||
for plugin_cmd in pl.ONIONR_COMMANDS:
|
||||
_show_term('%s %s: %s' %
|
||||
(PROGRAM_NAME,
|
||||
plugin_cmd,
|
||||
get_help_message(plugin_cmd)),)
|
||||
print('')
|
||||
else:
|
||||
try:
|
||||
_show_term('%s %s: %s' % (PROGRAM_NAME,
|
||||
sys.argv[2],
|
||||
get_help_message(sys.argv[2])))
|
||||
except KeyError:
|
||||
logger.error('%s: command does not exist.' % [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) -> bool:
|
||||
"""Find a plugin command hook and execute it for a given cmd."""
|
||||
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>
|
131
docs/html/src/onionrcommands/parser/recommend.html
Normal file
131
docs/html/src/onionrcommands/parser/recommend.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Try to provide recommendations for invalid Onionr commands
|
||||
"""
|
||||
import sys
|
||||
from difflib import SequenceMatcher
|
||||
import logger
|
||||
from . import arguments
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def recommend(print_default: bool = True):
|
||||
"""Print out a recommendation for argv cmd if one is available."""
|
||||
tried = sys.argv[1]
|
||||
args = arguments.get_arguments()
|
||||
print_message = 'Command not found:'
|
||||
for key in args.keys():
|
||||
for word in key:
|
||||
if SequenceMatcher(None, tried, word).ratio() >= 0.75:
|
||||
logger.warn(f'{print_message} "{tried}", '
|
||||
+ f'did you mean "{word}"?',
|
||||
terminal=True)
|
||||
return
|
||||
if print_default:
|
||||
logger.error('%s "%s"' % (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):
|
||||
"""Print out a recommendation for argv cmd if one is available."""
|
||||
tried = sys.argv[1]
|
||||
args = arguments.get_arguments()
|
||||
print_message = 'Command not found:'
|
||||
for key in args.keys():
|
||||
for word in key:
|
||||
if SequenceMatcher(None, tried, word).ratio() >= 0.75:
|
||||
logger.warn(f'{print_message} "{tried}", '
|
||||
+ f'did you mean "{word}"?',
|
||||
terminal=True)
|
||||
return
|
||||
if print_default:
|
||||
logger.error('%s "%s"' % (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>
|
366
docs/html/src/onionrcommands/pubkeymanager.html
Normal file
366
docs/html/src/onionrcommands/pubkeymanager.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
This module defines user ID-related CLI commands
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
DETERMINISTIC_REQUIREMENT = onionrvalues.PASSWORD_LENGTH
|
||||
|
||||
|
||||
def add_ID():
|
||||
"""Command to create a new user ID key pair."""
|
||||
key_manager = keymanager.KeyManager()
|
||||
try:
|
||||
sys.argv[2] # pylint: disable=W0104
|
||||
if not sys.argv[2].lower() == 'true':
|
||||
raise ValueError
|
||||
except (IndexError, ValueError):
|
||||
newID = key_manager.addKey()[0]
|
||||
else:
|
||||
logger.warn(
|
||||
'Deterministic keys require random and long passphrases.',
|
||||
terminal=True)
|
||||
logger.warn(
|
||||
'If a good passphrase is not used, your key can be easily stolen.',
|
||||
terminal=True)
|
||||
logger.warn(
|
||||
'You should use a series of hard to guess words, ' +
|
||||
'see this for reference: https://www.xkcd.com/936/',
|
||||
terminal=True)
|
||||
try:
|
||||
pass1 = getpass.getpass(
|
||||
prompt='Enter at least %s characters: ' %
|
||||
(DETERMINISTIC_REQUIREMENT,))
|
||||
pass2 = getpass.getpass(prompt='Confirm entry: ')
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(42)
|
||||
if onionrcrypto.cryptoutils.safe_compare(pass1, pass2):
|
||||
try:
|
||||
logger.info(
|
||||
'Generating deterministic key. This can take a while.',
|
||||
terminal=True)
|
||||
newID, privKey = onionrcrypto.generate_deterministic(pass1)
|
||||
except onionrexceptions.PasswordStrengthError:
|
||||
logger.error('Passphrase must use at least %s characters.' % (
|
||||
DETERMINISTIC_REQUIREMENT,), terminal=True)
|
||||
sys.exit(1)
|
||||
else:
|
||||
logger.error('Passwords do not match.', terminal=True)
|
||||
sys.exit(1)
|
||||
try:
|
||||
key_manager.addKey(pubKey=newID,
|
||||
privKey=privKey)
|
||||
except ValueError:
|
||||
logger.error(
|
||||
'That ID is already available, you can change to it ' +
|
||||
'with the change-id command.', terminal=True)
|
||||
return
|
||||
logger.info('Added ID: %s' %
|
||||
(bytesconverter.bytes_to_str(newID),), terminal=True)
|
||||
|
||||
|
||||
add_ID.onionr_help = "If the first argument is true, " # type: ignore
|
||||
add_ID.onionr_help += "Onionr will show a deterministic " # type: ignore
|
||||
add_ID.onionr_help += "generation prompt. Otherwise it will " # type: ignore
|
||||
add_ID.onionr_help += "generate & save a new random key pair." # type: ignore
|
||||
|
||||
|
||||
def change_ID():
|
||||
"""Command to change active ID from argv or stdin."""
|
||||
key_manager = keymanager.KeyManager()
|
||||
try:
|
||||
key = sys.argv[2]
|
||||
key = unpaddedbase32.repad(key.encode()).decode()
|
||||
except IndexError:
|
||||
logger.warn('Specify pubkey to use', terminal=True)
|
||||
else:
|
||||
if stringvalidators.validate_pub_key(key):
|
||||
key_list = key_manager.getPubkeyList()
|
||||
if key in key_list or key.replace('=', '') in key_list:
|
||||
config.set('general.public_key', key)
|
||||
config.save()
|
||||
logger.info('Set active key to: %s' % (key,), terminal=True)
|
||||
logger.info('Restart Onionr if it is running.', terminal=True)
|
||||
else:
|
||||
logger.warn('That key does not exist', terminal=True)
|
||||
else:
|
||||
logger.warn('Invalid key %s' % (key,), terminal=True)
|
||||
|
||||
|
||||
change_ID.onionr_help = "<pubkey>: Switches Onionr to " # type: ignore
|
||||
change_ID.onionr_help += "use a different user ID key. " # type: ignore
|
||||
change_ID.onionr_help += "You should immediately restart " # type: ignore
|
||||
change_ID.onionr_help += "Onionr if it is running." # type: ignore
|
||||
|
||||
|
||||
def add_vanity():
|
||||
"""Command to generate menmonic vanity key pair."""
|
||||
key_manager = keymanager.KeyManager()
|
||||
|
||||
def tell(tell):
|
||||
return logger.info(tell, terminal=True)
|
||||
|
||||
words = ''
|
||||
length = len(sys.argv) - 2
|
||||
if length == 0:
|
||||
return
|
||||
for i in range(2, len(sys.argv)):
|
||||
words += ' '
|
||||
words += sys.argv[i]
|
||||
try:
|
||||
if length == 1:
|
||||
tell('Finding vanity, this should only take a few moments.')
|
||||
else:
|
||||
tell('Finding vanity, this will probably take a really long time.')
|
||||
try:
|
||||
vanity = vanityonionr.find_multiprocess(words)
|
||||
except ValueError:
|
||||
logger.warn('Vanity words must be valid english bip39',
|
||||
terminal=True)
|
||||
else:
|
||||
b32_pub = unpaddedbase32.b32encode(vanity[0])
|
||||
tell('Found vanity address:\n' +
|
||||
niceware.bytes_to_passphrase(vanity[0]))
|
||||
tell('Base32 Public key: %s' % (b32_pub.decode(),))
|
||||
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
|
||||
add_vanity.onionr_help = "<space separated words> - " # type: ignore
|
||||
add_vanity.onionr_help += "Generates and stores an " # type: ignore
|
||||
add_vanity.onionr_help += "Onionr vanity address " # type: ignore
|
||||
add_vanity.onionr_help += "(see is.gd/YklHGe)" # 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():
|
||||
"""Command to create a new user ID key pair."""
|
||||
key_manager = keymanager.KeyManager()
|
||||
try:
|
||||
sys.argv[2] # pylint: disable=W0104
|
||||
if not sys.argv[2].lower() == 'true':
|
||||
raise ValueError
|
||||
except (IndexError, ValueError):
|
||||
newID = key_manager.addKey()[0]
|
||||
else:
|
||||
logger.warn(
|
||||
'Deterministic keys require random and long passphrases.',
|
||||
terminal=True)
|
||||
logger.warn(
|
||||
'If a good passphrase is not used, your key can be easily stolen.',
|
||||
terminal=True)
|
||||
logger.warn(
|
||||
'You should use a series of hard to guess words, ' +
|
||||
'see this for reference: https://www.xkcd.com/936/',
|
||||
terminal=True)
|
||||
try:
|
||||
pass1 = getpass.getpass(
|
||||
prompt='Enter at least %s characters: ' %
|
||||
(DETERMINISTIC_REQUIREMENT,))
|
||||
pass2 = getpass.getpass(prompt='Confirm entry: ')
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(42)
|
||||
if onionrcrypto.cryptoutils.safe_compare(pass1, pass2):
|
||||
try:
|
||||
logger.info(
|
||||
'Generating deterministic key. This can take a while.',
|
||||
terminal=True)
|
||||
newID, privKey = onionrcrypto.generate_deterministic(pass1)
|
||||
except onionrexceptions.PasswordStrengthError:
|
||||
logger.error('Passphrase must use at least %s characters.' % (
|
||||
DETERMINISTIC_REQUIREMENT,), terminal=True)
|
||||
sys.exit(1)
|
||||
else:
|
||||
logger.error('Passwords do not match.', terminal=True)
|
||||
sys.exit(1)
|
||||
try:
|
||||
key_manager.addKey(pubKey=newID,
|
||||
privKey=privKey)
|
||||
except ValueError:
|
||||
logger.error(
|
||||
'That ID is already available, you can change to it ' +
|
||||
'with the change-id command.', terminal=True)
|
||||
return
|
||||
logger.info('Added ID: %s' %
|
||||
(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():
|
||||
"""Command to generate menmonic vanity key pair."""
|
||||
key_manager = keymanager.KeyManager()
|
||||
|
||||
def tell(tell):
|
||||
return logger.info(tell, terminal=True)
|
||||
|
||||
words = ''
|
||||
length = len(sys.argv) - 2
|
||||
if length == 0:
|
||||
return
|
||||
for i in range(2, len(sys.argv)):
|
||||
words += ' '
|
||||
words += sys.argv[i]
|
||||
try:
|
||||
if length == 1:
|
||||
tell('Finding vanity, this should only take a few moments.')
|
||||
else:
|
||||
tell('Finding vanity, this will probably take a really long time.')
|
||||
try:
|
||||
vanity = vanityonionr.find_multiprocess(words)
|
||||
except ValueError:
|
||||
logger.warn('Vanity words must be valid english bip39',
|
||||
terminal=True)
|
||||
else:
|
||||
b32_pub = unpaddedbase32.b32encode(vanity[0])
|
||||
tell('Found vanity address:\n' +
|
||||
niceware.bytes_to_passphrase(vanity[0]))
|
||||
tell('Base32 Public key: %s' % (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():
|
||||
"""Command to change active ID from argv or stdin."""
|
||||
key_manager = keymanager.KeyManager()
|
||||
try:
|
||||
key = sys.argv[2]
|
||||
key = unpaddedbase32.repad(key.encode()).decode()
|
||||
except IndexError:
|
||||
logger.warn('Specify pubkey to use', terminal=True)
|
||||
else:
|
||||
if stringvalidators.validate_pub_key(key):
|
||||
key_list = key_manager.getPubkeyList()
|
||||
if key in key_list or key.replace('=', '') in key_list:
|
||||
config.set('general.public_key', key)
|
||||
config.save()
|
||||
logger.info('Set active key to: %s' % (key,), terminal=True)
|
||||
logger.info('Restart Onionr if it is running.', terminal=True)
|
||||
else:
|
||||
logger.warn('That key does not exist', terminal=True)
|
||||
else:
|
||||
logger.warn('Invalid key %s' % (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>
|
129
docs/html/src/onionrcommands/resetplugins.html
Normal file
129
docs/html/src/onionrcommands/resetplugins.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Reset default plugins from source
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from utils import identifyhome
|
||||
import logger
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def reset():
|
||||
"""Reinstalls Onionr default plugins."""
|
||||
home = identifyhome.identify_home()
|
||||
plugin_dir = home + '/plugins/'
|
||||
if not os.path.exists(home):
|
||||
return
|
||||
if os.path.exists(plugin_dir):
|
||||
shutil.rmtree(plugin_dir)
|
||||
|
||||
logger.info('Default plugins have been reset.', terminal=True)
|
||||
|
||||
|
||||
reset.onionr_help = "reinstalls default Onionr plugins" # type: ignore
|
||||
reset.onionr_help += "(e.g. mail). Should be done after " # type: ignore
|
||||
reset.onionr_help += "git pulls or plugin modification." # 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():
|
||||
"""Reinstalls Onionr default plugins."""
|
||||
home = identifyhome.identify_home()
|
||||
plugin_dir = home + '/plugins/'
|
||||
if not os.path.exists(home):
|
||||
return
|
||||
if os.path.exists(plugin_dir):
|
||||
shutil.rmtree(plugin_dir)
|
||||
|
||||
logger.info('Default plugins have been reset.', 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>
|
158
docs/html/src/onionrcommands/resettor.html
Normal file
158
docs/html/src/onionrcommands/resettor.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Command to delete the Tor data directory if its safe to do so
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import logger
|
||||
from onionrutils import localcommand
|
||||
from utils import identifyhome
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def __delete(directory):
|
||||
tor_dir = '%s/%s/' % (identifyhome.identify_home(), directory)
|
||||
if os.path.exists(tor_dir):
|
||||
if localcommand.local_command('/ping') == 'pong!':
|
||||
logger.warn(
|
||||
'Cannot delete Tor data while Onionr is running',
|
||||
terminal=True)
|
||||
else:
|
||||
shutil.rmtree(tor_dir)
|
||||
logger.info('Tor reset', terminal=True)
|
||||
|
||||
|
||||
def reset_tor():
|
||||
"""Delete tor data directory."""
|
||||
__delete('tordata')
|
||||
|
||||
|
||||
reset_tor.onionr_help = "Deletes Onionr's Tor data directory. " # type: ignore
|
||||
reset_tor.onionr_help += "Only do this as a last resort if " # type: ignore
|
||||
reset_tor.onionr_help += "you have serious Tor issues." # type: ignore
|
||||
|
||||
|
||||
def reset_tor_key_pair():
|
||||
"""Delete Tor HS key pair for our node."""
|
||||
__delete('hs')
|
||||
|
||||
|
||||
reset_tor_key_pair.onionr_help = "Delete's your Tor " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "node address permanently. " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "Note that through " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "fingerprinting attackers " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "may be able to know that " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "your new generated node " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "address belongs to " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "the same node " # type: ignore
|
||||
reset_tor_key_pair.onionr_help += "as the deleted one." # 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():
|
||||
"""Delete tor data directory."""
|
||||
__delete('tordata')</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():
|
||||
"""Delete Tor HS key pair for our node."""
|
||||
__delete('hs')</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>
|
164
docs/html/src/onionrcommands/restartonionr.html
Normal file
164
docs/html/src/onionrcommands/restartonionr.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Command to restart Onionr
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
SCRIPT_NAME = os.path.dirname(os.path.realpath(
|
||||
__file__)) + f'/../../{onionrvalues.SCRIPT_NAME}'
|
||||
|
||||
|
||||
def restart():
|
||||
"""Tell the Onionr daemon to restart."""
|
||||
logger.info('Restarting Onionr', 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() != 'Windows':
|
||||
logger.warn('Could not fork on restart')
|
||||
|
||||
daemonlaunch.kill_daemon()
|
||||
while localcommand.local_command('ping', maxWait=8) == 'pong!':
|
||||
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, 'start'])
|
||||
|
||||
|
||||
restart.onionr_help = 'Gracefully restart Onionr' # 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():
|
||||
"""Tell the Onionr daemon to restart."""
|
||||
logger.info('Restarting Onionr', 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() != 'Windows':
|
||||
logger.warn('Could not fork on restart')
|
||||
|
||||
daemonlaunch.kill_daemon()
|
||||
while localcommand.local_command('ping', maxWait=8) == 'pong!':
|
||||
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, 'start'])</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>
|
126
docs/html/src/onionrcommands/runtimetestcmd.html
Normal file
126
docs/html/src/onionrcommands/runtimetestcmd.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Command to tell daemon to do run time tests
|
||||
"""
|
||||
from gevent import spawn
|
||||
|
||||
from onionrutils import localcommand
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def do_runtime_test():
|
||||
"""Send runtime test daemon queue command."""
|
||||
spawn(
|
||||
localcommand.local_command,
|
||||
f'daemon-event/test_runtime',
|
||||
post=True,
|
||||
is_json=True,
|
||||
postData={},
|
||||
maxWait=300
|
||||
).get(300)
|
||||
|
||||
|
||||
do_runtime_test.onionr_help = "If Onionr is running, " # type: ignore
|
||||
do_runtime_test.onionr_help += "run runtime tests (check logs)" # 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():
|
||||
"""Send runtime test daemon queue command."""
|
||||
spawn(
|
||||
localcommand.local_command,
|
||||
f'daemon-event/test_runtime',
|
||||
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>
|
187
docs/html/src/onionrcommands/sitecreator.html
Normal file
187
docs/html/src/onionrcommands/sitecreator.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Command to create Onionr mutli-page sites
|
||||
"""
|
||||
import sys
|
||||
import getpass
|
||||
|
||||
from httpapi import onionrsitesapi
|
||||
import logger
|
||||
from etc import onionrvalues
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def create_multipage_site():
|
||||
"""Command to create mutlipage sites with specified dir and password."""
|
||||
error_encountered = False
|
||||
try:
|
||||
directory = sys.argv[2]
|
||||
except IndexError:
|
||||
directory = '.'
|
||||
try:
|
||||
passphrase = sys.argv[3]
|
||||
except IndexError:
|
||||
logger.warn('''It is critical that this passphrase is long.
|
||||
If you want to update your site later you must remember the passphrase.''',
|
||||
terminal=True)
|
||||
|
||||
passphrase = getpass.getpass(
|
||||
'Please enter a site passphrase of at least ' +
|
||||
str(onionrvalues.PASSWORD_LENGTH) + ' characters.')
|
||||
|
||||
confirm = getpass.getpass('Confirm passphrase:')
|
||||
if passphrase != confirm:
|
||||
logger.error('Passphrases do not match', terminal=True)
|
||||
error_encountered = True
|
||||
|
||||
if len(passphrase) < onionrvalues.PASSWORD_LENGTH:
|
||||
error_encountered = True
|
||||
logger.error(
|
||||
f'Passphrase must be at least {onionrvalues.PASSWORD_LENGTH}' +
|
||||
'characters.', terminal=True)
|
||||
|
||||
if error_encountered:
|
||||
sys.exit(1)
|
||||
|
||||
results = onionrsitesapi.sitefiles.create_site(
|
||||
passphrase, directory=directory)
|
||||
results = (results[0].replace('=', ''), results[1])
|
||||
logger.info(f'Site address {results[0]}', terminal=True)
|
||||
logger.info(f'Block for this version {results[1]}', terminal=True)
|
||||
|
||||
|
||||
create_multipage_site.onionr_help = "[directory path " # type: ignore
|
||||
create_multipage_site.onionr_help += "(default relative)] " # type: ignore
|
||||
create_multipage_site.onionr_help += "- packages a whole " # type: ignore
|
||||
create_multipage_site.onionr_help += "directory and makes " # type: ignore
|
||||
create_multipage_site.onionr_help += "it available as " # type: ignore
|
||||
create_multipage_site.onionr_help += "an Onionr site." # 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():
|
||||
"""Command to create mutlipage sites with specified dir and password."""
|
||||
error_encountered = False
|
||||
try:
|
||||
directory = sys.argv[2]
|
||||
except IndexError:
|
||||
directory = '.'
|
||||
try:
|
||||
passphrase = sys.argv[3]
|
||||
except IndexError:
|
||||
logger.warn('''It is critical that this passphrase is long.
|
||||
If you want to update your site later you must remember the passphrase.''',
|
||||
terminal=True)
|
||||
|
||||
passphrase = getpass.getpass(
|
||||
'Please enter a site passphrase of at least ' +
|
||||
str(onionrvalues.PASSWORD_LENGTH) + ' characters.')
|
||||
|
||||
confirm = getpass.getpass('Confirm passphrase:')
|
||||
if passphrase != confirm:
|
||||
logger.error('Passphrases do not match', terminal=True)
|
||||
error_encountered = True
|
||||
|
||||
if len(passphrase) < onionrvalues.PASSWORD_LENGTH:
|
||||
error_encountered = True
|
||||
logger.error(
|
||||
f'Passphrase must be at least {onionrvalues.PASSWORD_LENGTH}' +
|
||||
'characters.', terminal=True)
|
||||
|
||||
if error_encountered:
|
||||
sys.exit(1)
|
||||
|
||||
results = onionrsitesapi.sitefiles.create_site(
|
||||
passphrase, directory=directory)
|
||||
results = (results[0].replace('=', ''), results[1])
|
||||
logger.info(f'Site address {results[0]}', terminal=True)
|
||||
logger.info(f'Block for this version {results[1]}', 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>
|
154
docs/html/src/onionrcommands/softreset.html
Normal file
154
docs/html/src/onionrcommands/softreset.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Command to soft-reset Onionr (deletes blocks)
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from onionrutils import localcommand
|
||||
from coredb import dbfiles
|
||||
import filepaths
|
||||
from onionrplugins import onionrevents
|
||||
import logger
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def _ignore_not_found_delete(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
def soft_reset():
|
||||
"""Command to soft reset Onionr home data.
|
||||
|
||||
Onionr must not be running
|
||||
"""
|
||||
if localcommand.local_command('/ping') == 'pong!':
|
||||
logger.warn('Cannot soft reset while Onionr is running',
|
||||
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('softreset')
|
||||
logger.info("Soft reset Onionr", terminal=True)
|
||||
|
||||
|
||||
soft_reset.onionr_help = "Deletes Onionr blocks and their " # type: ignore
|
||||
soft_reset.onionr_help += "associated metadata, except for " # type: ignore
|
||||
soft_reset.onionr_help += "any exported block files. Does NOT " # type: ignore
|
||||
soft_reset.onionr_help += "delete data on " # type: ignore
|
||||
soft_reset.onionr_help += "other nodes in the network." # 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():
|
||||
"""Command to soft reset Onionr home data.
|
||||
|
||||
Onionr must not be running
|
||||
"""
|
||||
if localcommand.local_command('/ping') == 'pong!':
|
||||
logger.warn('Cannot soft reset while Onionr is running',
|
||||
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('softreset')
|
||||
logger.info("Soft reset Onionr", 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>
|
119
docs/html/src/onionrcommands/togglebootstrap.html
Normal file
119
docs/html/src/onionrcommands/togglebootstrap.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Toggle the bootstrap configuration
|
||||
"""
|
||||
import sys
|
||||
|
||||
import config
|
||||
import logger
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def toggle_bootstrap_config():
|
||||
"""Toggles the bootstrap configuration."""
|
||||
print("test")
|
||||
if config.get('general.use_bootstrap_list') is None:
|
||||
logger.error('No general.bootstrap_list setting found')
|
||||
sys.exit(3)
|
||||
flipped: bool = not config.get('general.use_bootstrap_list')
|
||||
config.set('general.use_bootstrap_list', 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():
|
||||
"""Toggles the bootstrap configuration."""
|
||||
print("test")
|
||||
if config.get('general.use_bootstrap_list') is None:
|
||||
logger.error('No general.bootstrap_list setting found')
|
||||
sys.exit(3)
|
||||
flipped: bool = not config.get('general.use_bootstrap_list')
|
||||
config.set('general.use_bootstrap_list', 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>
|
144
docs/html/src/onionrcommands/version.html
Normal file
144
docs/html/src/onionrcommands/version.html
Normal 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">"""Onionr - Private P2P Communication.
|
||||
|
||||
Command to show version info
|
||||
"""
|
||||
import platform
|
||||
from utils import identifyhome
|
||||
from etc import onionrvalues
|
||||
import logger
|
||||
"""
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def version(verbosity=5, function=logger.info):
|
||||
"""Display the Onionr version."""
|
||||
function('Onionr v%s (%s) (API v%s)' % (onionrvalues.ONIONR_VERSION,
|
||||
platform.machine(),
|
||||
onionrvalues.API_VERSION),
|
||||
terminal=True)
|
||||
if verbosity >= 1:
|
||||
function(onionrvalues.ONIONR_TAGLINE, terminal=True)
|
||||
if verbosity >= 2:
|
||||
pf = platform.platform()
|
||||
release = platform.release()
|
||||
python_imp = platform.python_implementation()
|
||||
python_version = platform.python_version()
|
||||
function(
|
||||
f'{python_imp} {python_version} on {pf} {release}',
|
||||
terminal=True)
|
||||
function('Onionr data dir: %s' %
|
||||
identifyhome.identify_home(), terminal=True)
|
||||
|
||||
|
||||
version.onionr_help = 'Shows environment details including ' # type: ignore
|
||||
version.onionr_help += 'Onionr version & data directory, ' # type: ignore
|
||||
version.onionr_help += 'OS and Python version' # 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=<function info>)</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):
|
||||
"""Display the Onionr version."""
|
||||
function('Onionr v%s (%s) (API v%s)' % (onionrvalues.ONIONR_VERSION,
|
||||
platform.machine(),
|
||||
onionrvalues.API_VERSION),
|
||||
terminal=True)
|
||||
if verbosity >= 1:
|
||||
function(onionrvalues.ONIONR_TAGLINE, terminal=True)
|
||||
if verbosity >= 2:
|
||||
pf = platform.platform()
|
||||
release = platform.release()
|
||||
python_imp = platform.python_implementation()
|
||||
python_version = platform.python_version()
|
||||
function(
|
||||
f'{python_imp} {python_version} on {pf} {release}',
|
||||
terminal=True)
|
||||
function('Onionr data dir: %s' %
|
||||
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>
|
Loading…
Add table
Add a link
Reference in a new issue