-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add custom agent strings #63
Conversation
This makes malloy::controller an abstract type... If someone needed that I would be concerned
Now called by the derived classes and `protected`
That failure on VS is the out of heap space again. Only seems to happen on PRs for some reason |
I only took a quick glance over it so far.
|
Ah, I didn't realise that was also needed. I'll add that.
I could, but I dislike storing
Adding it to the top-level config is an issue because the defaults are different for client and server. Not sure how else that could be done. |
If I remember correctly requests sent from client to server use the
I don't mind too much at the moment. There's plenty of other stuff that can be optimized. In this case I'd personally be a bit more "cautious" than with things like the
I might be misunderstanding but why not just initializing it in the config structure's constructor? Creating the controller (and corresponding config) is something that happens rarely (most likely in most applications even just once) so performance penalties shouldn't be the thing to worry about. |
Currently it does just that effectively, but since its not part of the top level config the user cannot set it there where having the same value for server and client may not make sense. It does mean there is effectively code duplication there, but only superficially since they are really independent and seperate options, they are just named the same right now. I can't see a way to put it in the ctors of the derived without also potentially overwriting a users config or other issues. Since fields cannot be overriden.
True, but then as you say there are much bigger fish to fry. We currently copy 3 shared pointers every time a new connection is created, I'm pretty sure thats a lot more expensive than copying a SSO string :p (although I haven't measured so I'm sorta talking out of my arse here). |
Hmm, I've just done the server side and I'm working on the client but I was thinking, should we set this? The user has full control over it from their end and I've heard it can be a security issue outside of debug environments. For the websockets its different because we set the decorator internally, before the user has access to the connection, but the user can easily pass their requests and responses through some prep code before sending them off |
The difference with the string is mainly memory related: Shared pointers are lightweight. Agents strings might easily be a few dozen characters and each active connection will have a copy.
As far as I know the security issues do not arise from the header value itself but the fact that information is being disclosed which makes looking for (and using) existing vulnerabilities easier. |
Agreed, I'll add a check for if its currently set already since currently we overwrite any existing Server field with BOOST_BEAST_VERSION_STRING (and the user provided one in my working tree). |
The use of |
…feat-custom-agent-strings
I've added the agent strings to |
lib/malloy/client/controller.hpp
Outdated
@@ -16,6 +18,7 @@ | |||
#endif | |||
|
|||
#include <boost/asio/strand.hpp> | |||
#include <boost/beast/version.hpp> |
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.
This include should not be necessary as we don't use the beast version number anymore?
lib/malloy/client/controller.hpp
Outdated
@@ -66,11 +69,19 @@ namespace malloy::client | |||
public: | |||
struct config : | |||
malloy::controller::config { | |||
|
|||
/** | |||
* @brief Agent string used for websocket connections |
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.
This field value is also used for HTTP connections - not only WS connections, right?
lib/malloy/core/http/utils.hpp
Outdated
@@ -22,6 +22,12 @@ namespace malloy::http | |||
{ | |||
head.target(head.target().substr(resource.size())); | |||
} | |||
|
|||
template<bool isReq, typename Fields> | |||
auto has_field(const boost::beast::http::header<isReq, Fields>& head, malloy::http::field check) -> bool |
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.
The check
field can be const
(I think).
lib/malloy/server/controller.hpp
Outdated
@@ -50,6 +52,11 @@ namespace malloy::server | |||
* to the working directory. | |||
*/ | |||
std::filesystem::path doc_root = "."; | |||
|
|||
/** | |||
* @brief Agent string used for websocket connections |
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.
This field value is also used for HTTP connections - not only WS connections, right?
Also CI build errors :p |
This implements #37. There are a few issues that cropped up during implementation.
Main Changes
malloy::controller
has had itsm_cfg
removed. This was due to collisions with derived versions and it was just a whole mess. I hacked around it rather while doing HTTP client: Automatically follow redirects #35, but I gave up when I realised thatinit
is hiding the inherited version to take the rightconfig
. I can reverse it but I'd rather not :pmalloy::controller
has had parts of its interface madeprotected
since it no longer hasm_cfg
. If anything relied on the controllerstart
orinit
it will be broken by this patchserver::controller::config
andclient::controller::config
both have newws_agent_string
fields, which default to<beast version> malloy-<server|client>
agent_string
is threaded through the server and client side and set as the decorator on the websocket connectionclient::controller::init
now takes aclient::controller::config
, which will break code currently passingmalloy::controller::config
to itThe tests don't fail, but an error is logged in
on_read
inserver::http::connection
. I'm not really sure if it indicates a problem or not, as far as I can tell from testing the examples everything seems to be OK but I may have missed something.Closes: #37