work on making mail more efficient, added --private-ke argument imp to run script
parent
646a7c0b80
commit
3199f93d4b
|
@ -75,7 +75,7 @@ parser.add_argument(
|
||||||
type=int, default=1)
|
type=int, default=1)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--private-key', help='Use existing private key',
|
'--private-key', help='Use existing private key',
|
||||||
type=int, default=1)
|
type=str, default=0)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--animated-background', help='Animated background on webui index. Just for looks.',
|
'--animated-background', help='Animated background on webui index. Just for looks.',
|
||||||
type=int, default=0)
|
type=int, default=0)
|
||||||
|
@ -86,14 +86,22 @@ args = parser.parse_args()
|
||||||
|
|
||||||
p = Popen([sub_script, 'version'], stdout=DEVNULL)
|
p = Popen([sub_script, 'version'], stdout=DEVNULL)
|
||||||
p.wait()
|
p.wait()
|
||||||
from filepaths import config_file
|
from filepaths import config_file, keys_file
|
||||||
from coredb import blockmetadb
|
from coredb import blockmetadb
|
||||||
|
import onionrcrypto
|
||||||
|
|
||||||
|
|
||||||
with open(config_file, 'r') as cf:
|
with open(config_file, 'r') as cf:
|
||||||
config = ujson.loads(cf.read())
|
config = ujson.loads(cf.read())
|
||||||
|
|
||||||
|
|
||||||
|
if args.private_key:
|
||||||
|
priv = args.private_key
|
||||||
|
pub = onionrcrypto.cryptoutils.get_pub_key_from_priv(priv)
|
||||||
|
with open(keys_file, "a") as f:
|
||||||
|
f.write(',' + pub.decode() + ',' + priv)
|
||||||
|
config['general']['public_key'] = pub
|
||||||
|
|
||||||
if not args.onboarding:
|
if not args.onboarding:
|
||||||
config['onboarding']['done'] = True
|
config['onboarding']['done'] = True
|
||||||
if not args.random_localhost_ip:
|
if not args.random_localhost_ip:
|
||||||
|
@ -110,7 +118,7 @@ config['general']['display_header'] = False
|
||||||
config['general']['security_level'] = args.security_level
|
config['general']['security_level'] = args.security_level
|
||||||
|
|
||||||
with open(config_file, 'w') as cf:
|
with open(config_file, 'w') as cf:
|
||||||
cf.write(ujson.dumps(config))
|
cf.write(ujson.dumps(config, reject_bytes=False))
|
||||||
|
|
||||||
if args.open_ui:
|
if args.open_ui:
|
||||||
p = Popen([sub_script, 'start'], stdout=DEVNULL)
|
p = Popen([sub_script, 'start'], stdout=DEVNULL)
|
||||||
|
|
|
@ -10,9 +10,11 @@ from flask import Response, request, redirect, Blueprint, abort
|
||||||
from flask import send_from_directory
|
from flask import send_from_directory
|
||||||
import deadsimplekv as simplekv
|
import deadsimplekv as simplekv
|
||||||
|
|
||||||
|
from httpapi.sse.wrapper import SSEWrapper
|
||||||
from onionrusers import contactmanager
|
from onionrusers import contactmanager
|
||||||
from onionrutils import stringvalidators
|
from onionrutils import stringvalidators
|
||||||
from utils import reconstructhash, identifyhome
|
from utils import reconstructhash, identifyhome
|
||||||
|
from utils.bettersleep import better_sleep as sleep
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
||||||
import loadinbox
|
import loadinbox
|
||||||
|
@ -35,6 +37,7 @@ flask_blueprint = Blueprint('mail', __name__)
|
||||||
kv = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat')
|
kv = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat')
|
||||||
root = os.path.dirname(os.path.realpath(__file__))
|
root = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
sse_wrapper = SSEWrapper()
|
||||||
|
|
||||||
@flask_blueprint.route('/mail/<path:path>', endpoint='mailstatic')
|
@flask_blueprint.route('/mail/<path:path>', endpoint='mailstatic')
|
||||||
def load_mail(path):
|
def load_mail(path):
|
||||||
|
@ -68,6 +71,16 @@ def mail_delete(block):
|
||||||
def list_inbox():
|
def list_inbox():
|
||||||
return ','.join(loadinbox.load_inbox())
|
return ','.join(loadinbox.load_inbox())
|
||||||
|
|
||||||
|
|
||||||
|
@flask_blueprint.route('/mail/streaminbox')
|
||||||
|
def stream_inbox():
|
||||||
|
def _stream():
|
||||||
|
while True:
|
||||||
|
yield "data: " + ','.join(loadinbox.load_inbox()) + "\n\n"
|
||||||
|
sleep(1)
|
||||||
|
return sse_wrapper.handle_sse_request(_stream)
|
||||||
|
|
||||||
|
|
||||||
@flask_blueprint.route('/mail/getsentbox')
|
@flask_blueprint.route('/mail/getsentbox')
|
||||||
def list_sentbox():
|
def list_sentbox():
|
||||||
kv.refresh()
|
kv.refresh()
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<link rel="stylesheet" href="/mail/mail.css">
|
<link rel="stylesheet" href="/mail/mail.css">
|
||||||
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotify.js"></script>
|
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotify.js"></script>
|
||||||
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
|
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
|
||||||
|
<script defer src="/shared/eventsource.js"></script>
|
||||||
<script defer src="/shared/main/apicheck.js"></script>
|
<script defer src="/shared/main/apicheck.js"></script>
|
||||||
<script defer src="/shared/misc.js"></script>
|
<script defer src="/shared/misc.js"></script>
|
||||||
<script defer src="/mail/sethumanreadable.js"></script>
|
<script defer src="/mail/sethumanreadable.js"></script>
|
||||||
|
|
|
@ -382,6 +382,9 @@ function refreshPms(callNext){
|
||||||
if (! window.inboxActive){
|
if (! window.inboxActive){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (document.hidden){
|
||||||
|
return
|
||||||
|
}
|
||||||
fetch('/mail/getinbox', {
|
fetch('/mail/getinbox', {
|
||||||
headers: {
|
headers: {
|
||||||
"token": webpass
|
"token": webpass
|
||||||
|
@ -448,3 +451,17 @@ document.addEventListener("visibilitychange", function() {
|
||||||
refreshPms()
|
refreshPms()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
let mailStream = function(){
|
||||||
|
var streamSource = new EventSourcePolyfill('/mail/streaminbox', {
|
||||||
|
headers: {
|
||||||
|
"token": webpass
|
||||||
|
}
|
||||||
|
})
|
||||||
|
streamSource.onmessage = function(e){
|
||||||
|
console.debug(e.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mailStream()
|
||||||
|
*/
|
Loading…
Reference in New Issue