Merge branch 'windows' of https://github.com/sogou/workflow into windows

This commit is contained in:
XieHan
2023-01-04 02:47:53 +08:00
4 changed files with 18 additions and 28 deletions
+11 -1
View File
@@ -45,6 +45,7 @@ public:
protected:
virtual CommMessageOut *message_out();
virtual int keep_alive_timeout();
virtual bool init_success();
virtual bool finish_once();
@@ -70,7 +71,8 @@ CommMessageOut *ComplexDnsTask::message_out()
DnsResponse *resp = this->get_resp();
TransportType type = this->get_transport_type();
/* Set these field every time, in case of reconstruct on redirect */
if (req->get_id() == 0)
req->set_id(this->get_task_seq() + 1);
resp->set_request_id(req->get_id());
resp->set_request_name(req->get_question_name());
req->set_single_packet(type == TT_UDP);
@@ -79,6 +81,14 @@ CommMessageOut *ComplexDnsTask::message_out()
return this->WFClientTask::message_out();
}
int ComplexDnsTask::keep_alive_timeout()
{
if (this->get_task_seq() == (1 << 16) - 2)
return 0;
return this->WFClientTask::keep_alive_timeout();
}
bool ComplexDnsTask::init_success()
{
if (uri_.scheme && strcasecmp(uri_.scheme, "dnss") == 0)
-2
View File
@@ -184,8 +184,6 @@ void DnsMessage::set_question_name(const std::string& name)
parser->question.qname = strdup(name.c_str());
}
std::atomic<uint16_t> DnsRequest::req_id_(1);
int DnsResponse::append(const void *buf, size_t *size)
{
int ret = this->DnsMessage::append(buf, size);
+1 -13
View File
@@ -26,7 +26,6 @@
#include <string.h>
#include <string>
#include <atomic>
#include "ProtocolMessage.h"
#include "dns_parser.h"
@@ -193,15 +192,7 @@ private:
class DnsRequest : public DnsMessage
{
public:
DnsRequest()
{
uint64_t req_id;
do
req_id = DnsRequest::req_id_++;
while (req_id == 0);
dns_parser_set_id(req_id, this->parser);
}
DnsRequest() = default;
DnsRequest(DnsRequest&& req) = default;
DnsRequest& operator = (DnsRequest&& req) = default;
@@ -209,9 +200,6 @@ public:
{
dns_parser_set_question(host, qtype, qclass, this->parser);
}
private:
static std::atomic<uint16_t> req_id_;
};
class DnsResponse : public DnsMessage
+6 -12
View File
@@ -248,20 +248,14 @@ int MySQLHandshakeResponse::decode_packet(const unsigned char *buf, size_t bufle
return 1;
}
static inline void __sha1(const std::string& str, unsigned char *md)
static inline std::string __sha1_str(const std::string& str)
{
unsigned char sha1[20];
SHA_CTX ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx, str.c_str(), str.size());
SHA1_Final(md, &ctx);
}
static inline std::string __sha1_bin(const std::string& str)
{
unsigned char md[20];
__sha1(str, md);
return std::string((const char *)md, 20);
SHA1_Final(sha1, &ctx);
return std::string((const char *)sha1, 20);
}
#define MYSQL_CAPFLAG_CLIENT_SSL 0x00000800
@@ -334,8 +328,8 @@ int MySQLAuthRequest::encode(struct iovec vectors[], int max)
else
{
native.push_back((char)20);
std::string first = __sha1_bin(password_);
std::string second = __sha1_bin(challenge_ + __sha1_bin(first));
std::string first = __sha1_str(password_);
std::string second = __sha1_str(challenge_ + __sha1_str(first));
for (int i = 0; i < 20; i++)
native.push_back(first[i] ^ second[i]);