https://github.com/shuque/goparsezone
Parse master DNS zone format file and process it
https://github.com/shuque/goparsezone
Last synced: 9 months ago
JSON representation
Parse master DNS zone format file and process it
- Host: GitHub
- URL: https://github.com/shuque/goparsezone
- Owner: shuque
- Created: 2025-06-22T22:03:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-22T22:07:01.000Z (about 1 year ago)
- Last Synced: 2025-06-22T23:18:44.231Z (about 1 year ago)
- Language: Go
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DNS Zone Parser
A Go program that parses DNS master file format zone files and displays their contents.
Written with the help of Cursor, mainly to evaluate its ability to generate working Go code.
## Features
- Parses standard DNS master file format
- Handles $ORIGIN and $TTL directives
- Supports quoted strings in RDATA
- Handles multi-line records (like SOA)
- Supports TTL values with time units (S, M, H, D, W)
- Proper error handling with line numbers
## Usage
```bash
go run main.go
```
Or build and run:
```bash
go build -o dns-parser main.go
./dns-parser
```
## Example
```bash
go run main.go example.zone
```
This will parse the `example.zone` file and display all DNS records in a structured format.
## Zone File Format
The program expects standard DNS master file format:
```
$ORIGIN example.com.
$TTL 3600
@ IN SOA ns1.example.com. admin.example.com. (
2023120101 ; serial
3600 ; refresh
1800 ; retry
1209600 ; expire
3600 ; minimum TTL
)
@ IN NS ns1.example.com.
www IN A 192.168.1.20
```
## Error Handling
The program provides detailed error messages including:
- File not found errors
- Parsing errors with line numbers
- Invalid record format errors
## Requirements
- Go 1.16 or later