git ssb

15+

ansuz / dnssb



Commit 43596ee016af3e2c1709e0734c63755a47e1f3d6

don't stringify records. send the correct function signature

ansuz committed on 10/31/2016, 2:52:52 PM
Parent: 4f20c03084a7047f145cae482611adee823c5421

Files changed

publish.jschanged
config.js.distdeleted
config.dist.jsadded
publish.jsView
@@ -27,29 +27,29 @@
2727 return /\.ssb$/i.test(s);
2828 };
2929
3030 var isValidRecord = function (record) {
31- return endsInSSB(record.name) &&
32- record.value &&
33- isValidType(record.type) &&
34- isValidClass(record.class);
31 + return endsInSSB(record.name) && // it ends in .ssb
32 + record.value && // there is a value // TODO validate that it is correct for the type
33 + isValidType(record.type) && // it is a valid type
34 + isValidClass(record.class); // there is a class // TODO make sure it's valid
3535 };
3636
3737 var makeRecord = function (name, type, value, _class) {
3838 return {
3939 name: name,
4040 type: type,
41 + value: value,
4142 class: _class || 'IN',
42- value: value
4343 };
4444 };
4545
4646 var serialize = function (record) {
4747 return JSON.stringify(record);
4848 };
4949
50-var publish = function (name, type, _class) {
51- var record = makeRecord(name, type, _class);
50 +var publish = function (name, type, value, _class) {
51 + var record = makeRecord(name, type, value, _class);
5252
5353 if (!isValidRecord(record)) {
5454 console.error("invalid input");
5555 return void process.exit(1);
@@ -61,10 +61,9 @@
6161 return void process.exit(1);
6262 }
6363
6464 // publish a message
65- sbot.publish({ type: 'ssb-dns', text: serialize(record) }, function (err, msg) {
66-
65 + sbot.publish({ type: 'ssb-dns', record: record }, function (err, msg) {
6766 console.log(msg);
6867
6968 console.log(JSON.stringify(record, null, 4));
7069 sbot.close();
@@ -75,5 +74,6 @@
7574 })
7675 });
7776 };
7877
79-publish(args[0], args[1], args[2]);
78 +// name type value class
79 +publish(args[0], args[1], args[2], args[3]);
config.js.distView
@@ -1,7 +1,0 @@
1-var Config = module.exports = {
2- port: 53053,
3- host: '127.0.0.1',
4- ready: function () {
5- console.log("\nServer running at %s:%s", Config.host, Config.port);
6- },
7-};
config.dist.jsView
@@ -1,0 +1,7 @@
1 +var Config = module.exports = {
2 + port: 53053,
3 + host: '127.0.0.1',
4 + ready: function () {
5 + console.log("\nServer running at %s:%s", Config.host, Config.port);
6 + },
7 +};

Built with git-ssb-web