misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
Simone Margaritelli 2024-09-22 14:00:39 +02:00
commit 8446d66d12
2 changed files with 37 additions and 40 deletions

View file

@ -16,7 +16,7 @@ func addIfMatches(to *[]string, prefix string, what string) {
}
}
func (s *Session) LANCompleter(prefix string) []string {
func (s *Session) LANCompleterForMacs(prefix string) []string {
macs := []string{""}
s.Lan.EachHost(func(mac string, e *network.Endpoint) {
addIfMatches(&macs, prefix, mac)
@ -24,6 +24,14 @@ func (s *Session) LANCompleter(prefix string) []string {
return macs
}
func (s *Session) LANCompleterForIPs(prefix string) []string {
ips := []string{""}
s.Lan.EachHost(func(mac string, e *network.Endpoint) {
addIfMatches(&ips, prefix, e.IpAddress)
})
return ips
}
func (s *Session) WiFiCompleter(prefix string) []string {
macs := []string{""}
s.WiFi.EachAccessPoint(func(mac string, ap *network.AccessPoint) {