Skip to content

DNS server #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
300 changes: 300 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions packages/dns/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@tcpip/dns",
"version": "0.1.0",
"description": "DNS server built on tcpip.js",
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
"build": "tsup --clean",
"test": "vitest",
"prepublishOnly": "npm run build"
},
"files": [
"dist/**/*"
],
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
},
"dependencies": {},
"devDependencies": {
"@total-typescript/tsconfig": "^1.0.4",
"tcpip": "0.2",
"typescript": "^5.0.4",
"vitest": "^3.0.1"
}
}
26 changes: 26 additions & 0 deletions packages/dns/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const TypeCode = {
A: 1, // IPv4
NS: 2, // Nameserver
CNAME: 5, // Canonical name
SOA: 6, // Start of authority
PTR: 12, // Pointer
MX: 15, // Mail exchange
TXT: 16, // Text
AAAA: 28, // IPv6
SRV: 33, // Service locator
ANY: 255, // Any
} as const;

export const ClassCode = {
IN: 1, // Internet
} as const;

export const OpCode = {
QUERY: 0, // Standard query
} as const;

export const RCode = {
NOERROR: 0, // No error
SERVFAIL: 2, // Server failure
NXDOMAIN: 3, // Non-existent domain
} as const;
Loading