Skip to content

Commit

Permalink
Rev907, Wait 200ms to opener close, Enable wrapper nonce security by …
Browse files Browse the repository at this point in the history
…default for new sites
  • Loading branch information
shortcutme committed Feb 21, 2016
1 parent da58f5a commit b2fb1fc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Config(object):

def __init__(self, argv):
self.version = "0.3.6"
self.rev = 906
self.rev = 907
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"
Expand Down
6 changes: 4 additions & 2 deletions src/Ui/media/Wrapper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ if window.opener and window.postmessage_nonce_security == false
# Window opener security problem workaround: Open a new window, close this one
console.log "Opener present:", window.opener
setTimeout ( -> # Wait 200ms to parent tab closing
console.log "Opener still present:", window.opener
if window.opener
# Opener still present, display message
elem = $("<div class='opener-overlay'><div class='dialog'>You have opened this page by clicking on a link. Please, confirm if you want to load this site.<a href='?' target='_blank' class='button'>Open site</a></div></div>")
Expand All @@ -400,6 +401,7 @@ if window.opener and window.postmessage_nonce_security == false
window.location.reload()
# Opener gone, continue init
# window.wrapper = new Wrapper(ws_url)
), 150
# window.wrapper.reload()
), 200
else
window.wrapper = new Wrapper(ws_url)
window.wrapper = new Wrapper(ws_url)
3 changes: 2 additions & 1 deletion src/Ui/media/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ jQuery.extend( jQuery.easing,
console.log("Opener present:", window.opener);
setTimeout((function() {
var elem;
console.log("Opener still present:", window.opener);
if (window.opener) {
elem = $("<div class='opener-overlay'><div class='dialog'>You have opened this page by clicking on a link. Please, confirm if you want to load this site.<a href='?' target='_blank' class='button'>Open site</a></div></div>");
elem.find('a').on("click", function() {
Expand All @@ -1281,7 +1282,7 @@ jQuery.extend( jQuery.easing,
} else {
return window.location.reload();
}
}), 150);
}), 200);
} else {
window.wrapper = new Wrapper(ws_url);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def siteCreate(self):

logging.info("Creating content.json...")
site = Site(address)
site.content_manager.sign(privatekey=privatekey)
site.content_manager.sign(privatekey=privatekey, extend={"postmessage_nonce_security": True})
site.settings["own"] = True
site.saveSettings()

Expand Down Expand Up @@ -335,6 +335,7 @@ def peerPing(self, peer_ip, peer_port=None):
print "Response time: %.3fs (crypt: %s)" % (time.time() - s, peer.connection.crypt)
time.sleep(1)


def peerGetFile(self, peer_ip, peer_port, site, filename, benchmark=False):
logging.info("Opening a simple connection server")
global file_server
Expand All @@ -355,6 +356,7 @@ def peerGetFile(self, peer_ip, peer_port, site, filename, benchmark=False):
else:
print peer.getFile(site, filename).read()


def peerCmd(self, peer_ip, peer_port, cmd, parameters):
logging.info("Opening a simple connection server")
global file_server
Expand Down

0 comments on commit b2fb1fc

Please sign in to comment.