1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | exports.toString = function (rcode) {
|
9 | switch (rcode) {
|
10 | case 0: return 'NOERROR'
|
11 | case 1: return 'FORMERR'
|
12 | case 2: return 'SERVFAIL'
|
13 | case 3: return 'NXDOMAIN'
|
14 | case 4: return 'NOTIMP'
|
15 | case 5: return 'REFUSED'
|
16 | case 6: return 'YXDOMAIN'
|
17 | case 7: return 'YXRRSET'
|
18 | case 8: return 'NXRRSET'
|
19 | case 9: return 'NOTAUTH'
|
20 | case 10: return 'NOTZONE'
|
21 | case 11: return 'RCODE_11'
|
22 | case 12: return 'RCODE_12'
|
23 | case 13: return 'RCODE_13'
|
24 | case 14: return 'RCODE_14'
|
25 | case 15: return 'RCODE_15'
|
26 | }
|
27 | return 'RCODE_' + rcode
|
28 | }
|
29 |
|
30 | exports.toRcode = function (code) {
|
31 | switch (code.toUpperCase()) {
|
32 | case 'NOERROR': return 0
|
33 | case 'FORMERR': return 1
|
34 | case 'SERVFAIL': return 2
|
35 | case 'NXDOMAIN': return 3
|
36 | case 'NOTIMP': return 4
|
37 | case 'REFUSED': return 5
|
38 | case 'YXDOMAIN': return 6
|
39 | case 'YXRRSET': return 7
|
40 | case 'NXRRSET': return 8
|
41 | case 'NOTAUTH': return 9
|
42 | case 'NOTZONE': return 10
|
43 | case 'RCODE_11': return 11
|
44 | case 'RCODE_12': return 12
|
45 | case 'RCODE_13': return 13
|
46 | case 'RCODE_14': return 14
|
47 | case 'RCODE_15': return 15
|
48 | }
|
49 | return 0
|
50 | }
|