27117900eb
Complete architecture rewrite following go2rtc patterns: - pkg/ for pure logic (camdb, tester, probe, generate) - internal/ for application glue with Init() modules - Single HTTP server on :4567 with all endpoints - zerolog with password masking and memory ring buffer - Environment-based config only (no YAML files) API endpoints: /api/search, /api/streams, /api/test, /api/probe, /api/generate, /api/health, /api/log Dependencies: go2rtc v1.9.14, go-sqlite3, miekg/dns, zerolog
36 lines
573 B
Go
36 lines
573 B
Go
package probe
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// LookupARP reads /proc/net/arp to find MAC address for ip. Linux only.
|
|
func LookupARP(ip string) string {
|
|
file, err := os.Open("/proc/net/arp")
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
defer file.Close()
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
scanner.Scan() // skip header
|
|
|
|
for scanner.Scan() {
|
|
fields := strings.Fields(scanner.Text())
|
|
if len(fields) < 4 {
|
|
continue
|
|
}
|
|
if fields[0] == ip {
|
|
mac := fields[3]
|
|
if mac == "00:00:00:00:00:00" {
|
|
return ""
|
|
}
|
|
return strings.ToUpper(mac)
|
|
}
|
|
}
|
|
|
|
return ""
|
|
}
|