+ Work on boards
* Handle ctrl-c better in main loop
This commit is contained in:
parent
705359d3a6
commit
2219be9ae3
@ -497,6 +497,11 @@ class API:
|
||||
encrypt = False
|
||||
bData = request.get_json(force=True)
|
||||
message = bData['message']
|
||||
|
||||
# Detect if message (block body) is not specified
|
||||
if type(message) is None:
|
||||
return 'failure', 406
|
||||
|
||||
subject = 'temp'
|
||||
encryptType = ''
|
||||
sign = True
|
||||
|
@ -148,7 +148,7 @@ class OnionrCommunicatorDaemon:
|
||||
self.shutdown = True
|
||||
pass
|
||||
|
||||
logger.info('Goodbye.')
|
||||
logger.info('Goodbye. (Onionr is cleaning up, and will exit)')
|
||||
try:
|
||||
self.service_greenlets
|
||||
except AttributeError:
|
||||
|
@ -686,9 +686,13 @@ class Core:
|
||||
return False
|
||||
retData = False
|
||||
|
||||
if type(data) is None:
|
||||
raise ValueError('Data cannot be none')
|
||||
|
||||
createTime = self._utils.getRoundedEpoch()
|
||||
|
||||
# check nonce
|
||||
print(data)
|
||||
dataNonce = self._utils.bytesToStr(self._crypto.sha3Hash(data))
|
||||
try:
|
||||
with open(self.dataNonceFile, 'r') as nonces:
|
||||
|
@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
|
||||
import os, time, sys, platform, sqlite3
|
||||
import os, time, sys, platform, sqlite3, signal
|
||||
from threading import Thread
|
||||
import onionr, api, logger, communicator
|
||||
import onionrevents as events
|
||||
@ -84,9 +84,12 @@ def daemon(o_inst):
|
||||
logger.debug('Started communicator.')
|
||||
|
||||
events.event('daemon_start', onionr = o_inst)
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
time.sleep(3)
|
||||
except KeyboardInterrupt:
|
||||
o_inst.communicatorInst.shutdown = True
|
||||
finally:
|
||||
# Debug to print out used FDs (regular and net)
|
||||
#proc = psutil.Process()
|
||||
#print('api-files:',proc.open_files(), len(psutil.net_connections()))
|
||||
@ -95,16 +98,19 @@ def daemon(o_inst):
|
||||
break
|
||||
if o_inst.killed:
|
||||
break # Break out if sigterm for clean exit
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
|
||||
signal.signal(signal.SIGINT, _ignore_sigint)
|
||||
o_inst.onionrCore.daemonQueueAdd('shutdown')
|
||||
o_inst.onionrUtils.localCommand('shutdown')
|
||||
|
||||
net.killTor()
|
||||
time.sleep(3)
|
||||
o_inst.deleteRunFiles()
|
||||
return
|
||||
|
||||
def _ignore_sigint(sig, frame):
|
||||
return
|
||||
|
||||
def kill_daemon(o_inst):
|
||||
'''
|
||||
Shutdown the Onionr daemon
|
||||
|
@ -6,6 +6,9 @@ newPostForm = document.getElementById('addMsg')
|
||||
|
||||
function appendMessages(msg){
|
||||
var humanDate = new Date(0)
|
||||
if (msg.length == 0){
|
||||
return
|
||||
}
|
||||
var msg = JSON.parse(msg)
|
||||
var dateEl = document.createElement('span')
|
||||
var el = document.createElement('div')
|
||||
@ -46,5 +49,21 @@ document.getElementById('refreshFeed').onclick = function(){
|
||||
}
|
||||
|
||||
newPostForm.onsubmit = function(){
|
||||
var message = document.getElementById('newMsgText').value
|
||||
var postData = {'message': message, 'type': 'txt', 'encrypt': false}
|
||||
postData = JSON.stringify(postData)
|
||||
newPostForm.style.display = 'none'
|
||||
fetch('/insertblock', {
|
||||
method: 'POST',
|
||||
body: postData,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"token": webpass
|
||||
}})
|
||||
.then((resp) => resp.text()) // Transform the data into json
|
||||
.then(function(data) {
|
||||
newPostForm.style.display = 'block'
|
||||
alert('Queued for submission!')
|
||||
})
|
||||
return false
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
Anonymous message board
|
||||
</p>
|
||||
<form method='POST' action='/' id='addMsg'>
|
||||
<textarea name='newMsgText' rows=10 cols=50 required minlength="2"></textarea>
|
||||
<textarea id='newMsgText' name='newMsgText' rows=10 cols=50 required minlength="2"></textarea>
|
||||
<br><br>
|
||||
<input class='btn successBtn' value='Post' type='submit'>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user