mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-23 01:27:13 +02:00
internal/clientinfo: map ::1 to the right host MAC address
So queries originating from host using ::1 as source will be recognized properly, and treated the same as other queries from host itself.
This commit is contained in:
@@ -14,6 +14,11 @@ import (
|
||||
"github.com/Control-D-Inc/ctrld/internal/controld"
|
||||
)
|
||||
|
||||
const (
|
||||
ipV4Loopback = "127.0.0.1"
|
||||
ipv6Loopback = "::1"
|
||||
)
|
||||
|
||||
// IpResolver is the interface for retrieving IP from Mac.
|
||||
type IpResolver interface {
|
||||
fmt.Stringer
|
||||
@@ -322,6 +327,14 @@ func (t *Table) LookupRFC1918IPv4(mac string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// LocalHostname returns the localhost hostname associated with loopback IP.
|
||||
func (t *Table) LocalHostname(v6 bool) string {
|
||||
if v6 {
|
||||
return t.LookupHostname(ipv6Loopback, "")
|
||||
}
|
||||
return t.LookupHostname(ipV4Loopback, "")
|
||||
}
|
||||
|
||||
type macEntry struct {
|
||||
mac string
|
||||
src string
|
||||
|
||||
Reference in New Issue
Block a user