Skip to content

Commit b5ae6b5

Browse files
committed
HttpQuery: store peer address into query
GitOrigin-RevId: 00b1b116e508ab49d9cabc192f7999069fb3add1
1 parent fee05df commit b5ae6b5

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

‎.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ FixNamespaceComments: true
6565
ForEachMacros:
6666
- Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY
6767
IncludeBlocks: Preserve
68-
IndentCaseBlocks: false
68+
#IndentCaseBlocks: false
6969
IndentCaseLabels: true
7070
IndentGotoLabels: true
7171
IndentPPDirectives: None

‎tdnet/td/net/HttpConnectionBase.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ HttpConnectionBase::HttpConnectionBase(State state, SocketFd fd, SslStream ssl_s
3333
read_source_ >> read_sink_;
3434
write_source_ >> write_sink_;
3535
}
36+
peer_address_.init_peer_address(fd_).ignore();
3637
}
3738

3839
void HttpConnectionBase::live_event() {
@@ -123,6 +124,7 @@ void HttpConnectionBase::loop() {
123124
state_ = State::Write;
124125
LOG(DEBUG) << "Send query to handler";
125126
live_event();
127+
current_query_->peer_address_ = peer_address_;
126128
on_query(std::move(current_query_));
127129
} else {
128130
want_read = true;

‎tdnet/td/net/HttpConnectionBase.h

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class HttpConnectionBase : public Actor {
3838
State state_;
3939

4040
BufferedFd<SocketFd> fd_;
41+
IPAddress peer_address_;
4142
SslStream ssl_stream_;
4243

4344
ByteFlowSource read_source_{&fd_.input_buffer()};

‎tdnet/td/net/HttpQuery.h

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "td/utils/Slice.h"
1414
#include "td/utils/StringBuilder.h"
1515

16+
#include "td/utils/port/IPAddress.h"
17+
1618
#include <utility>
1719

1820
namespace td {
@@ -33,6 +35,8 @@ class HttpQuery {
3335
vector<HttpFile> files_;
3436
MutableSlice content_;
3537

38+
IPAddress peer_address_;
39+
3640
Slice get_header(Slice key) const;
3741

3842
MutableSlice get_arg(Slice key) const;

0 commit comments

Comments
 (0)