work on readme, added mail files, bugfixes

This commit is contained in:
Kevin Froman 2019-01-30 00:10:29 -06:00
parent 4882a21b6a
commit f0382d24da
8 changed files with 101 additions and 17 deletions

View file

@ -265,7 +265,7 @@ class API:
self.bindPort = bindPort
# Be extremely mindful of this
self.whitelistEndpoints = ('site', 'www', 'onionrhome', 'board', 'boardContent', 'sharedContent')
self.whitelistEndpoints = ('site', 'www', 'onionrhome', 'board', 'boardContent', 'sharedContent', 'mail', 'mailindex')
self.clientToken = config.get('client.webpassword')
self.timeBypassToken = base64.b16encode(os.urandom(32)).decode()
@ -308,6 +308,13 @@ class API:
def loadBoard():
return send_from_directory('static-data/www/board/', "index.html")
@app.route('/mail/<path:path>', endpoint='mail')
def loadMail(path):
return send_from_directory('static-data/www/mail/', '')
@app.route('/mail/', endpoint='mailindex')
def loadMailIndex():
return send_from_directory('static-data/www/mail/', 'index.html')
@app.route('/board/<path:path>', endpoint='boardContent')
def boardContent(path):
return send_from_directory('static-data/www/board/', path)
@ -407,7 +414,11 @@ class API:
@app.route('/getstats')
def getStats():
#return Response("disabled")
return Response(self._core.serializer.getStats())
while True:
try:
return Response(self._core.serializer.getStats())
except AttributeError:
pass
@app.route('/getuptime')
def showUptime():

View file

@ -105,7 +105,8 @@ def check():
open(get_config_file(), 'a', encoding="utf8").close()
save()
except:
logger.debug('Failed to check configuration file.')
pass
#logger.debug('Failed to check configuration file.')
def save():
'''
@ -129,7 +130,8 @@ def reload():
with open(get_config_file(), 'r', encoding="utf8") as configfile:
set_config(json.loads(configfile.read()))
except:
logger.debug('Failed to parse configuration file.')
pass
#logger.debug('Failed to parse configuration file.')
def get_config():
'''

View file

@ -30,7 +30,7 @@ import webbrowser, uuid, signal
from threading import Thread
import api, core, config, logger, onionrplugins as plugins, onionrevents as events
import onionrutils
import netcontroller
import netcontroller, onionrstorage
from netcontroller import NetController
from onionrblockapi import Block
import onionrproofs, onionrexceptions, onionrusers, communicator
@ -190,6 +190,9 @@ class Onionr:
'openhome': self.openHome,
'open-home': self.openHome,
'export-block': self.exportBlock,
'exportblock': self.exportBlock,
'get-file': self.getFile,
'getfile': self.getFile,
@ -271,6 +274,31 @@ class Onionr:
THIS SECTION HANDLES THE COMMANDS
'''
def exportBlock(self):
exportDir = self.dataDir + 'block-export/'
try:
assert self.onionrUtils.validateHash(sys.argv[2])
except (IndexError, AssertionError):
logger.error('No valid block hash specified.')
sys.exit(1)
else:
bHash = sys.argv[2]
try:
path = sys.argv[3]
except (IndexError):
if not os.path.exists(exportDir):
if os.path.exists(self.dataDir):
os.mkdir(exportDir)
else:
logger.error('Onionr not initialized')
sys.exit(1)
path = exportDir
data = onionrstorage.getData(self.onionrCore, bHash)
with open('%s/%s.dat' % (exportDir, bHash), 'wb') as exportFile:
exportFile.write(data)
def showDetails(self):
details = {
'Node Address' : self.get_hostname(),

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>
Onionr Mail
</title>
<link rel='stylesheet' href='/shared/style/modal.css'>
<link rel='stylesheet' href='/shared/main/style.css'>
</head>
<body>
<div id="infoOverlay" class='overlay'>
</div>
<img class='logo' src='/shared/onionr-icon.png' alt='onionr logo'>
<span class='logoText'>Onionr Web Mail</span>
<div class='content'>
</div>
<script src='/shared/misc.js'></script>
</body>
</html>

View file

View file

@ -42,6 +42,8 @@ class StorageCounter:
retData = int(dataFile.read())
except FileNotFoundError:
pass
except ValueError:
pass # Possibly happens when the file is empty
return retData
def getPercent(self):