-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
node: serve JSON-RPC on custom path prefix #22184
Conversation
4f00e09
to
9ebb18b
Compare
@ryanschneider here's the final PR, please let me know if this solves your issues! |
@renaynay I tried it out but was not able to get geth to behave how geth behaved in older versions where it would accept on all paths. I tried Also, with the default path there's still the bug that hitting |
@ryanschneider Ah yes I see. Okay I will set a special case for if the path is defined as |
@ryanschneider that's not really the intention here. The idea was to provide a way for you guys to set the path We can't make it serve JSON-RPC on all paths by default, since this will conflict with other resources on The query string issue is something we should fix, regardless of the path. It should just ignore the query The way @renaynay implemented it here is a bit special-casey, since it makes |
@fjl as I mentioned in #21826 (comment) later we'd still really want to have the option to support prefixes, ideally the @renaynay's original PR worked for us, it's the changes made in response to #21826 (comment) during the back and forth that caused it to "regress" for our use case. My main point is that we saw value in the original pre .12 behavior of accepting JSONRPC on any path, and would like a way to configure that behavior again (it doesn't need to be the default behavior though). |
Okay so, how about I add the |
Maybe instead of parsing out the “*” it’d be easier to use gorilla and add
an additional —http.prefix Boolean argument that controls whether the route
is registered using .PathPrefix? It’s been awhile since I’ve tried setting
up any “dynamic” routes like this so might not be the best approach though.
…On Thu, Jan 21, 2021 at 6:25 AM rene ***@***.***> wrote:
Okay so, how about I add the * wildcard option so when a user specified
--http.path=/*, then rpc will be served over any path. Would this work
for you @ryanschneider <https://github.com/ryanschneider> @fjl
<https://github.com/fjl> ? I will also fix the issue with the query
strings.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22184 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANCEEHH76WMFRYWAMRJFDS3A2O5ANCNFSM4WHAO7WQ>
.
|
@ryanschneider yeah I was considering using gorilla, but we are hesitant to introduce new dependencies into geth. I think we will do this manually. I could also add an |
Sounds good to me.
…On Thu, Jan 21, 2021 at 7:26 AM rene ***@***.***> wrote:
@ryanschneider <https://github.com/ryanschneider> yeah I was considering
using gorilla, but we are hesitant to introduce new dependencies into geth.
I think we will do this manually. I could also add an --http.prefix bool
flag to indicate whether the path should be treated as path or prefix.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22184 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANCEDMTVMSEQJ5GVDTTBDS3BBTLANCNFSM4WHAO7WQ>
.
|
8276369
to
070c5e3
Compare
070c5e3
to
8309550
Compare
@ryanschneider we have decided to consolidate the two flags into one Also the issue with query strings should now be solved. Apologies for all the back and forth, I hope this solution is satisfactory. |
Ya this sounds good to me. Thanks for working on this!
…On Mon, Jan 25, 2021 at 8:45 AM rene ***@***.***> wrote:
@ryanschneider <https://github.com/ryanschneider> we have decided to
consolidate the two flags into one --http.prefix flag (or --ws.prefix
flag). This flag will set a custom prefix *only*. If a user specifies /
as the prefix, all paths will be served. If this flag is not set, the
default is to serve requests only on root.
Apologies for all the back and forth, I hope this solution is satisfactory.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22184 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANCEBZNYON32ZKM4WMHGLS3WNZXANCNFSM4WHAO7WQ>
.
|
This is supposed to make it clearer that the prefix applies to JSON-RPC.
no need to expose the prefix feature in admin APIs
This removes the silent fix-up of non-rooted paths and instead checks if the specified prefix is valid when the node is constructed.
I've made a couple changes, it should be good to go now:
|
Updated again to add this error:
|
Not sure if it's a good idea though. The '?' would match correctly, just not in the obvious way. If someone used |
@fjl I think we should prohibit this behavior and not leave a lot of nuance / ambiguity. I like throwing the fatal err like you have implemented:
|
OK then, let's merge when CI turns green |
This PR allows a user to set a custom path prefix on which to mount the http-rpc or ws-rpc handlers via the new flags
--http.prefix
and--ws.prefix
. A user will also be able to set a custom path prefix if starting up RPC or WS through the console.If a custom path is not set, the default is to mount the handler on the root path. If
/
is specified as either the http or ws prefix, all paths will be served.This PR is an implementation of the issue addressed in #21826.