mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
Drop Windows Socket dependency for randomenv.cpp
This change drops a dependency on the ws2_32 library for our libbitcoinkernel, which may not be desirable.
This commit is contained in:
parent
23ba39470c
commit
03b87a3e64
@ -13,6 +13,7 @@
|
|||||||
#include <compat/compat.h>
|
#include <compat/compat.h>
|
||||||
#include <compat/cpuid.h>
|
#include <compat/cpuid.h>
|
||||||
#include <crypto/sha512.h>
|
#include <crypto/sha512.h>
|
||||||
|
#include <span.h>
|
||||||
#include <support/cleanse.h>
|
#include <support/cleanse.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
||||||
@ -357,10 +358,19 @@ void RandAddStaticEnv(CSHA512& hasher)
|
|||||||
hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ;
|
hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ;
|
||||||
|
|
||||||
// Hostname
|
// Hostname
|
||||||
|
#ifdef WIN32
|
||||||
|
constexpr DWORD max_size = MAX_COMPUTERNAME_LENGTH + 1;
|
||||||
|
char hname[max_size];
|
||||||
|
DWORD size = max_size;
|
||||||
|
if (GetComputerNameA(hname, &size) != 0) {
|
||||||
|
hasher.Write(UCharCast(hname), size);
|
||||||
|
}
|
||||||
|
#else
|
||||||
char hname[256];
|
char hname[256];
|
||||||
if (gethostname(hname, 256) == 0) {
|
if (gethostname(hname, 256) == 0) {
|
||||||
hasher.Write((const unsigned char*)hname, strnlen(hname, 256));
|
hasher.Write((const unsigned char*)hname, strnlen(hname, 256));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
|
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
|
||||||
// Network interfaces
|
// Network interfaces
|
||||||
|
Loading…
Reference in New Issue
Block a user