bind ip config option, use different type for deniable block, mostly finished friends UI

This commit is contained in:
Kevin Froman 2019-02-23 18:11:43 -06:00
parent c61c833658
commit 31039861c2
9 changed files with 44 additions and 20 deletions

View File

@ -40,9 +40,9 @@ class FDSafeHandler(WSGIHandler):
def setBindIP(filePath):
'''Set a random localhost IP to a specified file (intended for private or public API localhost IPs)'''
if config.get('general.random_bind_ip', True):
hostOctets = [str(127), str(random.randint(0x02, 0xFF)), str(random.randint(0x02, 0xFF)), str(random.randint(0x02, 0xFF))]
data = '.'.join(hostOctets)
# Try to bind IP. Some platforms like Mac block non normal 127.x.x.x
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
@ -52,10 +52,10 @@ def setBindIP(filePath):
logger.warn('Your platform appears to not support random local host addresses 127.x.x.x. Falling back to 127.0.0.1.')
data = '127.0.0.1'
s.close()
else:
data = '127.0.0.1'
with open(filePath, 'w') as bindFile:
bindFile.write(data)
return data
class PublicAPI:

View File

@ -34,12 +34,12 @@ def list_friends():
@friends.route('/friends/add/<pubkey>', methods=['POST'])
def add_friend(pubkey):
contactmanager.ContactManager(core.Core(), pubkey, saveUser=True).setTrust(1)
return 'success'
return redirect(request.referrer + '#' + request.form['token'])
@friends.route('/friends/remove/<pubkey>', methods=['POST'])
def remove_friend(pubkey):
contactmanager.ContactManager(core.Core(), pubkey).setTrust(0)
return 'success'
return redirect(request.referrer + '#' + request.form['token'])
@friends.route('/friends/setinfo/<pubkey>/<key>', methods=['POST'])
def set_info(pubkey, key):

View File

@ -308,7 +308,9 @@ class Onionr:
except FileNotFoundError:
logger.error('Onionr seems to not be running (could not get api host)')
else:
webbrowser.open_new_tab('http://%s/#%s' % (url, config.get('client.webpassword')))
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
print('If Onionr does not open automatically, use this URL:', url)
webbrowser.open_new_tab(url)
def addID(self):
try:

View File

@ -200,6 +200,6 @@ class DaemonTools:
if secrets.randbelow(chance) == (chance - 1):
fakePeer = self.daemon._core._crypto.generatePubKey()[0]
data = secrets.token_hex(secrets.randbelow(500) + 1)
self.daemon._core.insertBlock(data, header='pm', encryptType='asym', asymPeer=fakePeer, meta={'subject': 'foo'})
self.daemon._core.insertBlock(data, header='db', encryptType='asym', asymPeer=fakePeer, meta={'subject': 'foo'})
self.daemon.decrementThreadCount('insertDeniableBlock')
return

View File

@ -8,7 +8,8 @@
"security_level": 0,
"max_block_age": 2678400,
"bypass_tor_check": false,
"public_key": ""
"public_key": "",
"random_bind_ip": true
},
"www" : {
@ -48,7 +49,7 @@
"verbosity" : "default",
"file": {
"output": true,
"output": false,
"path": "output.log"
},

View File

@ -20,6 +20,10 @@
friendListDisplay = document.getElementById('friendList')
addForm = document.getElementById('addFriend')
function removeFriend(pubkey){
post_to_url('/friends/remove/' + pubkey, {'token': webpass})
}
addForm.onsubmit = function(){
var friend = document.getElementsByName('addKey')[0]
var alias = document.getElementsByName('data')[0]
@ -68,4 +72,14 @@ fetch('/friends/list', {
entry.appendChild(nameText)
friendListDisplay.appendChild(entry)
}
// If friend delete buttons are pressed
var friendRemoveBtns = document.getElementsByClassName('friendRemove')
for (var x = 0; x < friendRemoveBtns.length; x++){
var friendKey = friendRemoveBtns[x].parentElement.getAttribute('data-pubkey')
friendRemoveBtns[x].onclick = function(){
removeFriend(friendKey)
}
}
})

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,10 @@
<div class='content'>
<img class='logo' src='/shared/onionr-icon.png' alt='onionr logo'>
<span class='logoText'>Onionr Mail ✉️</span>
<div>Current Used Identity: <input class='myPub' type='text' readonly> <button class='refresh'>Refresh Page</button></div>
<br><br>
<div><a href='/' class='idLink'>Home</a> <button class='refresh'>Refresh Page</button></div>
<br>
<div>Current Used Identity: <input class='myPub' type='text' readonly></div>
<br><br>
<div class="btn-group" id='tabBtns'>
<button class='activeTab'>Inbox</button><button>Sentbox</button><button>Send Message</button>

File diff suppressed because one or more lines are too long