Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bonjour helper #2087 #2428

Merged
merged 8 commits into from
Aug 12, 2023
Merged

Bonjour helper #2087 #2428

merged 8 commits into from
Aug 12, 2023

Conversation

Julusian
Copy link
Member

@Julusian Julusian commented Apr 23, 2023

This allows modules to use bonjour(mdns) for device discovery with little/no effort.

To use, simply define a config field such as:

{
	type: 'bonjour-device',
	id: 'bonjour-test',
	label: 'Bonjour Test',
	width: 6,
},

And in your manifest.json:

	"bonjourQueries": {
		"bonjour_host": {
			"type": "blackmagic",
			"protocol": "tcp",
			"txt": {
				"class": "AtemSwitcher"
			}
		}
	}

This is a 'magic' config field, where Companion will populate and update the values for you.

image

The query is only run while the edit panel is open, and newly discovered services will be streamed to the client (the dropdown even updates while it is open).
If the selected device is not detected when the dropdown is opened, it renders that as an option which will disappear when unselected.
The 'Manual' option is forced to be there, as modules also need to provide manual address input fields for when bonjour is not working.
The value behind the options is shown in the brackets, and includes the ip address and port.

Q) Should this output the mdns hostname, or ip address? Perhaps that should be configurable by the module?
bmd-atem won't like the hostname, but it could explicitly resolve it first. and I worry about the reliability of mdns, and the potential for connections to break if it stops resolving correctly.

For hyperdeck:

bonjourQuery: {
	type: 'hyperdeck_ctrl',
	protocol: 'tcp',
},

@Julusian Julusian linked an issue Apr 23, 2023 that may be closed by this pull request
2 tasks
@krocheck
Copy link
Member

krocheck commented Apr 25, 2023

I was hoping eventually this type of field would be in manifest.json. On the Connections tab there would be a "Device Discovery" tab on the right (in addition to Add Connection) that would discover everything on the network and you can quick add those devices. But, this type of field to link to the hostname to track for IP changes would likely be necessary. I'd just maybe recommend moving the search definition to manifest.json if able to allow that future option without needing to revisit/move it later and break things.

It would be good to get the IP from the query and return that, but like I said it might want to be tracked for changes on startup? I don't ever trust local DNS unless its being managed in the DNS server, so I'd lean on IP in my implementations.

I'll have to do some packet sniffs on Shure to figure out what my options for filtering are compared to what you've found for BMD stuff, but that won't be in the short term.

@Julusian
Copy link
Member Author

Julusian commented Apr 25, 2023

I was hoping eventually this type of field would be in manifest.json.

I was thinking about doing that, but it becomes more of a challenge to link things up, because we will need to know how to map that query back into a config field.

But perhaps if it is something like:

manifest;

{
  "bonjourQueries": {
    "query1": {
      "filter": {
        "type": "blackmagic",
        "protocol": "tcp"
      }
    }
  }
}

config:

{
	type: 'bonjour-device',
	id: 'query1',
	label: 'Bonjour Test',
	width: 6,
},

With that query1 being the link between the two?

It doesnt feel elegant to have it split like this, but its not something that will ever be changed once defined

@Julusian
Copy link
Member Author

It would be good to get the IP from the query and return that, but like I said it might want to be tracked for changes on startup? I don't ever trust local DNS unless its being managed in the DNS server, so I'd lean on IP in my implementations.

Yeah I was wondering if it should use the address, hostname or let the module choose. I am happy to start with only allowing ip addresses. That is still friendlier than today, but not the best it could be.

Tracking changes could be interesting, but could also be a bit tricky for us to do on the modules behalf. Until the module is running we don't know its config fields (unless we start caching those too).
Perhaps we could mess with the dns resolver in the modules? That might be a bit far.

@Julusian Julusian added this to the v3.1 milestone May 16, 2023
@Julusian Julusian force-pushed the feat/develop-bonjour-helper branch from 2a0c5a0 to 056b03d Compare August 8, 2023 22:13
@Julusian Julusian marked this pull request as ready for review August 12, 2023 16:19
@Julusian Julusian merged commit 836bed8 into develop Aug 12, 2023
11 of 12 checks passed
@Julusian Julusian deleted the feat/develop-bonjour-helper branch August 12, 2023 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Bonjour discovery helper
2 participants