Handle TCP, padding, etc.

This commit is contained in:
Frank Denis 2018-01-09 16:40:37 +01:00
parent 6a39b0afdb
commit 553f6afb00
4 changed files with 137 additions and 29 deletions

View file

@ -18,7 +18,8 @@ var (
ServerMagic = [8]byte{0x72, 0x36, 0x66, 0x6e, 0x76, 0x57, 0x6a, 0x38}
MinDNSPacketSize = 12
MaxDNSPacketSize = 4096
InitialMinQuestionSize = 128
MaxDNSUDPPacketSize = 1252
InitialMinQuestionSize = 256
TimeoutMin = 1 * time.Second
TimeoutMax = 5 * time.Second
)
@ -36,3 +37,17 @@ type ServerInfo struct {
func HasTCFlag(packet []byte) bool {
return packet[2]&2 == 2
}
func Min(a, b int) int {
if a < b {
return a
}
return b
}
func Max(a, b int) int {
if a > b {
return a
}
return b
}