Skip to content

Commit

Permalink
Merge pull request #1128 from Chilledheart/core_move_rand_util
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilledheart authored Oct 21, 2024
2 parents cbe7e97 + e31743f commit 7cda92a
Show file tree
Hide file tree
Showing 20 changed files with 715 additions and 340 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4093,21 +4093,16 @@ add_library(yass_core STATIC
src/core/safe_strerror.hpp
src/core/debug.cpp
src/core/debug.hpp
src/core/rand_util.cpp
src/core/rand_util.hpp
src/core/scoped_clear_last_error_win.cpp
)

if (WIN32)
target_sources(yass_core PRIVATE src/core/rand_util_win.cpp)
target_sources(yass_core PRIVATE src/core/utils_win.cpp)
elseif (APPLE)
target_sources(yass_core PRIVATE src/config/config_impl_apple.hpp)
target_sources(yass_core PRIVATE src/config/config_impl_apple.mm)
target_sources(yass_core PRIVATE src/core/rand_util_posix.cpp)
target_sources(yass_core PRIVATE src/core/utils_mac.mm)
else()
target_sources(yass_core PRIVATE src/core/rand_util_posix.cpp)
target_sources(yass_core PRIVATE src/core/utils_linux.cpp)
target_sources(yass_core PRIVATE src/core/utils_freebsd.cpp)
endif()
Expand Down
6 changes: 3 additions & 3 deletions src/cli/cli_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include <absl/flags/flag.h>
#include <absl/strings/str_cat.h>
#include <base/rand_util.h>
#include <base/strings/string_util.h>

#include "config/config.hpp"
#include "core/rand_util.hpp"
#include "core/utils.hpp"
#include "net/asio.hpp"
#include "net/base64.hpp"
Expand Down Expand Up @@ -2246,9 +2246,9 @@ void CliConnection::connected() {
// originated from naive_proxy_delegate.go;func ServeHTTP
if (padding_support_) {
// Sends client-side padding header regardless of server support
std::string padding(RandInt(16, 32), '~');
std::string padding(gurl_base::RandInt(16, 32), '~');
InitializeNonindexCodes();
FillNonindexHeaderValue(RandUint64(), &padding[0], padding.size());
FillNonindexHeaderValue(gurl_base::RandUint64(), &padding[0], padding.size());
headers.emplace_back("padding"s, padding);
}
int submit_result = adapter_->SubmitRequest(GenerateHeaders(headers), std::move(data_frame), false, nullptr);
Expand Down
4 changes: 2 additions & 2 deletions src/config/config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

#include <absl/flags/flag.h>
#include <absl/strings/str_cat.h>
#include <base/rand_util.h>
#include <gmock/gmock.h>
#include <cstdlib>
#include "config/config_impl.hpp"
#include "core/process_utils.hpp"
#include "core/rand_util.hpp"
#include "core/utils_fs.hpp"

using namespace yass;
Expand All @@ -25,7 +25,7 @@ ABSL_FLAG(std::string, test_string, "", "Test string value");
class ConfigTest : public ::testing::Test {
public:
void SetUp() override {
key_prefix_ = absl::StrCat("pid_", GetPID(), "_run_", RandUint64());
key_prefix_ = absl::StrCat("pid_", GetPID(), "_run_", gurl_base::RandUint64());
#if !(defined(_WIN32) || defined(__APPLE__))
original_configfile_ = config::g_configfile;
const char* tmpdir = getenv("TMPDIR");
Expand Down
75 changes: 0 additions & 75 deletions src/core/rand_util.cpp

This file was deleted.

60 changes: 0 additions & 60 deletions src/core/rand_util.hpp

This file was deleted.

111 changes: 0 additions & 111 deletions src/core/rand_util_posix.cpp

This file was deleted.

65 changes: 0 additions & 65 deletions src/core/rand_util_win.cpp

This file was deleted.

Loading

0 comments on commit 7cda92a

Please sign in to comment.