mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
So with clients which only use SLAAC, ctrld could see client's new ip as soon as its state changes to REACHABLE. Moreover, the NDP listener is also changed to listen on all possible ipv6 link local interfaces. That would allow ctrld to get all NDP events happening in local network. SLAAC RFC: https://datatracker.ietf.org/doc/html/rfc4862
37 lines
923 B
Go
37 lines
923 B
Go
//go:build !linux
|
|
|
|
package clientinfo
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"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))
|
|
}
|
|
}
|
|
|
|
// subscribe watches NDP table changes and update new information to local table.
|
|
// This is a stub method, and only works on Linux at this moment.
|
|
func (nd *ndpDiscover) subscribe(ctx context.Context) {}
|