Skip to content

mdns: add txt filtering option for client connections#93

Closed
mhei wants to merge 3 commits into
cminyard:masterfrom
mhei:feature/mdns-txt-filter
Closed

mdns: add txt filtering option for client connections#93
mhei wants to merge 3 commits into
cminyard:masterfrom
mhei:feature/mdns-txt-filter

Conversation

@mhei

@mhei mhei commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Sometimes there are multiple devices using the same mDNS instance name on the network. Then the name is not stable due to conflict resolution and it is thus not really usable.

However, when unique text records are present, it is possible to filter for them. This change implements this and makes it for example possible to use:

gensiot 'mdns(type=_console._tcp,txt=serial:1234)'

I used the ':' character to split the mDNS txt key and value, to keep the existing parsing. It is also possible to specify more than one txt filter, then all must match (AND logic).

Sometimes there are multiple devices using the same mDNS instance
name on the network. Then the name is not stable due to conflict
resolution and it is thus not really usable.

However, when unique text records are present, it is possible to
filter for them. This change implements this and makes it
for example possible to use:

  gensiot 'mdns(type=_console._tcp,txt=serial:1234)'

I used the ':' character to split the mDNS txt key and value, to
keep the existing parsing. It is also possible to specify more
than one txt filter, then all must match (AND logic).

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
@mhei mhei marked this pull request as draft June 14, 2026 10:57
@mhei

mhei commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

I don't have a test ready yet, so I mark this PR as draft for now.

@cminyard

Copy link
Copy Markdown
Owner

This is good, it makes sense. I don't have a lot of practical experience with MDNS; following the specs doesn't always tell you everything. I tried to make it easy to use.

mhei added 2 commits June 16, 2026 07:47
mdns_timeout() was calling mdns_handle_err() on the GE_NOTFOUND path,
but mdns_handle_err() already releases the lock.
The timeout callback then fell through to its own mdnsn_deref_and_unlock(),
which meant the timeout path was effectively unlocking twice.
And this triggered a pthread_mutex_destroy() assertion.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
@mhei

mhei commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

I tried to make it easy to use.

I think it couldn't be easier from user perspective.

I've now added tests, but to be honest - Python skills are not really existing on my side. So thanks for carefully checking.

@mhei mhei marked this pull request as ready for review June 16, 2026 05:54
@cminyard

Copy link
Copy Markdown
Owner

Tests look good. The patches look good, good use of existing infrastructure and style.

I tested on MacOS and Windows and it works fine. Those are completely different stacks and they have some different behavior, so it's good they worked.

Thanks for doing all this work. It's a good improvement.

@cminyard cminyard closed this Jun 16, 2026
@mhei mhei deleted the feature/mdns-txt-filter branch June 16, 2026 19:18
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