forked from steemit/fc
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Log host information from websocket requests #134
Merged
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
82935ac
Add host information to log messages
jmjatlanta 8b4ef5a
Fix bad_alloc
jmjatlanta d821e86
Add configurable header
jmjatlanta 4906d8b
Allow configurable proxy header for logging
jmjatlanta 0df5f7e
Use an api call instead of constructor
jmjatlanta 94200c1
clarify method name, cache value
jmjatlanta 99d7e63
revert adjustment to capture
jmjatlanta 550e092
Merge branch 'master' into jmj_844b
oxarbitrage 5d8e9e1
fix remove appender()
oxarbitrage e907429
fix tests
oxarbitrage 7ec8ead
chanmge comment from hostname to IP
oxarbitrage e336649
lambda capture only whats required
oxarbitrage ba394e0
Refactor code about logging remote host info
abitmore 9c506d0
Fix test cases
abitmore e50067d
Tweak code slightly
abitmore 8ffe08f
Merge 'master' branch
abitmore e778cf1
Revert to simple WS connection for clients
abitmore 8ddcc87
Add todo
abitmore c6df78b
Rename a function to avoid accidental misuse
abitmore 3e07edf
Remove unused header inclusion
abitmore c8fcefb
Update RPC logging format
abitmore c58ae55
Update test cases about RPC logging level
abitmore ffbda4e
Add test cases about on_http for websocket servers
abitmore aa54e39
Remove unused websocket_tls_client class
abitmore ea96a5a
Fix websocket_client::secure_connect()
abitmore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 didn't get why we need this. Will the key change after a while? Will the header change after the connection is established? Will the connection be reopened after closed? Will the object be reused for a new connection?
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 agree this is not necessary. The header key should be set in the websocket_server before any connections are established, and it shouldn't change after that, and even if it is changed the change need not apply to existing connections. KISS, IMO.
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.
Do we need to handle HTTP connections with
connection: keep-alive
header?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.
No. http_handler always closes the connection after sending a response, and for a connection that has been upgraded to websocket protocol there will be no more http requests either.
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.
So it means the
connection: keep-alive
header is ignored. Are we going to support it in the future?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.
If I understand this correctly, the http_handler is called for every http request. So we create and close a
websocket_connection
for each request, not for each actual connection. (This also means I was wrong above - we don't close the http connection after sending the response, but only our own websocket_connection.)So even in the presence of a keep-alive http connection, the code in its current form should retrieve the remote address separately for each request.
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.
According to page 21 of RFC 6455, to establish a websocket connection, the request must include a
connection
header with theupgrade
keyword inside, however, the RFC doesn't mention "keep-alive", so I think it's implementation-dependent.When the connection is upgraded to a websocket connection, there is only one set of HTTP request headers attached to the connection, all following request messages must have the same original IP address (neither IP address nor forward-key would change), so it's best to get the address in
set_open_handler()
and use it inset_message_handler()
, but not put all code inset_message_handler()
.When the connection is a pure HTTP connection, there may be several requests received in the connection, we may probably need to handle
connection: keep-alive
header. If a new websocket_connection object is created for each request, then the header can be ignored. Anyway, we want to extract real IP addresses of the clients and log them, so we need to updateset_http_handler()
.