-
Notifications
You must be signed in to change notification settings - Fork 113
Subscription map updated checking of subscription path #684
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
Conversation
Codecov Report
@@ Coverage Diff @@
## new_wc #684 +/- ##
=======================================
Coverage 82.70% 82.70%
=======================================
Files 46 46
Lines 7082 7082
=======================================
Hits 5857 5857
Misses 1225 1225 |
|
I noticed that mqtt_valid_topic and mqtt_valid_subscription have prefix mqtt_. It isn't required. It seems that those functions are not called. Of course the branch new_wc doesn't contain test_broker.hpp updates. So I've also checked #558. Who calls them? Is function name and parameter name I'm not sure the difference between mqtt_valid_topic and mqtt_valid_subscription. The master branch only has mqtt_valid_topic_filter and it is called from compare_topic_filter(). compare_topic_filter() is called from linear search algorithm. I guess that your approach is very different from compare_topic_filter(). |
|
After you update #684, if needed, then I will merge it to new_wc. Then move on the next step. The next step means updating test_broker.hpp to replace compare_topic_filter() with trie version. I'm not sure how to gather matched subscriptions using trie. For example, a client subscribe |
yes, that is possible with the trie. |
yes, compare_topic_filter is the linear search approach, it is not needed anymore if you use the trie approach |
mqtt_valid_topic should be used when a message is published to a topic. The published topic should be a valid topic (not empty, does not contain \0, and does not contain wildcards). mqtt_valid_subscription checks whether a subscription is valid. A subscription is allowed to contain wildcards. You named this validate_topic_filter with argument topic_filter, subscription = topic filter |
|
mqtt_valid_subscription = validate_topic_filter and you can replace them. mqtt_valid_topic is not used by the trie, the broker should handle this. |
Hmm... maybe I understand. Let me clarify. This is the current master's validate_topic_filter() definition. Lines 42 to 114 in 9bebfc2
And this the current master's validate_topic_name() definition. Lines 144 to 159 in 9bebfc2
They are the same as mqtt_valid_subscription and mqtt_valid_topic on #684. It that right? That means we don't need #684, simply just use the current master's one. So, I will remove the functions from new_wc branch. Is that OK? I also want to update the name of Then I will let you know. |
I prepared #685 it is a replacement of #676 . @kleunen , My plan is
And then, I will ask you to update test_broker.hpp. It this OK ? |
yes, that sounds OK. I am not sure what you did with the validate filter/topic function, you removed my functions and are using your and @jonesmz updated function ? I think there was also a comment in the validate function of @jonesmz that UTF-8 matching was required. I am not sure if anything needs to be done to get UTF-8 matching working, the topics are validated on individual byte level. Maybe some tests with UTF-8 characters need in topics and topic_filters should be added. |
Ok I go forward the process. For UTF8 checking, we can use https://github.com/redboltz/mqtt_cpp/blob/master/include/mqtt/utf8encoded_strings.hpp#L47 . See https://github.com/redboltz/mqtt_cpp/blob/master/include/mqtt/utf8encoded_strings.hpp#L50 |
I do think that is required, MQTT specification states strings are UTF-8 encoded, so validation of network input should be done, offcourse ... The performance impact is minimal i would say, not memory allocation in inner loop, just blasting away these instructions is very fast on modern CPU. No locking, no memory allocation performance, these are usually performance killers. |
|
Yes. I think that simple insert validate_contents() function. Some of user uses the broker on closed environment. It might be in the factory. So I mean ob premise case and all of clients are under control. In this case, UTF8 check is redundant. So I provide the option. |
Yes, but even if all the clients are under control, if you open a TCP/SSL port, someone else beside your clients might connect. But ok, the library focuses now on MQTT client. If you have a MQTT server, i would always recommend enabling this check, and maybe some additional input validation as well ? |
|
Length checking and invalid bit checking are already implemented and always enabled. I agree recommending define MQTT_USE_STR_CHECK. NOTE: mqtt_cpp uses positive meaning flags. e.g.) MQTT_USE_TLS. And mqtt_cpp is a header only library so user need to define them. See https://github.com/redboltz/mqtt_cpp/wiki/Config This is off topic comment. I use mqtt_cpp for my proprietary broker. It has authorization and authentication. Client is required subscribe/publish permission for each topic. Anyway, it is my broker story. |
No description provided.