Update net

This commit is contained in:
XMRig 2020-12-02 11:32:11 +07:00
parent 121c515a07
commit 469b1f08de
No known key found for this signature in database
GPG key ID: 446A53638BE94409
14 changed files with 95 additions and 74 deletions

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
#include "base/net/tls/ServerTls.h"
#include <algorithm>
#include <cassert>
#include <cstring>
#include <openssl/ssl.h>
@ -39,11 +40,23 @@ xmrig::ServerTls::~ServerTls()
}
bool xmrig::ServerTls::isHTTP(const char *data, size_t size)
{
assert(size > 0);
static const char test[6] = "GET /";
return size > 0 && memcmp(data, test, std::min(size, sizeof(test) - 1)) == 0;
}
bool xmrig::ServerTls::isTLS(const char *data, size_t size)
{
assert(size > 0);
static const uint8_t test[3] = { 0x16, 0x03, 0x01 };
return size >= sizeof(test) && memcmp(data, test, sizeof(test)) == 0;
return size > 0 && memcmp(data, test, std::min(size, sizeof(test))) == 0;
}

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -41,6 +41,7 @@ public:
ServerTls(SSL_CTX *ctx);
virtual ~ServerTls();
static bool isHTTP(const char *data, size_t size);
static bool isTLS(const char *data, size_t size);
bool send(const char *data, size_t size);