Skip to content
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

A handful of fc changes to support unix sockets for HTTP RPC #12

Merged
merged 6 commits into from
Aug 21, 2018

Conversation

spoonincode
Copy link
Contributor

This PR includes the handful of changes I made to fc to support unix socket endpoints for HTTP RPC between keosd & cleos/nodeos. Most of these are pretty straightforward so I'd recommend reading each commit piecemeal.

When implementing unix socket HTTP support in websocketpp I tried to make as few changes to websocketpp as possible. Unfortuately still need to add a friend class in here it seems.
fc::mutable_url was never implemented; so remove the deceiving declaration of it. Add a way to piecemeal construct an fc::url by a long argument list in its place. I need to construct an fc::url with something that isn't quite a real URL so I need a way to set each piece manually.
Unix paths handed to the http_client contain the socket path and url path concatenated together. http_client needs to discover what portion is the socket path and what portion is the url path. This information is then cached for later usage.
Unix URLs work a little special here. They'll originally be in the format of
unix:///home/spoonincode/eosio-wallet/keosd.sock/v1/wallet/sign_digest
for example. When the fc::url is given to http_client in post_sync(), this will
have proto=unix and host=/home/spoonincode/eosio-wallet/keosd.sock/v1/wallet/sign_digest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generic username path?

Copy link
Contributor Author

@spoonincode spoonincode Aug 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow? obviously (or, at least I thought obviously) that comment is meant to be an example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of Github, it obviously is an example. In bare source code, I didn't think it was completely obvious that 'spoonincode' is someone's username.

host=/home/username/eosio-wallet/keosd.sock/v1/wallet/sign_digest is more generic. Likewise for two lines above.

At this point we still don't know what part of the above string is the unix socket path
and which part is the path to access on the server. This function discovers that
host=/home/spoonincode/eosio-wallet/keosd.sock and path=/v1/wallet/sign_digest
and create another fc::url that will be used downstream of the http_client::post_sync()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/create/creates/

@spoonincode spoonincode merged commit 5ea0de3 into master Aug 21, 2018
@spoonincode spoonincode deleted the unix_socket_fc_changes branch August 21, 2018 17:29
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.

3 participants