added 401 handler, work on storing/sending data
parent
5af2b99135
commit
f46e7ea965
|
@ -130,7 +130,10 @@ class API:
|
|||
elif action == 'getPGP':
|
||||
resp = Response(self._utils.exportMyPubkey())
|
||||
elif action == 'setData':
|
||||
pass
|
||||
if data == None:
|
||||
abort(401)
|
||||
else:
|
||||
self._core.setData(data)
|
||||
elif action == 'getData':
|
||||
resp = Response(self._core.getData(data))
|
||||
|
||||
|
@ -147,6 +150,11 @@ class API:
|
|||
self.requestFailed = True
|
||||
resp = Response("403")
|
||||
return resp
|
||||
@app.errorhandler(401)
|
||||
def clientError(err):
|
||||
self.requestFailed = True
|
||||
resp = Response("Invalid request")
|
||||
return resp
|
||||
|
||||
print('Starting client on ' + self.host + ':' + str(bindPort))
|
||||
print('Client token:', self.clientToken)
|
||||
|
|
|
@ -17,11 +17,18 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
import sqlite3, os, time, math, gnupg, base64, tarfile, getpass, simplecrypt
|
||||
import sqlite3, os, time, math, gnupg, base64, tarfile, getpass, simplecrypt, hashlib
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto import Random
|
||||
import netcontroller
|
||||
|
||||
if sys.version_info < (3, 6):
|
||||
try:
|
||||
import sha3
|
||||
except ModuleNotFoundError:
|
||||
sys.stderr.write('On Python 3 versions prior to 3.6.x, you need the sha3 module')
|
||||
sys.exit(1)
|
||||
|
||||
class Core:
|
||||
def __init__(self):
|
||||
'''
|
||||
|
@ -125,6 +132,10 @@ class Core:
|
|||
dataFile.close()
|
||||
return data
|
||||
|
||||
def setData(self, data):
|
||||
'''set the data assciated with a hash'''
|
||||
hasher = hashlib.sha3_256
|
||||
|
||||
def dataDirEncrypt(self, password):
|
||||
'''
|
||||
Encrypt the data directory on Onionr shutdown
|
||||
|
|
Loading…
Reference in New Issue