git ssb

15+

ansuz / dnssb



Commit aa8bdc9d1c7570e788c3416709fa6ef788024cec

Merge remote-tracking branch 'origin/master' into update

cel committed on 11/1/2016, 5:24:41 PM
Parent: c93111a7768b13d7bed3ff7994833c1b1279a1ae
Parent: 0553b24bb466e1e4ead0148e234950014b19335f

Files changed

README.mdchanged
index.jschanged
lib/publish.jschanged
lib/server.jschanged
package.jsonchanged
README.mdView
@@ -1,5 +1,5 @@
1-# ssb-dns
1 +# dnssb
22
33 It's fairly easy to [serve dns](https://github.com/iriscouch/dnsd) from a nodejs process.
44
55 [scuttlebot](http://ssbc.github.io/scuttlebot/) makes it easy to work with a peer-to-peer log store.
@@ -18,16 +18,16 @@
1818
1919 Or via git:
2020
2121 ```
22-git clone https://github.com/ansuz/ssb-dns;
23-cd ssb-dns;
22 +git clone https://github.com/ansuz/dnssb;
23 +cd dnssb;
2424 npm i -g;
2525 ```
2626
2727 ## Usage
2828
29-`ssb-dns` assumes that you have a scuttlebot instance running.
29 +`dnssb` assumes that you have a scuttlebot instance running.
3030 You can find out more about scuttlebot [here](https://ssbc.github.io/scuttlebot/).
3131
3232 ## Publish a record
3333
@@ -37,12 +37,12 @@
3737
3838 In the future this might be genralized to squat even more TLDs, or to simply be unopinionated about them.
3939
4040 ```
41-ssb-dns publish [{prev record key}...] {domain name} {record type} {value} [optionally add a dns class]
41 +dnssb publish [{prev record key}...] {domain name} {record type} {value} [optionally add a dns class]
4242 ```
4343
44-To replace some existing ssb-dns records, pass their ssb message id(s) as
44 +To replace some existing dnssb records, pass their ssb message id(s) as
4545 the first arguments to the publish command. To append a record to the set of
4646 existing records, omit the message ids.
4747
4848 To replace all existing records for a name+type+class, use `update`:
@@ -50,14 +50,26 @@
5050 ```
5151 ssb-dns update {domain name} {record type} {value} [optionally add a dns class]
5252 ```
5353
54 +## Display all records
55 +
56 +> I want to use this
57 +
58 +You'll only be able to resolve records that your node knows about.
59 +
60 +You can print a list of valid records with:
61 +
62 +```
63 +dnssb dump
64 +```
65 +
5466 ## Fetch a record
5567
5668 First launch the server in one terminal:
5769
5870 ```
59-ssb-dns server {port: 53053} {host: 127.0.0.1}
71 +dnssb server {port: 53053} {host: 127.0.0.1}
6072 ```
6173
6274 Then query it for a record:
6375
@@ -68,29 +80,46 @@
6880 ## FAQ
6981
7082 > Can I use this without running [scuttlebot](http://github.com/ssbc/scuttlebot)?
7183
72-You could get a friend to host ssb-dns for you if you _really_ trust them.
84 +You could get a friend to host dnssb for you if you _really_ trust them and don't care if they see all your dns requests.
7385 Once running, you should be able to use the dns server as you would any other dns provider.
7486
7587 > Is it Enterprise-Ready?
7688
77-Hell no. It barely works
89 +That depends on your the needs of your Enterprise, but I would lean towards _no_.
7890
7991 > Does it protect against name-squatting?
8092
81-Not even a little bit.
93 +The records available to dnssb are sourced from your ssb social network, so the quality of your results will depend on who you choose to follow (and who they choose to follow).
8294
95 +> How can I deal with malicious behaviour?
96 +
97 +Records must be published by someone in your social network, and all such records are cryptographically signed using their private key.
98 +
99 +If you notice malicious behaviour, it can always be traced back to the person who published it, through your social graph, if need be.
100 +Naming things is a social problem, and the best way to resolve conflicts is probably to discuss it.
101 +
102 +Additionally, in the future there will be better support for reporting and blocking abusive behaviour.
103 +
83104 > Does it resolve conflicts if they occur?
84105
85106 Not yet.
86107
87108 > What is it good for?
88109
89-1. If there is a DNS outage you can still resolve any you or your friends have published to ssb
90-2. If you don't have access to the internet at all, this will continue to work (for some definition of work)
110 +1. If there is a DNS outage you can still resolve any records you or your friends have published to ssb.
111 +2. As with everything committed to ssb, records are stored locally (and indefinitely) in a set of hash chains (one for each user). As such, if you don't have access to the internet at all, this will continue to work
91112 3. You can use this as a kind of distributed hosts file
92113
93114 > How optimized is this?
94115
95116 Not much, but it should get better over time if people are interested in using it.
96117
118 +> Is there a web interface?
119 +
120 +Not yet, but I'd like there to be!
121 +
122 +> Does it handle wildcard entries?
123 +
124 +Not yet, but I'd like it to!
125 +
index.jsView
@@ -60,9 +60,8 @@
6060 while (argv[1] && SsbRef.isMsgId(argv[1])) {
6161 branches.push(argv.splice(1));
6262 }
6363
64- console.log(argv.length);
6564 if (argv.length < 4) {
6665 console.log("Try:");
6766 console.error(publishHelp);
6867 return;
lib/publish.jsView
@@ -22,32 +22,32 @@
2222 var endsInSSB = Publish.endsInSSB = function (s) {
2323 return /\.ssb$/i.test(s);
2424 };
2525
26-var isValidRecord = Publish.isValidRecord = function (record) {
27- // TODO return what's wrong with the input instead of a boolean
26 +var validateRecord = Publish.validateRecord = function (record) {
27 + if (!endsInSSB(record.name)) { return "[Record NameError] records must end in .ssb"; }
28 + if (!isValidType(record.type)) { return "[Record TypeError] " + record.type + " is not a valid dns type"; }
29 + if (!isValidClass(record.class)) { return "[Record ClassError] class must be one of [" + CLASSES.join(', ') + "]"; }
2830
29- return endsInSSB(record.name) && // it ends in .ssb
30- record.value && // there is a value // TODO validate that it is correct for the type
31- isValidType(record.type) && // it is a valid type
32- isValidClass(record.class); // there is a class // TODO make sure it's valid
31 + // TODO rename 'value' to 'data' ???
32 + // TODO perform stricter validation on value
33 + if (!(record.value && typeof(record.value) === 'string')) { return "[Record DataError] expected a value to publish"; }
3334 };
3435
3536 var makeRecord = Publish.makeRecord = function (name, type, value, _class) {
3637 return {
3738 name: typeof(name) === 'string' && name.toLowerCase(), // domain names must be lowercase
3839 type: type,
39- value: value,
40 + value: value, // TODO change to 'data' ???
4041 class: _class || 'IN',
4142 };
4243 };
4344
4445 Publish.record = function (branches, name, type, value, _class, cb) {
4546 var record = makeRecord(name, type, value, _class);
4647
47- if (!isValidRecord(record)) {
48- return void cb(new Error("invalid input"));
49- }
48 + var complaint = validateRecord(record);
49 + if (complaint) { return void cb(new Error(complaint)); }
5050
5151 if (!branches.every(SsbRef.isMsgId)) {
5252 return void cb(new Error("invalid branches"));
5353 }
@@ -64,16 +64,10 @@
6464
6565 // publish a message
6666 sbot.publish(val, function (err, msg) {
6767 if (err) { return void cb(err); }
68-
69-
7068 sbot.close();
7169 return void cb(err, msg);
72-
73- console.log(msg);
74-
75- console.log(JSON.stringify(record, null, 4));
7670 })
7771 });
7872 };
7973
lib/server.jsView
@@ -53,11 +53,11 @@
5353 res.end();
5454 }));
5555 };
5656
57-var createServer = function (sbot, port, host, cb, opt) {
57 +var createServer = Server.create = function (sbot, port, host, cb, opt) {
5858 var Dnsd = require("dnsd");
59- Dnsd.createServer(function(req, res) {
59 + return Dnsd.createServer(function(req, res) {
6060 answer(sbot, req, res, opt);
6161 }).listen(port, host, cb);
6262 };
6363
@@ -67,8 +67,16 @@
6767 if (err) {
6868 console.error(err);
6969 return void process.exit(1);
7070 }
71- createServer(sbot, port, host, cb, opt);
71 + var server = createServer(sbot, port, host, cb, opt);
72 +
73 + var close = function () {
74 + console.error("Server connection lost. Shutting down");
75 + sbot.close();
76 + server.close();
77 + };
78 +
79 + sbot.on('closed', close);
7280 });
7381 };
7482
package.jsonView
@@ -1,10 +1,13 @@
11 {
22 "name": "ssb-dns",
3- "version": "1.0.20",
3 + "version": "1.0.22",
44 "description": "resolve dns via ssb",
55 "main": "index.js",
6- "bin": "index.js",
6 + "bin": {
7 + "dnssb": "index.js",
8 + "ssb-dns": "index.js"
9 + },
710 "scripts": {
811 "test": "echo \"Error: no test specified\" && exit 1"
912 },
1013 "dependencies": {

Built with git-ssb-web