34 lines
551 B
Go
34 lines
551 B
Go
package dns
|
|
|
|
import (
|
|
"git.loafle.net/overflow/overflow_probe/matcher/packet"
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
func TestDns(t *testing.T) {
|
|
m := NewDnsMatcher()
|
|
|
|
conn, _ := net.Dial("udp", "168.126.63.1:53")
|
|
|
|
defer conn.Close()
|
|
|
|
for i := 0; i < m.PacketCount(); i++ {
|
|
if m.IsSend(53) != true {
|
|
t.Error("not port")
|
|
}
|
|
pack := m.Packet(i)
|
|
conn.Write(pack.Buffer)
|
|
bytes := make([]byte, 1024)
|
|
n, _ := conn.Read(bytes)
|
|
p := packet.NewPacket(bytes, n)
|
|
|
|
if m.Match(i, p, nil) {
|
|
t.Log("dns found")
|
|
return
|
|
}
|
|
|
|
t.Error("dns not found")
|
|
}
|
|
}
|