diff --git a/onionr.sh b/onionr.sh new file mode 100755 index 00000000..286a0f7f --- /dev/null +++ b/onionr.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cd "$(dirname "$0")" +cd onionr/ +./onionr.py "$@" diff --git a/onionr/proofofmemory.py b/onionr/proofofmemory.py new file mode 100644 index 00000000..4b0b0fa7 --- /dev/null +++ b/onionr/proofofmemory.py @@ -0,0 +1,29 @@ +''' + Onionr - P2P Anonymous Storage Network + + This file handles proof of memory functionality +''' +''' + 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 . +''' + +class ProofOfMemory: + def __init__(self, commInst): + self.communicator = commInst + return + + def checkRandomPeer(self): + return + def checkPeer(self, peer): + return \ No newline at end of file diff --git a/onionr/serializeddata.py b/onionr/serializeddata.py new file mode 100644 index 00000000..a7ff2e80 --- /dev/null +++ b/onionr/serializeddata.py @@ -0,0 +1,42 @@ +''' + Onionr - P2P Anonymous Storage Network + + This module serializes various data pieces for use in other modules, in particular the web api +''' +''' + 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 . +''' + +import core, api, uuid, json + +class SerializedData: + def __init__(self, coreInst): + ''' + Serialized data is in JSON format: + { + 'success': bool, + 'foo': 'bar', + etc + } + ''' + assert isinstance(coreInst, core.Core) + self._core = coreInst + + def getStats(self): + '''Return statistics about our node''' + stats = {} + stats['uptime'] = self._core._utils.localCommand('getuptime') + stats['connectedNodes'] = self._core.daemonQueueSimple('connectedPeers') + stats['blockCount'] = len(self._core.getBlockList()) + return json.dumps(stats) diff --git a/onionr/static-data/www/private/index.html b/onionr/static-data/www/private/index.html new file mode 100644 index 00000000..58c14e3f --- /dev/null +++ b/onionr/static-data/www/private/index.html @@ -0,0 +1,24 @@ + + + + + + Onionr + + + + + + Onionr Web Control Panel +
+ Shutdown node +

Stats

+

Uptime:

+

Stored Blocks:

+

Connected nodes:

+

+        
+ + + + \ No newline at end of file diff --git a/onionr/static-data/www/shared/main/stats.js b/onionr/static-data/www/shared/main/stats.js new file mode 100644 index 00000000..4e856e5a --- /dev/null +++ b/onionr/static-data/www/shared/main/stats.js @@ -0,0 +1,30 @@ +/* + + Onionr - P2P Anonymous Storage Network + + This file loads stats to show on the main node web page + + 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 +*/ + +uptimeDisplay = document.getElementById('uptime') +connectedDisplay = document.getElementById('connectedNodes') +storedBlockDisplay = document.getElementById('storedBlocks') + +pass = window.location.hash.replace('#', '') + +stats = JSON.parse(httpGet('getstats', pass)) +uptimeDisplay.innerText = stats['uptime'] + ' seconds' +connectedDisplay.innerText = stats['connectedNodes'] +storedBlockDisplay.innerText = stats['blockCount'] \ No newline at end of file diff --git a/onionr/static-data/www/shared/main/style.css b/onionr/static-data/www/shared/main/style.css new file mode 100644 index 00000000..7b8f3c2e --- /dev/null +++ b/onionr/static-data/www/shared/main/style.css @@ -0,0 +1,126 @@ +body{ + background-color: #2c2b3f; + color: white; +} + +a, a:visited{ + color: white; +} +.center{ + text-align: center; +} +footer{ + margin-top: 2em; + margin-bottom: 0.5em; +} + +body{ + margin-left: 3em; + padding: 1em; +} +.onionrMenu{ + max-width: 25%; + margin-left: 2%; + margin-right: 10%; + font-family: sans-serif; +} +.onionrMenu li{ + list-style-type: none; + margin-top: 3px; + font-size: 125%; +} +.onionrMenu li:hover{ + color: red; +} +.box { + display: flex; + align-items:center; + } + .logo{ + max-width: 25%; + vertical-align: middle; + } + .logoText{ + font-family: sans-serif; + font-size: 2em; + margin-top: 1em; + margin-left: 1%; + } + .main{ + min-height: 500px; + } + +.content{ + margin-top: 3em; + margin-left: 0%; + margin-right: 40%; + background-color: white; + color: black; + padding-right: 5%; + padding-left: 3%; + padding-bottom: 2em; + padding-top: 0.5em; + border: 1px solid black; + border-radius: 10px; + min-height: 300px; +} +.content p{ + text-align: justify; +} +.content img{ + max-width: 35%; +} +.content a, .content a:visited{ + color: black; +} + +.stats{ + margin-top: 1em; + background-color: #0c1049; + padding: 5px; + margin-right: 45%; + font-family: sans-serif; +} +.statDesc{ + background-color: black; + padding: 5px; + margin-right: 1%; + margin-left: -5px; +} + +.stats noscript{ + color: blue; +} + +.statItem{ + padding-left: 10px; + float: right; + margin-right: 5px; +} + +.warn{ + color: orangered; +} + +@media only screen and (max-width: 640px) { + .onionrMenu{ + margin-left: 0%; + } + body{ + margin-left: 0em; + } + .content{ + margin-left: 1%; + margin-right: 2%; + } + .content img{ + max-width: 85%; + } + .stats{ + margin-right: 1%; + } + .statItem{ + float: initial; + display: block; + } +} diff --git a/onionr/static-data/www/shared/misc.js b/onionr/static-data/www/shared/misc.js new file mode 100644 index 00000000..1b7d6092 --- /dev/null +++ b/onionr/static-data/www/shared/misc.js @@ -0,0 +1,12 @@ +function httpGet(theUrl, webpass) { + var xmlHttp = new XMLHttpRequest() + xmlHttp.open( "GET", theUrl, false ) // false for synchronous request + xmlHttp.setRequestHeader('token', webpass) + xmlHttp.send( null ) + if (xmlHttp.status == 200){ + return xmlHttp.responseText + } + else{ + return ""; + } +} \ No newline at end of file diff --git a/onionr/static-data/www/shared/onionr-icon.png b/onionr/static-data/www/shared/onionr-icon.png new file mode 100644 index 00000000..6662210d Binary files /dev/null and b/onionr/static-data/www/shared/onionr-icon.png differ diff --git a/onionr/static-data/www/shared/onionrblocks.js b/onionr/static-data/www/shared/onionrblocks.js new file mode 100644 index 00000000..6be0210d --- /dev/null +++ b/onionr/static-data/www/shared/onionrblocks.js @@ -0,0 +1,7 @@ +class Block { + constructor(hash, raw) { + this.hash = hash; + this.raw = raw; + } +} + \ No newline at end of file diff --git a/start-daemon.sh b/start-daemon.sh new file mode 100755 index 00000000..1b713100 --- /dev/null +++ b/start-daemon.sh @@ -0,0 +1,5 @@ +#!/usr/bin/bash +cd "$(dirname "$0")" +echo "starting Onionr daemon..." +echo "run onionr.sh stop to stop the daemon, or onionr.sh start to get output" +nohup ./onionr.sh start & disown > /dev/null