mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-09-17 01:45:27 +02:00
internal/clientinfo: add NDP discovery
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//go:build !linux
|
||||
|
||||
package clientinfo
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/Control-D-Inc/ctrld"
|
||||
)
|
||||
|
||||
// scan populates NDP table using information from system mappings.
|
||||
func (nd *ndpDiscover) scan() {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
data, err := exec.Command("netsh", "interface", "ipv6", "show", "neighbors").Output()
|
||||
if err != nil {
|
||||
ctrld.ProxyLogger.Load().Warn().Err(err).Msg("could not query ndp table")
|
||||
return
|
||||
}
|
||||
nd.scanWindows(bytes.NewReader(data))
|
||||
default:
|
||||
data, err := exec.Command("ndp", "-an").Output()
|
||||
if err != nil {
|
||||
ctrld.ProxyLogger.Load().Warn().Err(err).Msg("could not query ndp table")
|
||||
return
|
||||
}
|
||||
nd.scanUnix(bytes.NewReader(data))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user