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