Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bughandler/libdnspacket
A single file cpp17 header only DNS packet parser/builder.
https://github.com/bughandler/libdnspacket
cpp17 dns parser
Last synced: about 2 months ago
JSON representation
A single file cpp17 header only DNS packet parser/builder.
- Host: GitHub
- URL: https://github.com/bughandler/libdnspacket
- Owner: bughandler
- License: mit
- Created: 2022-06-22T12:11:23.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-19T11:28:49.000Z (about 2 years ago)
- Last Synced: 2024-08-18T08:29:38.004Z (5 months ago)
- Topics: cpp17, dns, parser
- Language: C++
- Homepage:
- Size: 73.2 KB
- Stars: 26
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libdnspacket
An ultra lightweight, cross platform and single header DNS packet parser & builder.+ Easy to use
+ No external dependency
+ Parse DNS packet
+ Build DNS packet
+ DNS host name compression
+ Support multiple DNS record types
> + A
> + NS
> + CNAME
> + SOA
> + PTR
> + MX
> + TXT
> + AAAA
> + SPF### How to use
1. Just copy `libdnspacket` into your project folder
2. Include `libdnspacket/dns.hpp`
3. You are ready to go### APIs
There are two simple APIs.
+ Parse raw DNS packet into DNS message
``` c++
//
// Parameters:
// buf: point to the raw DNS packet
// bufSize: indicate the size of [buf]
// Return:
//
// #1: indicate whether the packet was parsed successfully or not
// #2: when #1 value is true, this is the final structured DNS message
//
std::tuple dns::Parse(const uint8_t* buf, size_t bufSize);
```+ Build raw DNS packet from DNS message
``` c++
//
// Parameters:
// message: the structured DNS message
// Return:
// The byte buffer of raw DNS packet
//
std::vector dns::Build(const DnsMessage& message);
```
### Notes
+ Any feedback is welcome