fixed file bug, removed username setting

This commit is contained in:
Kevin Froman 2019-01-16 23:31:56 -06:00
parent 1ebed8d606
commit 9429afba18
10 changed files with 40 additions and 59 deletions

View file

@ -31,11 +31,14 @@ class OnionrCLIUI:
self.myCore = apiInst.get_core()
return
def subCommand(self, command):
def subCommand(self, command, args=None):
try:
#subprocess.run(["./onionr.py", command])
#subprocess.Popen(['./onionr.py', command], stdin=subprocess.STD, stdout=subprocess.STDOUT, stderr=subprocess.STDOUT)
subprocess.call(['./onionr.py', command])
if args != None:
subprocess.call(['./onionr.py', command, args])
else:
subprocess.call(['./onionr.py', command])
except KeyboardInterrupt:
pass
@ -48,12 +51,11 @@ class OnionrCLIUI:
isOnline = 'No'
firstRun = True
choice = ''
if self.myCore._utils.localCommand('ping') == 'pong':
if self.myCore._utils.localCommand('ping', maxWait=10) == 'pong!':
firstRun = False
while showMenu:
if self.myCore._utils.localCommand('ping') == 'pong':
if self.myCore._utils.localCommand('ping', maxWait=2) == 'pong!':
isOnline = "Yes"
else:
isOnline = "No"
@ -62,8 +64,7 @@ class OnionrCLIUI:
1. Flow (Anonymous public chat, use at your own risk)
2. Mail (Secure email-like service)
3. File Sharing
4. User Settings
5. Quit (Does not shutdown daemon)
4. Quit (Does not shutdown daemon)
''')
try:
choice = input(">").strip().lower()
@ -75,13 +76,9 @@ class OnionrCLIUI:
elif choice in ("2", "mail"):
self.subCommand("mail")
elif choice in ("3", "file sharing", "file"):
print("Not supported yet")
elif choice in ("4", "user settings", "settings"):
try:
self.setName()
except (KeyboardInterrupt, EOFError) as e:
pass
elif choice in ("5", "quit"):
filename = input("Enter full path to file: ").strip()
self.subCommand("addfile", filename)
elif choice in ("4", "quit"):
showMenu = False
elif choice == "":
pass
@ -89,14 +86,6 @@ class OnionrCLIUI:
logger.error("Invalid choice")
return
def setName(self):
try:
name = input("Enter your name: ")
if name != "":
self.myCore.insertBlock("userInfo-" + str(uuid.uuid1()), sign=True, header='userInfo', meta={'name': name})
except KeyboardInterrupt:
pass
return
def on_init(api, data = None):
'''

View file

@ -28,24 +28,6 @@ plugin_name = 'metadataprocessor'
# event listeners
def _processUserInfo(api, newBlock):
'''
Set the username for a particular user, from a signed block by them
'''
myBlock = newBlock
peerName = myBlock.getMetadata('name')
try:
if len(peerName) > 20:
raise onionrexceptions.InvalidMetdata('Peer name specified is too large')
except TypeError:
pass
except onionrexceptions.InvalidMetadata:
pass
else:
if signer in self.api.get_core().listPeers():
api.get_core().setPeerInfo(signer, 'name', peerName)
logger.info('%s is now using the name %s.' % (signer, api.get_utils().escapeAnsi(peerName)))
def _processForwardKey(api, myBlock):
'''
Get the forward secrecy key specified by the user for us to use
@ -67,12 +49,8 @@ def on_processblocks(api):
# Process specific block types
# userInfo blocks, such as for setting username
if blockType == 'userInfo':
if api.data['validSig'] == True: # we use == True for type safety
_processUserInfo(api, myBlock)
# forwardKey blocks, add a new forward secrecy key for a peer
elif blockType == 'forwardKey':
if blockType == 'forwardKey':
if api.data['validSig'] == True:
_processForwardKey(api, myBlock)
# socket blocks

View file

@ -1,4 +1,5 @@
webpass = document.location.hash.replace('#', '')
nowebpass = false
if (typeof webpass == "undefined"){
webpass = localStorage['webpass']
}
@ -8,6 +9,7 @@ else{
}
if (typeof webpass == "undefined" || webpass == ""){
alert('Web password was not found in memory or URL')
nowebpass = true
}
function httpGet(theUrl) {

View file

@ -1,6 +1,8 @@
shutdownBtn = document.getElementById('shutdownNode')
shutdownBtn.onclick = function(){
httpGet('shutdownclean')
overlay('shutdownNotice')
if (! nowebpass){
httpGet('shutdownclean')
overlay('shutdownNotice')
}
}