mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
SPAM
This commit is contained in:
parent
a1bc9a27f2
commit
c8fe8ae00c
2
gun.js
2
gun.js
@ -1,5 +1,5 @@
|
||||
;(function(){
|
||||
//module.exports = require('../gun4');return;
|
||||
module.exports = require('../gun4');return;
|
||||
function Gun(o){
|
||||
var gun = this;
|
||||
if(!Gun.is(gun)){ return new Gun(o) }
|
||||
|
@ -40,6 +40,7 @@ Gun.on('opt').event(function(gun, opts) {
|
||||
get: function get(lex, cb, o){
|
||||
var node, soul = lex[Gun._.soul];
|
||||
node = all.nodes[soul];
|
||||
console.log("FILE.GET", lex, soul, node);
|
||||
if(!node){ return cb(null) }
|
||||
cb(null, node);
|
||||
node = Gun.is.node.soul.ify({}, soul);
|
||||
|
12
lib/wsp.js
12
lib/wsp.js
@ -97,15 +97,21 @@
|
||||
// except for the ones that are listed in the message as having already been sending to.
|
||||
// all states, implemented with GET, are replied to the source that asked for it.
|
||||
function tran(req, cb){
|
||||
//console.log("REQUEST", req);
|
||||
if(Gun.text.is(req.body)){
|
||||
if('?' === req.body.slice(-1)){
|
||||
req.lex = Gun.get.wire(req.body);
|
||||
delete req.body;
|
||||
}
|
||||
}
|
||||
req.method = req.body? 'put' : 'get'; // put or get is based on whether there is a body or not
|
||||
req.key = req.url.pathname.replace(gun.wsp.regex,'').replace(/^\//i,'') || '';
|
||||
console.log("REQUEST", req);
|
||||
if('get' == req.method){ return tran.get(req, cb) }
|
||||
if('put' == req.method || 'post' == req.method){ return tran.put(req, cb) }
|
||||
cb({body: {hello: 'world'}});
|
||||
}
|
||||
tran.get = function(req, cb){
|
||||
var key = req.key
|
||||
var key = req.lex || req.key
|
||||
, reply = {headers: {'Content-Type': tran.json}};
|
||||
//console.log(req);
|
||||
// NTS HACK! SHOULD BE ITS OWN ISOLATED MODULE! //
|
||||
@ -137,7 +143,7 @@
|
||||
//console.log("tran.get", key, "<---", err, node);
|
||||
if(err || !node){
|
||||
if(opt.on && opt.on.off){ opt.on.off() }
|
||||
return cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : null)});
|
||||
return cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : undefined)});
|
||||
}
|
||||
if(Gun.obj.empty(node)){
|
||||
if(opt.on && opt.on.off){ opt.on.off() }
|
||||
|
Loading…
x
Reference in New Issue
Block a user