Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #5978 from sepalani/net-log
NetworkCaptureLogger: Move SSL logging
- Loading branch information
Showing
9 changed files
with
138 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright 2021 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "Core/NetworkCaptureLogger.h" | ||
|
|
||
| #include "Common/FileUtil.h" | ||
| #include "Common/IOFile.h" | ||
| #include "Core/Config/MainSettings.h" | ||
| #include "Core/ConfigManager.h" | ||
|
|
||
| namespace Core | ||
| { | ||
| NetworkCaptureLogger::NetworkCaptureLogger() = default; | ||
| NetworkCaptureLogger::~NetworkCaptureLogger() = default; | ||
|
|
||
| void DummyNetworkCaptureLogger::LogRead(const void* data, std::size_t length) | ||
| { | ||
| } | ||
|
|
||
| void DummyNetworkCaptureLogger::LogWrite(const void* data, std::size_t length) | ||
| { | ||
| } | ||
|
|
||
| NetworkCaptureType DummyNetworkCaptureLogger::GetCaptureType() const | ||
| { | ||
| return NetworkCaptureType::None; | ||
| } | ||
|
|
||
| void BinarySSLCaptureLogger::LogRead(const void* data, std::size_t length) | ||
| { | ||
| if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ)) | ||
| return; | ||
| const std::string filename = | ||
| File::GetUserPath(D_DUMPSSL_IDX) + SConfig::GetInstance().GetGameID() + "_read.bin"; | ||
| File::IOFile(filename, "ab").WriteBytes(data, length); | ||
| } | ||
|
|
||
| void BinarySSLCaptureLogger::LogWrite(const void* data, std::size_t length) | ||
| { | ||
| if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE)) | ||
| return; | ||
| const std::string filename = | ||
| File::GetUserPath(D_DUMPSSL_IDX) + SConfig::GetInstance().GetGameID() + "_write.bin"; | ||
| File::IOFile(filename, "ab").WriteBytes(data, length); | ||
| } | ||
|
|
||
| NetworkCaptureType BinarySSLCaptureLogger::GetCaptureType() const | ||
| { | ||
| return NetworkCaptureType::Raw; | ||
| } | ||
| } // namespace Core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Copyright 2021 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstddef> | ||
|
|
||
| namespace Core | ||
| { | ||
| enum class NetworkCaptureType | ||
| { | ||
| None, | ||
| Raw, | ||
| PCAP, | ||
| }; | ||
|
|
||
| class NetworkCaptureLogger | ||
| { | ||
| public: | ||
| NetworkCaptureLogger(); | ||
| NetworkCaptureLogger(const NetworkCaptureLogger&) = delete; | ||
| NetworkCaptureLogger(NetworkCaptureLogger&&) = delete; | ||
| NetworkCaptureLogger& operator=(const NetworkCaptureLogger&) = delete; | ||
| NetworkCaptureLogger& operator=(NetworkCaptureLogger&&) = delete; | ||
| virtual ~NetworkCaptureLogger(); | ||
|
|
||
| virtual void LogRead(const void* data, std::size_t length) = 0; | ||
| virtual void LogWrite(const void* data, std::size_t length) = 0; | ||
| virtual NetworkCaptureType GetCaptureType() const = 0; | ||
| }; | ||
|
|
||
| class DummyNetworkCaptureLogger : public NetworkCaptureLogger | ||
| { | ||
| public: | ||
| void LogRead(const void* data, std::size_t length) override; | ||
| void LogWrite(const void* data, std::size_t length) override; | ||
| NetworkCaptureType GetCaptureType() const override; | ||
| }; | ||
|
|
||
| class BinarySSLCaptureLogger final : public NetworkCaptureLogger | ||
| { | ||
| public: | ||
| void LogRead(const void* data, std::size_t length) override; | ||
| void LogWrite(const void* data, std::size_t length) override; | ||
| NetworkCaptureType GetCaptureType() const override; | ||
| }; | ||
| } // namespace Core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters