From ca8655a676cb3c3a22509b6480e064fb784b03c4 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Fri, 21 Feb 2020 08:52:52 +0100 Subject: [PATCH] Use tunnel ping instead of gossip ping, more stable --- dist/bundle-core.js | 4 ++-- net.js | 2 +- ssb-db.js | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dist/bundle-core.js b/dist/bundle-core.js index bc9fe22..358b844 100644 --- a/dist/bundle-core.js +++ b/dist/bundle-core.js @@ -1310,7 +1310,7 @@ const validate=require("ssb-validate");module.exports=function(){var t={},a=null },{"ssb-validate":603}],190:[function(require,module,exports){ (function (Buffer){ -const SecretStack=require("secret-stack"),caps=require("ssb-caps"),ssbKeys=require("ssb-keys"),path=require("path");exports.init=function(e,s){var r,n=ssbKeys.loadOrCreateSync(path.join(e,"secret")),t=Object.assign({caps:{shs:Buffer.from(caps.shs,"base64")},keys:n,connections:{incoming:{tunnel:[{transform:"shs"}]},outgoing:{net:[{transform:"shs"}],ws:[{transform:"shs"},{transform:"noauth"}],tunnel:[{transform:"shs"}]}},path:e,timers:{inactivity:3e4},tunnel:{logging:!0},replicate:{legacy:!1},blobs:{sympathy:0,stingy:!1,pushy:3,max:262144}},s),i=SecretStack(t).use(require("./ssb-db")).use(require("./ssb-get-thread")).use(require("./simple-ooo")).use(require("ssb-ws")).use(require("ssb-replicate")).use(require("ssb-ebt")).use(require("ssb-no-auth")).use(require("ssb-tunnel")).use(require("./tunnel-chat")).use(require("./simple-blobs"))();return i.on("rpc:connect",function(e,s){console.log("connected to:",e.id),function s(){e.gossip.ping(function(e,n){if(e)return console.error(e);clearTimeout(r),r=setTimeout(s,1e4)})}()}),i.on("replicate:finish",function(){console.log("finished ebt replicate")}),i.gossip={connect:function(e,s){i.connect(SSB.remoteAddress,s)}},i}; +const SecretStack=require("secret-stack"),caps=require("ssb-caps"),ssbKeys=require("ssb-keys"),path=require("path");exports.init=function(e,s){var r,n=ssbKeys.loadOrCreateSync(path.join(e,"secret")),t=Object.assign({caps:{shs:Buffer.from(caps.shs,"base64")},keys:n,connections:{incoming:{tunnel:[{transform:"shs"}]},outgoing:{net:[{transform:"shs"}],ws:[{transform:"shs"},{transform:"noauth"}],tunnel:[{transform:"shs"}]}},path:e,timers:{inactivity:3e4},tunnel:{logging:!0},replicate:{legacy:!1},blobs:{sympathy:0,stingy:!1,pushy:3,max:262144}},s),i=SecretStack(t).use(require("./ssb-db")).use(require("./ssb-get-thread")).use(require("./simple-ooo")).use(require("ssb-ws")).use(require("ssb-replicate")).use(require("ssb-ebt")).use(require("ssb-no-auth")).use(require("ssb-tunnel")).use(require("./tunnel-chat")).use(require("./simple-blobs"))();return i.on("rpc:connect",function(e,s){console.log("connected to:",e.id),function s(){e.tunnel.ping(function(e,n){if(e)return console.error(e);clearTimeout(r),r=setTimeout(s,1e4)})}()}),i.on("replicate:finish",function(){console.log("finished ebt replicate")}),i.gossip={connect:function(e,s){i.connect(SSB.remoteAddress,s)}},i}; }).call(this,require("buffer").Buffer) },{"./simple-blobs":625,"./simple-ooo":626,"./ssb-db":627,"./ssb-get-thread":628,"./tunnel-chat":630,"buffer":52,"path":121,"secret-stack":543,"ssb-caps":572,"ssb-ebt":573,"ssb-keys":579,"ssb-no-auth":584,"ssb-replicate":598,"ssb-tunnel":601,"ssb-ws":604}],191:[function(require,module,exports){ @@ -3059,7 +3059,7 @@ const path=require("path"),raf=require("polyraf"),pull=require("pull-stream"),de var pull=require("pull-stream"),GQ=require("gossip-query"),hash=require("ssb-keys/util").hash,isMsg=require("ssb-ref").isMsg,checkInvalidOOO=require("ssb-validate").checkInvalidOOO;function getId(e){return"%"+hash(JSON.stringify(e,null,2))}function isObject(e){return e&&"object"==typeof e}exports.name="ooo",exports.version="1.0.0",exports.manifest={stream:"duplex",get:"async",help:"sync"},exports.permissions={anonymous:{allow:["stream"]}},exports.init=function(e,t){e.id;var n=t.ooo||{},r=GQ({isQuery:isMsg,isRequest:function(e){return Number.isInteger(e)&&e<0},isResponse:function(e){return e&&isObject(e)},check:function(e,t){SSB.db.get(e,t)},isUpdate:function(e,t,n){return null==n&&getId(t)==e},process:function(e,t,n){e!==getId(t)||checkInvalidOOO(t,null)?n():n(null,t)},timeout:n.timeout||3e4});return e.on("rpc:connect",function(e,t){if(t){var n=r.createStream(e.id);pull(n,e.ooo.stream(function(){}),n)}}),{stream:function(){return r.createStream(this.id)},get:function(e,t){var i,o=isMsg(e)?e:e.id,u=null!=e.timeout?e.timeout:null==n.timeout?5e3:n.timeout;u>0&&(i=setTimeout(function(){var e=t;t=null,e(new Error("ooo.get: took more than timeout:"+u))},u)),console.log("doing a query for",o),r.query(o,function(e,n){if(e)return t(e);clearTimeout(i),t&&t(null,n)})}}}; },{"gossip-query":285,"pull-stream":470,"ssb-keys/util":583,"ssb-ref":595,"ssb-validate":603}],627:[function(require,module,exports){ -const pull=require("pull-stream");var Obv=require("obv");exports.manifest={createHistoryStream:"source",partialReplication:{partialReplication:"source",partialReplicationReverse:"source"},gossip:{ping:"duplex"}},exports.permissions={anonymous:{allow:["createHistoryStream"],deny:null}},exports.init=function(e,t){return e.createHistoryStream=function(){return pull.empty()},e.post=Obv(),e.getVectorClock=function(e,t){t||(t=e),SSB.events.on("SSB: loaded",function(){var e=SSB.db.last.get(),r={};for(var n in e)r[n]=e[n].sequence;t(null,r)})},e.getAtSequence=function(e,t){SSB.db.clock.get("string"==typeof e?e.split(":"):e,function(e,r){var n;e?t(e):t(null,((n=r).value=function(e){var t={};for(let r in e)"meta"!==r&&"cyphertext"!==r&&"private"!==r&&"unbox"!==r&&(t[r]=e[r]);if(e.meta&&e.meta.original)for(let r in e.meta.original)t[r]=e.meta.original[r];return t}(n.value),n))})},e.add=function(e,t){SSB.db.validateAndAddStrictOrder(e,t)},{}}; +const pull=require("pull-stream");var Obv=require("obv");exports.manifest={createHistoryStream:"source",partialReplication:{partialReplication:"source",partialReplicationReverse:"source"}},exports.permissions={anonymous:{allow:["createHistoryStream"],deny:null}},exports.init=function(e,t){return e.createHistoryStream=function(){return pull.empty()},e.post=Obv(),e.getVectorClock=function(e,t){t||(t=e),SSB.events.on("SSB: loaded",function(){var e=SSB.db.last.get(),r={};for(var n in e)r[n]=e[n].sequence;t(null,r)})},e.getAtSequence=function(e,t){SSB.db.clock.get("string"==typeof e?e.split(":"):e,function(e,r){var n;e?t(e):t(null,((n=r).value=function(e){var t={};for(let r in e)"meta"!==r&&"cyphertext"!==r&&"private"!==r&&"unbox"!==r&&(t[r]=e[r]);if(e.meta&&e.meta.original)for(let r in e.meta.original)t[r]=e.meta.original[r];return t}(n.value),n))})},e.add=function(e,t){SSB.db.validateAndAddStrictOrder(e,t)},{}}; },{"obv":395,"pull-stream":470}],628:[function(require,module,exports){ exports.manifest={get:"async"},exports.name="get-thread",exports.permissions={anonymous:{allow:["get"]}},exports.init=function(t,e){return{get:function(t,e){}}}; diff --git a/net.js b/net.js index 61e4049..024fa26 100644 --- a/net.js +++ b/net.js @@ -57,7 +57,7 @@ exports.init = function(dir, overwriteConfig) { console.log("connected to:", rpc.id) function ping() { - rpc.gossip.ping(function (err, _ts) { + rpc.tunnel.ping(function (err, _ts) { if (err) return console.error(err) clearTimeout(timer) timer = setTimeout(ping, 10e3) diff --git a/ssb-db.js b/ssb-db.js index 4f7717d..0545499 100644 --- a/ssb-db.js +++ b/ssb-db.js @@ -9,9 +9,6 @@ exports.manifest = { partialReplication: { partialReplication: 'source', partialReplicationReverse: 'source', - }, - gossip: { - ping: 'duplex' } }