dio

package
v0.0.0-...-5abfbfe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package dio provides functions to read and write DNS messages from and to the wire

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultReader

type DefaultReader struct {
	AncillarySize int
}

func (*DefaultReader) ReadTCP

func (r *DefaultReader) ReadTCP(conn net.Conn) ([]byte, error)

func (*DefaultReader) ReadUDP

func (r *DefaultReader) ReadUDP(c *net.UDPConn, message []byte) (int, dns.Session, error)

ReadUDP reads a single message from a UDP connection and returns the message as a slice of bytes, the length of the read message, session data or an error

type DefaultWriter

type DefaultWriter struct {
}

DefaultWriter is the default implementation of the 'Writer' interface

func NewDefaultWriter

func NewDefaultWriter() *DefaultWriter

NewDefault returns a new default writer

func (*DefaultWriter) WriteTCP

func (w *DefaultWriter) WriteTCP(conn *net.TCPConn, buf []byte) error

WriteTCP writes a byte slice back to a client with 'addr' via the provided TCP conn

func (*DefaultWriter) WriteTCPClose

func (w *DefaultWriter) WriteTCPClose(conn *net.TCPConn, buf []byte) error

WriteTCPClose writes a byte slice back to a client with 'addr' via the provided TCP conn and closes it afterwards

func (*DefaultWriter) WriteUDP

func (w *DefaultWriter) WriteUDP(conn *net.UDPConn, buf []byte, addrPort netip.AddrPort) error

WriteUDP writes a byte slice back to a client with 'addr' via the provided UDP conn

func (*DefaultWriter) WriteUDPClose

func (w *DefaultWriter) WriteUDPClose(conn *net.UDPConn, buf []byte, addrPort netip.AddrPort) error

WriteUDPClose writes a byte slice back to a client with 'addr' via the provided UDP conn and closes it afterwards

type Reader

type Reader interface {
	// ReadUDP reads a single message from a UDP connection and
	// returns the message as a slice of bytes, the length of the
	// read message, session data or an error
	ReadUDP(*net.UDPConn, []byte) (int, dns.Session, error)

	ReadTCP(net.Conn) ([]byte, error)
}

Reader defines a reader interface which enbables implementers to read incoming TCP and UDP messages from listeners and return these messages as a byte slice, session data like remote IP address and additional data or an error.

func NewDefaultReader

func NewDefaultReader(ancillarySize int) Reader

type Writer

type Writer interface {
	// WriteUDPClose writes a byte slice back to a client with
	// 'addr' via the provided UDP conn and closes it afterwards
	WriteUDPClose(*net.UDPConn, []byte, netip.AddrPort) error

	// WriteUDP writes a byte slice back to a client with
	// 'addr' via the provided UDP conn
	WriteUDP(*net.UDPConn, []byte, netip.AddrPort) error

	// WriteTCPClose writes a byte slice back to a client with
	// 'addr' via the provided TCP conn and closes it afterwards
	WriteTCPClose(*net.TCPConn, []byte) error

	// WriteTCP writes a byte slice back to a client with
	// 'addr' via the provided TCP conn
	WriteTCP(*net.TCPConn, []byte) error
}

Writer describes an interface which allows to write DNS messages (byte slices) back to a client via UDP and TCP

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL