domain_name
import "github.com/TheManticoreProject/Manticore/network/llmnr/domain_name"
Index
- func DecodeDomainName(data []byte, offset int) (string, int, error)
- func EncodeDomainName(name string) ([]byte, error)
- func ValidateDomainName(name string) error
- type DomainName
func DecodeDomainName
func DecodeDomainName(data []byte, offset int) (string, int, error)
DecodeDomainName parses a domain name from LLMNR/DNS wire format located at offset inside the full message buffer data. Because DNS/LLMNR compression pointers are offsets from the start of the message (RFC 1035 §4.1.4), data MUST be the whole message (starting at the header ID field) rather than a sub-slice, otherwise 0xC0 pointers resolve against the wrong origin.
It returns the decoded name, the new offset (past the encoded name in the original stream — a compression pointer counts as exactly two bytes at the point it appears), and an error if decoding fails.
func EncodeDomainName
func EncodeDomainName(name string) ([]byte, error)
EncodeDomainName serializes a domain name into LLMNR/DNS wire format. Labels are length-prefixed and the sequence is terminated by a zero-length label.
func ValidateDomainName
func ValidateDomainName(name string) error
ValidateDomainName validates a domain name according to LLMNR/DNS label rules.
type DomainName
type DomainName string
func (*DomainName) Marshal
func (d *DomainName) Marshal() ([]byte, error)
func (*DomainName) Unmarshal
func (d *DomainName) Unmarshal(data []byte) (int, error)
Unmarshal decodes a domain name from data starting at offset 0 and sets the receiver. It returns the number of bytes consumed from data.
This entry point treats data as if the name started at the very beginning of the message, so it can only resolve compression pointers that reference bytes present in data. When the name lives inside a larger message and may contain 0xC0 compression pointers that reference earlier bytes, callers must use UnmarshalFromMessage instead so the pointers resolve against the message origin.
func (*DomainName) UnmarshalFromMessage
func (d *DomainName) UnmarshalFromMessage(message []byte, offset int) (int, error)
UnmarshalFromMessage decodes a domain name located at offset inside the full message buffer and sets the receiver. Compression pointers (0xC0) are resolved relative to the start of message, as mandated by RFC 1035 §4.1.4.
It returns the number of bytes consumed in the original stream at offset. A compression pointer consumes exactly two bytes at the point it appears, regardless of the length of the name it references.
func (*DomainName) Validate
func (d *DomainName) Validate() error