show domain name when establishing a new connection

When a new connection is about to be established and the system performs
a dns resolution, we displayed it like this: 9.9.9.9 (www.opensnitch.io)

It added visibility of what was going on, but if you created a rule to
filter by destination host, you were prompted twice to allow firstly the
DNS query, and secondly the TCP connection, which was a bit annoying.

Some users (#5) also asked to display just the domain, so now we only
display the domain name.
This commit is contained in:
Gustavo Iñiguez Goia 2020-10-19 01:02:05 +02:00
parent bc70423997
commit d6cf18ef27

View file

@ -210,11 +210,9 @@ func (c *Connection) parseDirection() bool {
func (c *Connection) getDomains(nfp *netfilter.Packet, con *Connection) {
domains := dns.GetQuestions(nfp)
if len(domains) > 0 {
con.DstHost = fmt.Sprint(con.DstHost, " (")
for _, dns := range domains {
con.DstHost = fmt.Sprint(con.DstHost, dns)
con.DstHost = dns
}
con.DstHost = fmt.Sprint(con.DstHost, ")")
}
}