mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
rldp-http-proxy: use tonlib
- rldp-http-proxy used TONLib to resolve domains via DNS smartcontract - updated tonlib - bugfixes
This commit is contained in:
parent
1de39f5d7c
commit
493ae2410c
34 changed files with 816 additions and 153 deletions
|
@ -133,6 +133,7 @@ class HttpConnection : public td::actor::Actor, public td::ObserverBase {
|
|||
// unsubscribe from socket updates
|
||||
// nb: interface will be changed
|
||||
td::actor::SchedulerContext::get()->get_poll().unsubscribe(buffered_fd_.get_poll_info().get_pollable_fd_ref());
|
||||
buffered_fd_.close();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -27,25 +27,31 @@ void HttpInboundConnection::send_client_error() {
|
|||
static const auto s =
|
||||
"HTTP/1.0 400 Bad Request\r\n"
|
||||
"Connection: Close\r\n"
|
||||
"Content-length: 0\r\n"
|
||||
"\r\n";
|
||||
buffered_fd_.output_buffer().append(td::Slice(s, strlen(s)));
|
||||
close_after_write_ = true;
|
||||
loop();
|
||||
}
|
||||
|
||||
void HttpInboundConnection::send_server_error() {
|
||||
static const auto s =
|
||||
"HTTP/1.1 502 Bad Gateway\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"Content-length: 0\r\n"
|
||||
"\r\n";
|
||||
buffered_fd_.output_buffer().append(td::Slice(s, strlen(s)));
|
||||
loop();
|
||||
}
|
||||
|
||||
void HttpInboundConnection::send_proxy_error() {
|
||||
static const auto s =
|
||||
"HTTP/1.1 502 Bad Gateway\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"Content-length: 0\r\n"
|
||||
"\r\n";
|
||||
buffered_fd_.output_buffer().append(td::Slice(s, strlen(s)));
|
||||
loop();
|
||||
}
|
||||
|
||||
td::Status HttpInboundConnection::receive(td::ChainBufferReader &input) {
|
||||
|
|
|
@ -33,6 +33,7 @@ class HttpInboundConnection : public HttpConnection {
|
|||
}
|
||||
|
||||
td::Status receive_eof() override {
|
||||
found_eof_ = true;
|
||||
if (reading_payload_) {
|
||||
if (reading_payload_->payload_type() != HttpPayload::PayloadType::pt_eof) {
|
||||
return td::Status::Error("unexpected EOF");
|
||||
|
@ -42,6 +43,10 @@ class HttpInboundConnection : public HttpConnection {
|
|||
return td::Status::OK();
|
||||
}
|
||||
} else {
|
||||
if (read_next_request_) {
|
||||
stop();
|
||||
return td::Status::OK();
|
||||
}
|
||||
return td::Status::OK();
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +59,10 @@ class HttpInboundConnection : public HttpConnection {
|
|||
writing_payload_ = nullptr;
|
||||
if (!close_after_write_) {
|
||||
read_next_request_ = true;
|
||||
if (found_eof_) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void payload_read() override {
|
||||
|
|
|
@ -42,6 +42,7 @@ class HttpOutboundConnection : public HttpConnection {
|
|||
}
|
||||
|
||||
td::Status receive_eof() override {
|
||||
found_eof_ = true;
|
||||
if (reading_payload_) {
|
||||
if (reading_payload_->payload_type() != HttpPayload::PayloadType::pt_eof) {
|
||||
return td::Status::Error("unexpected EOF");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue