HttpQuery: store peer address into query

GitOrigin-RevId: 00b1b116e508ab49d9cabc192f7999069fb3add1
This commit is contained in:
Arseny Smirnov 2020-07-13 15:23:03 +03:00
parent fee05df2cc
commit b5ae6b5b95
4 changed files with 8 additions and 1 deletions

View File

@ -65,7 +65,7 @@ FixNamespaceComments: true
ForEachMacros: ForEachMacros:
- Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY - Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY
IncludeBlocks: Preserve IncludeBlocks: Preserve
IndentCaseBlocks: false #IndentCaseBlocks: false
IndentCaseLabels: true IndentCaseLabels: true
IndentGotoLabels: true IndentGotoLabels: true
IndentPPDirectives: None IndentPPDirectives: None

View File

@ -33,6 +33,7 @@ HttpConnectionBase::HttpConnectionBase(State state, SocketFd fd, SslStream ssl_s
read_source_ >> read_sink_; read_source_ >> read_sink_;
write_source_ >> write_sink_; write_source_ >> write_sink_;
} }
peer_address_.init_peer_address(fd_).ignore();
} }
void HttpConnectionBase::live_event() { void HttpConnectionBase::live_event() {
@ -123,6 +124,7 @@ void HttpConnectionBase::loop() {
state_ = State::Write; state_ = State::Write;
LOG(DEBUG) << "Send query to handler"; LOG(DEBUG) << "Send query to handler";
live_event(); live_event();
current_query_->peer_address_ = peer_address_;
on_query(std::move(current_query_)); on_query(std::move(current_query_));
} else { } else {
want_read = true; want_read = true;

View File

@ -38,6 +38,7 @@ class HttpConnectionBase : public Actor {
State state_; State state_;
BufferedFd<SocketFd> fd_; BufferedFd<SocketFd> fd_;
IPAddress peer_address_;
SslStream ssl_stream_; SslStream ssl_stream_;
ByteFlowSource read_source_{&fd_.input_buffer()}; ByteFlowSource read_source_{&fd_.input_buffer()};

View File

@ -13,6 +13,8 @@
#include "td/utils/Slice.h" #include "td/utils/Slice.h"
#include "td/utils/StringBuilder.h" #include "td/utils/StringBuilder.h"
#include "td/utils/port/IPAddress.h"
#include <utility> #include <utility>
namespace td { namespace td {
@ -33,6 +35,8 @@ class HttpQuery {
vector<HttpFile> files_; vector<HttpFile> files_;
MutableSlice content_; MutableSlice content_;
IPAddress peer_address_;
Slice get_header(Slice key) const; Slice get_header(Slice key) const;
MutableSlice get_arg(Slice key) const; MutableSlice get_arg(Slice key) const;