-
Notifications
You must be signed in to change notification settings - Fork 235
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
[mdns] add PublishKey()
& UnpublishKey()
methods
#2022
Conversation
@abtink Why not carry the KEY record in the service or host struct? |
There are use-cases where we want to publish a KEY record without the host or service.
|
b1c18a1
to
4a4026a
Compare
4a4026a
to
94a4441
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
They can be eliminated by making A/AAAA and SRV records optional for a host and service registration. Th cons I see with new PublishKey() API is that:
Putting KEY record together with the service and host struct will eliminates the issues. This also follows the SRP definition that the KEY record is part of the Service Description Instruction. We have separate PublishService and PublishHost APIs because there are two different DNS resource groups for service and host (similar to SRP have different Service and Host Description Instructions). This is not the case for the KEY record. For a service, it's just a group of DNS resource records which are keyed with the same DNS name. Like the TXT, SRV. I don't know a good reason why the KER RR is not in this service RR group. |
Thanks @wgtdkp I'm not sure your suggestion would make it simpler to implement and/or easier to use. We need to support cases where we don't want to publish SRV/TXT records but want to publish KEY record (similarly for hosts with AAAA and KEY records).
If I understand it correctly, your suggestion is to update the existing Similarly, we need to figure out how to I feel that this model would be more complex to use. It is practically adding the
I don't think the new model of updating existing APIs will eliminate these and may even make it more complex:
|
I think avahi is easier because we can use
Even, I would be glad if we can change the mDNS APIs to have only:
This makes the API more similar to avahi which I think is more extensible, and it can further simplify the implementation. |
@wgtdkp, I am not convinced that your suggestion is simpler or better. We do want to be able to publish and unpublish keys for a name independently of host and service related records. This is used in adv-proxy where a service/host entry lease expires but its key lease does not. Having separate APIs for
If user publishes a service and key, and later wants to unpublish the service without affecting the key registration (this is a common use case in adv-proxy when the lease expires), they must first unpublish everything and then remember to re-publish the key. This is inefficient and complex. Your new suggested API model puts the responsibility (and burden) on user of the API to manage groups under same name and update records in a group. In my opinion, this should be managed by Out goal should be to make the APIs easier to use, rather than maybe easier to implement. We can separately discuss other ideas and possible redesign of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks @abtink !
@@ -486,6 +582,26 @@ void Publisher::HostRegistration::OnComplete(otbrError aError) | |||
} | |||
} | |||
|
|||
bool Publisher::KeyRegistration::IsOutdated(const std::string &aName, const KeyData &aKeyData) const | |||
{ | |||
return !(mName == aName && mKeyData == aKeyData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the name is accounted here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to re-read the code to remember.
This is following the same pattern as existing IsOutDated()
methods for HostRegisteration
and ServiceRegisteration
. So I did the same pattern to be consistent.
I agree none of them need to get a aName
input and compare actually. It may make sense to change them all in separate PR to be consistent.
Looks like this CL needs to be rebased. @abtink |
This commit adds new methods in `Mdns::Publisher` to publish or unpublish a key record for a given (host or service instance) name. New methods are implemented for both MDNSResponder and Avahi sub-classes. In the MDNSResponder implementation, if a key registration is for a service instance name matching a service registration, `DNSServiceAddRecord()` is used to associate the new record with the service. Otherwise, `DNSServiceRegisterRecord()` is used to register the KEY record on its own. The implementation handles cases when related service and key registrations are updated or unregistered. This commit also simplifies and updates the `test/mdns/main.cpp` tests, adding a common `Test()` function that takes a function pointer to run the test and handles all common boilerplate code, as well as adding a common callback to check the registration result. New test cases are also added to check key registration, registering keys on their own, and registering keys and services in different orders.
94a4441
to
d1a8858
Compare
This commit adds new methods in
Mdns::Publisher
to publish or unpublish a key record for a given (host or service instance) name. New methods are implemented for both MDNSResponder and Avahi sub-classes.In the MDNSResponder implementation, if a key registration is for a service instance name matching a service registration,
DNSServiceAddRecord()
is used to associate the new record with the service. Otherwise,DNSServiceRegisterRecord()
is used to register the KEY record on its own. The implementation handles cases when related service and key registrations are updated or unregistered.This commit also simplifies and updates the
test/mdns/main.cpp
tests, adding a commonTest()
function that takes a function pointer to run the test and handles all common boilerplate code, as well as adding a common callback to check the registration result. New test cases are also added to check key registration, registering keys on their own, and registering keys and services in different orders.This PR contains the commit [mdns-mdnssd] simplify service and host registrations #2008Please check and review the last commit on this PR. Thanks.