Skip to content

Conversation

@postphotos
Copy link

Hi @vishen, first off—thank you for creating and maintaining this fantastic tool!

This pull request introduces enhanced discovery mechanisms to make go-chromecast more robust for users with mesh networks, multiple VLANs, or larger device ecosystems. The changes are fully backward-compatible and significantly improve device discovery reliability.

Issue Encountered

After setting up a mesh wifi network, I found that device discovery became unreliable. While the go-chromecast scan --cidr 192.168.4.0/24 command could find some devices, it consistently missed others, including Chromecast groups, even when they were on the same subnet. The tool was also hardcoded to scan 192.168.50.0/24 by default, which didn't match most home networks.

Solution

The default issue may affect a ton of use cases:

  • Mesh WiFi networks (Eero, Orbi, etc.)
  • Multiple VLANs or subnets
  • Corporate networks with segmented subnets
  • Networks with WiFi isolation enabled
  • Finding Chromecast Audio groups on non-standard ports
  • Any network where devices don't appear with standard mDNS discovery

To address this, I've expanded on the existing scanning capabilities to provide a more powerful and flexible discovery process:

--broad-search Flag (Universal across all relevant commands)

Added to all device-connecting commands for the simplest and most powerful discovery. This flag automatically combines mDNS with comprehensive port scanning across all detected network interfaces to find devices that standard discovery might miss.

Works with all commands:

# Device listing and discovery
$ go-chromecast ls --broad-search

# Playback control commands
$ go-chromecast status --broad-search
$ go-chromecast load media.mp4 --broad-search
$ go-chromecast pause --broad-search
$ go-chromecast volume 0.5 --broad-search

# Media commands
$ go-chromecast playlist ~/music/ --broad-search
$ go-chromecast slideshow ~/photos/ --broad-search
$ go-chromecast tts "Hello world" --broad-search

# Advanced commands
$ go-chromecast ui --broad-search
$ go-chromecast seek 30 --broad-search
$ go-chromecast seek-to 120 --broad-search
$ go-chromecast load-app CC1AD845 content-id --broad-search

Enhanced scan Command

The scan command now supports flexible subnet targeting:

# Scan specific networks (comma-separated)
$ go-chromecast scan --subnets 192.168.1.0/24,192.168.4.0/24,10.0.0.0/24

# Scan all detected local subnets automatically
$ go-chromecast scan --subnets *

# Traditional single subnet (still works)
$ go-chromecast scan --cidr 192.168.1.0/24

# Auto-detect local subnet (new default behavior)
$ go-chromecast scan

Automatic Network Detection

  • Interface Detection: Automatically identifies the best local network interface, removing the need for manual -i configuration in most cases
  • Subnet Detection: Auto-detects the local subnet instead of using the hardcoded 192.168.50.0/24 default
  • Multi-Port Scanning: Now scans Chromecast standard ports (8009, 8008, 8443) plus group ports (32000-32010, 32236)

Testing

Test Coverage: Added unit tests for new utility functions (subnet parsing, flag handling) and integration tests using testscript to validate CLI behavior. Includes mocks for network-dependent functionality to ensure reliable testing. Tests can be run with go test ./... or individual components with go test ./cmd/.

Performance Note: --broad-search is slower than standard discovery as it performs comprehensive network scanning, but finds devices that mDNS alone might miss.

Backward Compatibility

I wanted to make sure any existing workflows will continue to work and leave existing functionality unchanged. This means:

  • Existing --cidr flag works exactly as before
  • Standard device discovery (without flags) works as before but with improved auto-detection
  • All command syntax and behavior is preserved, while users with complex networks now will have powerful options for reliable device discovery.

I believe these changes make go-chromecast significantly more powerful on modern home networks. Please let me know if you have any questions or need any adjustments to merge this in!

Further fixes (adding in --broad-search)
…w feature

final cleanup of implementation; completing basic documentation of new feature
@postphotos postphotos changed the title Enhance device discovery for complex and mesh networks (feat) Enhance device discovery for complex and mesh networks Aug 8, 2025
Copy link
Owner

@vishen vishen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies this took so long for me to review. This looks good. I've left a comment about putting the new flag in with the rest of the global flags.

@postphotos
Copy link
Author

Awesome! I also cleaned up the rest of the --broad-search flags, let me know if you need anything else to get this merged.

Copy link
Owner

@vishen vishen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay, have been on paternity leave.

This looks good other than a couple of minor comments.

var app application.App
var err error

if broadSearch {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed if castApplication checks this flag as well?

exit("unable to seek current media: %v", err)
}
},
Run: func(cmd *cobra.Command, args []string) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting on these look off, was this done with gofmt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants