Mercurial > sat_docs
view scripts/minifier/otr/sm-webworker.js @ 103:e69883c1ec30
docker (libervia_cont): added a "status" command:
- if libervia container is not running, it exits with error code 1
- if libervia container is running but no server is launched, it exits with error code 2
- if libervia container is running and server is launcher, it exits with error code 0 (success)
server detection is done by doing a simple grep on logs, that's not perfectly reliable (ports can be changed in configuration, even if that doesn't really make sense in Docker context) but should be good enough for this purpose.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 27 Feb 2016 00:45:40 +0100 |
parents | 1596660ddf72 |
children |
line wrap: on
line source
;(function (root) { "use strict"; root.OTR = {} root.crypto = { randomBytes: function () { throw new Error("Haven't seeded yet.") } } // default imports var imports = [ 'vendor/salsa20.js' , 'vendor/bigint.js' , 'vendor/crypto.js' , 'vendor/eventemitter.js' , 'lib/const.js' , 'lib/helpers.js' , 'lib/sm.js' ] function wrapPostMessage(method) { return function () { postMessage({ method: method , args: Array.prototype.slice.call(arguments, 0) }) } } var sm onmessage = function (e) { var data = e.data switch (data.type) { case 'seed': if (data.imports) imports = data.imports importScripts.apply(root, imports) // use salsa20 since there's no prng in webworkers var state = new root.Salsa20( data.seed.slice(0, 32), data.seed.slice(32) ) root.crypto.randomBytes = function (n) { return state.getBytes(n) } break case 'init': sm = new root.OTR.SM(data.reqs) ;['trust','question', 'send', 'abort'].forEach(function (m) { sm.on(m, wrapPostMessage(m)); }) break case 'method': sm[data.method].apply(sm, data.args) break } } }(this))