File: parse.go

package info (click to toggle)
opensnitch 1.5.9-4
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 10,536 kB
  • sloc: ansic: 136,511; python: 6,597; sh: 204; makefile: 167; xml: 50
file content (21 lines) | stat: -rw-r--r-- 511 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package dns

import (
	"github.com/evilsocket/opensnitch/daemon/netfilter"
	"github.com/google/gopacket/layers"
)

// GetQuestions retrieves the domain names a process is trying to resolve.
func GetQuestions(nfp *netfilter.Packet) (questions []string) {
	dnsLayer := nfp.Packet.Layer(layers.LayerTypeDNS)
	if dnsLayer == nil {
		return questions
	}

	dns, _ := dnsLayer.(*layers.DNS)
	for _, dnsQuestion := range dns.Questions {
		questions = append(questions, string(dnsQuestion.Name))
	}

	return questions
}