Created
May 22, 2014 23:22
-
-
Save gongo/ebcda016333fe1749ff0 to your computer and use it in GitHub Desktop.
Output Airplay servers in LAN http://gongo.hatenablog.com/entry/2014/05/23/090403
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/armon/mdns" | |
"github.com/olekukonko/tablewriter" | |
"os" | |
"strconv" | |
) | |
func main() { | |
table := tablewriter.NewWriter(os.Stdout) | |
table.SetHeader([]string{"Name", "IP address", "Port"}) | |
entriesCh := make(chan *mdns.ServiceEntry, 4) | |
defer close(entriesCh) | |
go func() { | |
for entry := range entriesCh { | |
table.Append([]string{ | |
entry.Name, | |
entry.Addr.String(), | |
strconv.Itoa(entry.Port), | |
}) | |
} | |
}() | |
mdns.Lookup("_airplay._tcp", entriesCh) | |
table.Render() | |
} | |
// $ go run main.go | |
// +----------------+-------------+------+ | |
// | NAME | IP ADDRESS | PORT | | |
// +----------------+-------------+------+ | |
// | AppleTV.local. | 192.168.0.2 | 7000 | | |
// +----------------+-------------+------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment