Skip to content

Commit 5274d3c

Browse files
committed
feat: dns server
1 parent 34eb162 commit 5274d3c

File tree

12 files changed

+1231
-0
lines changed

12 files changed

+1231
-0
lines changed

package-lock.json

Lines changed: 300 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dns/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@tcpip/dns",
3+
"version": "0.1.0",
4+
"description": "DNS server built on tcpip.js",
5+
"main": "dist/index.cjs",
6+
"types": "dist/index.d.ts",
7+
"type": "module",
8+
"scripts": {
9+
"build": "tsup --clean",
10+
"test": "vitest",
11+
"prepublishOnly": "npm run build"
12+
},
13+
"files": [
14+
"dist/**/*"
15+
],
16+
"exports": {
17+
".": {
18+
"import": "./dist/index.js",
19+
"types": "./dist/index.d.ts",
20+
"default": "./dist/index.cjs"
21+
}
22+
},
23+
"dependencies": {},
24+
"devDependencies": {
25+
"@total-typescript/tsconfig": "^1.0.4",
26+
"tcpip": "0.2",
27+
"typescript": "^5.0.4",
28+
"vitest": "^3.0.1"
29+
}
30+
}

packages/dns/src/constants.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export const TypeCode = {
2+
A: 1, // IPv4
3+
NS: 2, // Nameserver
4+
CNAME: 5, // Canonical name
5+
SOA: 6, // Start of authority
6+
PTR: 12, // Pointer
7+
MX: 15, // Mail exchange
8+
TXT: 16, // Text
9+
AAAA: 28, // IPv6
10+
SRV: 33, // Service locator
11+
ANY: 255, // Any
12+
} as const;
13+
14+
export const ClassCode = {
15+
IN: 1, // Internet
16+
} as const;
17+
18+
export const OpCode = {
19+
QUERY: 0, // Standard query
20+
} as const;
21+
22+
export const RCode = {
23+
NOERROR: 0, // No error
24+
SERVFAIL: 2, // Server failure
25+
NXDOMAIN: 3, // Non-existent domain
26+
} as const;

0 commit comments

Comments
 (0)