Skip to content

Commit a1f93f6

Browse files
committed
Small Changes
- sort gitignore - fix README - fix docs/index
1 parent 2b1adaa commit a1f93f6

File tree

3 files changed

+75
-70
lines changed

3 files changed

+75
-70
lines changed

.gitignore

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
.DS_Store
1+
# Files
22
*.swmp
3-
node_modules
43
npm-debug.log
5-
tmp
4+
5+
# Folders
6+
tmp/
7+
node_modules/
8+
.DS_Store/
9+
.vs/

README.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ Node-named is a lightweight DNS server written in pure javascript. It has
44
limited support for the DNS spec, but aims to implement all of the *common*
55
functionality that is in use today.
66

7-
8-
97
## Creating a DNS Server
10-
```javascript
11-
var named = require('./lib/index');
12-
var server = named.createServer();
13-
var ttl = 300;
14-
15-
server.listen(9999, '127.0.0.1', function() {
16-
console.log('DNS server started on port 9999');
17-
});
18-
19-
server.on('query', function(query) {
20-
var domain = query.name();
21-
console.log('DNS Query: %s', domain)
22-
var target = new named.SOARecord(domain, {serial: 12345});
23-
query.addAnswer(domain, target, ttl);
24-
server.send(query);
25-
});
8+
9+
```js
10+
var named = require('./lib/index');
11+
var server = named.createServer();
12+
var ttl = 300;
13+
14+
server.listen(9999, '127.0.0.1', function() {
15+
console.log('DNS server started on port 9999');
16+
});
17+
18+
server.on('query', function(query) {
19+
var domain = query.name();
20+
console.log('DNS Query: %s', domain)
21+
var target = new named.SOARecord(domain, {serial: 12345});
22+
query.addAnswer(domain, target, ttl);
23+
server.send(query);
24+
});
2625
```
26+
2727
## Creating DNS Records
2828

2929
node-named provides helper functions for creating DNS records.
@@ -32,12 +32,13 @@ of ['A', 'AAAA', 'CNAME', 'SOA', 'MX', 'NS', 'TXT, 'SRV']. It is important to
3232
remember that these DNS records are not permanently added to the server.
3333
They only exist for the length of the particular request. After that, they are
3434
destroyed. This means you have to create your own lookup mechanism.
35-
```javascript
36-
var named = require('node-named');
37-
38-
var soaRecord = new named.SOARecord('example.com', {serial: 201205150000});
39-
console.log(soaRecord);
35+
```js
36+
var named = require('node-named');
37+
38+
var soaRecord = new named.SOARecord('example.com', {serial: 201205150000});
39+
console.log(soaRecord);
4040
```
41+
4142
### Supported Record Types
4243

4344
The following record types are supported
@@ -53,15 +54,15 @@ The following record types are supported
5354

5455
## Logging
5556

56-
node-named uses [http://github.com/trentm/node-bunyan](bunyan) for logging.
57+
node-named uses [bunyan](http://github.com/trentm/node-bunyan) for logging.
5758
It's a lot nicer to use if you npm install bunyan and put the bunyan tool in
5859
your path. Otherwise, you will end up with JSON formatted log output by default.
5960

6061
### Replacing the default logger
6162

6263
You can pass in an alternate logger if you wish. If you do not, then it will use
63-
bunyan by default. Your logger must expose the functions 'info', 'debug',
64-
'warn', 'trace', 'error', and 'notice'.
64+
bunyan by default. Your logger must expose the functions `info`, `debug`,
65+
`warn`, `trace`, `error`, and `notice`.
6566

6667
### TODO
6768

docs/index.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,55 @@ pluggable storage mechanisms. This DNS server is good for creating services
1818
where your records may change frequently, or you would like to access records
1919
stored in a central system using a mechanism of your choosing.
2020

21-
2221
# Installation
2322

24-
$ npm install named
23+
`$ npm install named`
2524

2625
# Server API
2726

28-
var named = require('./lib/index');
29-
var server = named.createServer();
27+
```js
28+
var named = require('./lib/index');
29+
var server = named.createServer();
3030

31-
server.listen(9999, '127.0.0.1', function() {
32-
console.log('DNS server started on port 9999');
33-
});
31+
server.listen(9999, '127.0.0.1', function() {
32+
console.log('DNS server started on port 9999');
33+
});
3434

35-
server.on('query', function(query) {
36-
var domain = query.name();
37-
var target = new named.SOARecord(domain, {serial: 12345});
38-
// 300 is the ttl for this record
39-
query.addAnswer(domain, target, 300);
40-
server.send(query);
41-
});
35+
server.on('query', function(query) {
36+
var domain = query.name();
37+
var target = new named.SOARecord(domain, { serial: 12345 });
38+
// 300 is the ttl for this record
39+
query.addAnswer(domain, target, 300);
40+
server.send(query);
41+
});
42+
```
4243

4344
Hit this DNS server with `dig` to see some results. Because we are only
4445
handling DNS responses for one record type (SOA or 'Start of Authority'), that
4546
is the response we will see, regardless of the type we make a request for. Dig
4647
is nice about this.
48+
```
49+
$ dig @localhost -p9999 example.com SOA
4750
48-
$ dig @localhost -p9999 example.com SOA
49-
50-
; <<>> DiG 9.7.3-P3 <<>> @localhost -p9999 example.com SOA
51-
; (3 servers found)
52-
;; global options: +cmd
53-
;; Got answer:
54-
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32739
55-
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
56-
;; WARNING: recursion requested but not available
57-
58-
;; QUESTION SECTION:
59-
;example.com. IN SOA
51+
; <<>> DiG 9.7.3-P3 <<>> @localhost -p9999 example.com SOA
52+
; (3 servers found)
53+
;; global options: +cmd
54+
;; Got answer:
55+
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32739
56+
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
57+
;; WARNING: recursion requested but not available
6058
61-
;; ANSWER SECTION:
62-
example.com. 5 IN SOA example.com. hostmaster.example.com. 12345 10 10 10 10
59+
;; QUESTION SECTION:
60+
;example.com. IN SOA
6361
64-
;; Query time: 10 msec
65-
;; SERVER: ::1#9999(::1)
66-
;; WHEN: Wed May 23 19:24:09 2012
67-
;; MSG SIZE rcvd: 109
62+
;; ANSWER SECTION:
63+
example.com.5 IN SOA example.com. hostmaster.example.com. 12345 10 10 10 10
6864
65+
;; Query time: 10 msec
66+
;; SERVER: ::1#9999(::1)
67+
;; WHEN: Wed May 23 19:24:09 2012
68+
;; MSG SIZE rcvd: 109
69+
```
6970

7071
## Named API
7172

@@ -79,14 +80,15 @@ options is an object which may specify:
7980
- name: an optional name used to identify the server
8081

8182
Here is an example a named server listening on port 53
83+
```js
84+
var named = require('named');
8285

83-
var named = require('named');
86+
var server = named.createServer({
87+
name: 'named0'
88+
});
8489

85-
var server = named.createServer({
86-
name: 'named0'
87-
});
88-
89-
server.listen(53);
90+
server.listen(53);
91+
```
9092

9193
## Class: named.Server
9294

@@ -301,6 +303,4 @@ DnsErrors are:
301303
Returns the message that was passed in to the error. The message is a string,
302304
and can be used for logging purposes
303305

304-
## Server Properties
305-
306-
306+
<!--## Server Properties>

0 commit comments

Comments
 (0)