mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
all: fix LAN hostname checking condition
The LAN hostname in question is FQDN, "." suffix must be trimmed before checking. While at it, also add tests for LAN/PTR query checking functions.
This commit is contained in:
committed by
Cuong Manh Le
parent
f9a3f4c045
commit
5897c174d3
@@ -806,6 +806,7 @@ func isPrivatePtrLookup(m *dns.Msg) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isLanHostnameQuery reports whether DNS message is an A/AAAA query with LAN hostname.
|
||||
func isLanHostnameQuery(m *dns.Msg) bool {
|
||||
if m == nil || len(m.Question) == 0 {
|
||||
return false
|
||||
@@ -816,7 +817,8 @@ func isLanHostnameQuery(m *dns.Msg) bool {
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return !strings.Contains(q.Name, ".") ||
|
||||
strings.HasSuffix(q.Name, ".domain") ||
|
||||
strings.HasSuffix(q.Name, ".lan")
|
||||
name := strings.TrimSuffix(q.Name, ".")
|
||||
return !strings.Contains(name, ".") ||
|
||||
strings.HasSuffix(name, ".domain") ||
|
||||
strings.HasSuffix(name, ".lan")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user