Documentation ¶
Index ¶
- Constants
- Variables
- func Dotify(buf []byte) (res []byte)
- func GetLongestDataString(domain string) int
- func NewSocketAcePrivate() dns.PrivateRdata
- func PrepareHostname(data []byte, domain string) ([]byte, error)
- func TypePriority(rr dns.RR) uint32
- func Undotify(buf string) string
- func UnwrapDnsResponse(q *dns.Msg, domain string) []byte
- func WrapDnsResponse(msg *dns.Msg, data []byte, queryType dnsmessage.Type, domain string) error
- func WrapDnsResponseA(msg *dns.Msg, data []byte, domain string) error
- func WrapDnsResponseAAAA(msg *dns.Msg, data []byte, domain string) error
- func WrapDnsResponseCname(msg *dns.Msg, data []byte, domain string) error
- func WrapDnsResponseMx(msg *dns.Msg, data []byte, domain string) error
- func WrapDnsResponseNull(msg *dns.Msg, data []byte, domain string) error
- func WrapDnsResponsePrivate(msg *dns.Msg, data []byte, domain string) error
- func WrapDnsResponseSrv(msg *dns.Msg, data []byte, domain string) error
- func WrapDnsResponseTxt(msg *dns.Msg, data []byte, domain string) error
- type DownstreamConfig
- type InQueue
- type OutQueue
- type Packet
- type QueryTypes
- type SocketAcePrivate
- func (rd *SocketAcePrivate) Copy(dest dns.PrivateRdata) error
- func (rd *SocketAcePrivate) Len() int
- func (rd *SocketAcePrivate) Pack(buf []byte) (int, error)
- func (rd *SocketAcePrivate) Parse(txt []string) error
- func (rd *SocketAcePrivate) String() string
- func (rd *SocketAcePrivate) Unpack(buf []byte) (int, error)
- type UpstreamConfig
Constants ¶
const ( HostnameMaxLen = 253 // including the final period, and the non-printed zero octet for root makes 255 LabelMaxlen = 60 // See https://stackoverflow.com/questions/32290167/what-is-the-maximum-length-of-a-dns-name )
const MaxCachedChunks = 128
Keep at most 128 acked chunks from the other party
const TypeSocketAce uint16 = 0xFFA0
Variables ¶
var ( ErrTooLong = errors.New("token too long") ErrCaseSwap = errors.New("case swap, no need for any further test") )
var ( QueryTypeNull = dnsmessage.Type(10) QueryTypePrivate = dnsmessage.Type(65000) QueryTypeTxt = dnsmessage.TypeTXT QueryTypeSrv = dnsmessage.TypeSRV QueryTypeMx = dnsmessage.TypeMX QueryTypeCname = dnsmessage.TypeCNAME QueryTypeAAAA = dnsmessage.TypeAAAA QueryTypeA = dnsmessage.TypeA )
Define different query types which can be used
var ( ErrInvalidSequenceNumber = errors.New("invalid chunk sequence") ErrStreamBroken = errors.New("stream broken") ErrDeadlineExceeded = errors.New("deadline exceeded") )
var DotRegex = regexp.MustCompile("\\.")
var ( // DownloadCodecCheck is the hard coded string available on both client and server which // is used to check if the downstream codec works properly or not. DownloadCodecCheck = []byte( "\000\000\000\000\377\377\377\377\125\125\125\125\252\252\252\252" + "\201\143\310\322\307\174\262\027\137\117\316\311\111\055\122\041" + "\141\251\161\040\045\263\006\163\346\330\104\060\171\120\127\277") )
var QueryTypesByPriority = QueryTypes{ QueryTypeNull, QueryTypePrivate, QueryTypeTxt, QueryTypeSrv, QueryTypeMx, QueryTypeCname, QueryTypeAAAA, QueryTypeA, }
Sorted by priority
Functions ¶
func GetLongestDataString ¶
GetLongestDataString returns the longest data string available, when all dots and domain are included in the calculation
func NewSocketAcePrivate ¶
func NewSocketAcePrivate() dns.PrivateRdata
func PrepareHostname ¶
PrepareHostname will finalize hostname -- add dots in the name, if needed. It will verify that the total lenght of the hostname does not exiceed HostnameMaxLen and throw an error it it does.
func TypePriority ¶
TypePriority calculates the supplied type's priority used for sorting
func UnwrapDnsResponse ¶
UnwrapDnsResponse will decode the DNS message and return the bytes in the response
func WrapDnsResponse ¶
WrapDnsResponse will wrap the given data into the specificed message type. It will call one of the other methods to actually do the wrapping
func WrapDnsResponseA ¶
WrapDnsResponseA will wrap the data into a A-type DNS response message
func WrapDnsResponseAAAA ¶
WrapDnsResponseAAAA will wrap the data into a AAAA-type DNS response message
func WrapDnsResponseCname ¶
WrapDnsResponseCname will wrap the data into a CNAME-type DNS response message
func WrapDnsResponseMx ¶
WrapDnsResponseMx will wrap the data into a MX-type DNS response message
func WrapDnsResponseNull ¶
WrapDnsResponseNull will wrap the data into a NULL-type DNS response message
func WrapDnsResponsePrivate ¶
WrapDnsResponsePrivate will wrap the data into a PRIVATE-type DNS response message
func WrapDnsResponseSrv ¶
WrapDnsResponseSrv will wrap the data into a SRV-type DNS response message
Types ¶
type DownstreamConfig ¶
type DownstreamConfig struct { FragmentSize uint32 // -m max size of downstream fragments (default: autodetect) Encoder enc.Encoder // -O force downstream encoding for -T other than NULL: Base32Encoding, Base64Encoding, Base64uEncoding, Base128Encoding, or (only for TXT:) RawEncoding (default: autodetect) }
type InQueue ¶
type InQueue struct { NextSeqNo uint16 // The id of the next Packet to be written to the queue // contains filtered or unexported fields }
func (*InQueue) Append ¶
Try to append the Packet to our byte list. Returns an error if out of order
type OutQueue ¶
type OutQueue struct { NextSeqNo uint16 // Next chunk to be put into queue will get this ID OnChunkAdded func() error // Callback function when a new chunk is added // contains filtered or unexported fields }
func (*OutQueue) NextChunk ¶
NextChunk will return the first non-acked chunk from the queue. It will return nil if the queue is empty
func (*OutQueue) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.
func (*OutQueue) UpdateAcked ¶
UpdateAcked will add the acked sequence number to the list and remove the chunk from the outboud queue.
type Packet ¶
type Packet struct { SeqNo uint16 // The sequence number of the chunk. Data []byte // The chunk data }
Packet represents a part of data exchanged between the client and the server
type QueryTypes ¶
type QueryTypes []dnsmessage.Type
func (QueryTypes) Before ¶
func (qt QueryTypes) Before(q1, q2 dnsmessage.Type) bool
Before returns true if q1 has higher priority than q2
type SocketAcePrivate ¶
type SocketAcePrivate struct {
Data []byte
}
A crazy new RR type :)
func (*SocketAcePrivate) Copy ¶
func (rd *SocketAcePrivate) Copy(dest dns.PrivateRdata) error
func (*SocketAcePrivate) Len ¶
func (rd *SocketAcePrivate) Len() int
func (*SocketAcePrivate) Parse ¶
func (rd *SocketAcePrivate) Parse(txt []string) error
func (*SocketAcePrivate) String ¶
func (rd *SocketAcePrivate) String() string
type UpstreamConfig ¶
type UpstreamConfig struct { FragmentSize uint32 // -M max size of upstream hostnames (~100-255, default: 255) Encoder enc.Encoder // -O force downstream encoding for -T other than NULL: Base32, Base64, Base64u, Base128, or (only for TXT:) Raw (default: autodetect) QueryType *dnsmessage.Type // -T force dns type: QueryTypeNull, QueryTypePrivate, QueryTypeTxt, QueryTypeSrv, QueryTypeMx, QueryTypeCname, QueryTypeAAAA, QueryTypeA (default: autodetect) }