Compare commits
6 Commits
ssl
...
254de7a9ee
| Author | SHA1 | Date | |
|---|---|---|---|
| 254de7a9ee | |||
| 9fa023f716 | |||
| f6620dc522 | |||
| 6a52b7fe2a | |||
| 68fcd514a3 | |||
| 5f9cc86ad2 |
31
.github/workflows/ubuntu.yml
vendored
31
.github/workflows/ubuntu.yml
vendored
@@ -1,31 +0,0 @@
|
|||||||
name: Linux arm64
|
|
||||||
run-name: Build And Test
|
|
||||||
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
|
|
||||||
env:
|
|
||||||
XMAKE_ROOT: y
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Prepare XMake
|
|
||||||
uses: xmake-io/github-action-setup-xmake@v1
|
|
||||||
with:
|
|
||||||
xmake-version: latest
|
|
||||||
actions-cache-folder: '.xmake-cache'
|
|
||||||
actions-cache-key: 'ubuntu'
|
|
||||||
|
|
||||||
- name: XMake config
|
|
||||||
run: xmake f -p linux -y
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: xmake
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: xmake test
|
|
||||||
@@ -166,7 +166,7 @@ class DataBuffer {
|
|||||||
K newKey;
|
K newKey;
|
||||||
V newValue;
|
V newValue;
|
||||||
*this >> newKey >> newValue;
|
*this >> newKey >> newValue;
|
||||||
data.emplace(newKey, newValue);
|
data.insert({newKey, newValue});
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ template <>
|
|||||||
class MessageEncapsulator<option::ZlibCompress> {
|
class MessageEncapsulator<option::ZlibCompress> {
|
||||||
public:
|
public:
|
||||||
static DataBuffer Encapsulate(const DataBuffer& a_Data, const option::ZlibCompress& a_Option);
|
static DataBuffer Encapsulate(const DataBuffer& a_Data, const option::ZlibCompress& a_Option);
|
||||||
static DataBuffer Decapsulate(DataBuffer& a_Data, const option::ZlibCompress& a_Option);
|
static DataBuffer Decapsulate(DataBuffer& a_Data, std::size_t a_Length, const option::ZlibCompress& a_Option);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace io
|
} // namespace io
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file Encrypt.h
|
|
||||||
* \brief File containing encrypt utilities
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sp/common/DataBuffer.h>
|
|
||||||
|
|
||||||
namespace sp {
|
|
||||||
namespace option {
|
|
||||||
|
|
||||||
struct TlsEncrypt {
|
|
||||||
bool m_Enabled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace option
|
|
||||||
} // namespace sp
|
|
||||||
|
|
||||||
#include <sp/io/IOInterface.h>
|
|
||||||
|
|
||||||
namespace sp {
|
|
||||||
namespace ssl {
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
|
|
||||||
// decrypt
|
|
||||||
|
|
||||||
} // namespace ssl
|
|
||||||
|
|
||||||
namespace io {
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class MessageEncapsulator<option::TlsEncrypt> {
|
|
||||||
public:
|
|
||||||
static DataBuffer Encapsulate(const DataBuffer& a_Data, const option::TlsEncrypt& a_Option);
|
|
||||||
static DataBuffer Decapsulate(DataBuffer& a_Data, const option::TlsEncrypt& a_Option);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace io
|
|
||||||
} // namespace sp
|
|
||||||
@@ -17,7 +17,7 @@ template <typename TOption>
|
|||||||
class MessageEncapsulator {
|
class MessageEncapsulator {
|
||||||
public:
|
public:
|
||||||
static DataBuffer Encapsulate(const DataBuffer& a_Data, const TOption& a_Option);
|
static DataBuffer Encapsulate(const DataBuffer& a_Data, const TOption& a_Option);
|
||||||
static DataBuffer Decapsulate(DataBuffer& a_Data, const TOption& a_Option);
|
static DataBuffer Decapsulate(DataBuffer& a_Data, std::size_t a_Length, const TOption& a_Option);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename IOTag, typename MessageDispatcher, typename MessageFactory, typename... TOptions>
|
template <typename IOTag, typename MessageDispatcher, typename MessageFactory, typename... TOptions>
|
||||||
@@ -49,7 +49,7 @@ class Stream {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static DataBuffer Encapsulate(const DataBuffer& a_Data, const TOptions&... a_Options);
|
static DataBuffer Encapsulate(const DataBuffer& a_Data, const TOptions&... a_Options);
|
||||||
static DataBuffer Decapsulate(DataBuffer& a_Data, const TOptions&... a_Options);
|
static DataBuffer Decapsulate(DataBuffer& a_Data, std::size_t a_Length, const TOptions&... a_Options);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace io
|
} // namespace io
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ struct MessageEncapsulatorPack<> {
|
|||||||
static DataBuffer Encapsulate(const DataBuffer& a_Data) {
|
static DataBuffer Encapsulate(const DataBuffer& a_Data) {
|
||||||
return a_Data;
|
return a_Data;
|
||||||
}
|
}
|
||||||
static DataBuffer Decapsulate(DataBuffer& a_Data) {
|
static DataBuffer Decapsulate(DataBuffer& a_Data, std::size_t a_Length) {
|
||||||
return a_Data;
|
return a_Data;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -26,9 +26,9 @@ struct MessageEncapsulatorPack<TOption, TOptions...> {
|
|||||||
DataBuffer data = io::MessageEncapsulator<TOption>::Encapsulate(a_Data, a_Option);
|
DataBuffer data = io::MessageEncapsulator<TOption>::Encapsulate(a_Data, a_Option);
|
||||||
return MessageEncapsulatorPack<TOptions...>::Encapsulate(data, a_Options...);
|
return MessageEncapsulatorPack<TOptions...>::Encapsulate(data, a_Options...);
|
||||||
}
|
}
|
||||||
static DataBuffer Decapsulate(DataBuffer& a_Data, const TOption& a_Option, const TOptions&... a_Options) {
|
static DataBuffer Decapsulate(DataBuffer& a_Data, std::size_t a_Length, const TOption& a_Option, const TOptions&... a_Options) {
|
||||||
DataBuffer data = io::MessageEncapsulator<TOption>::Decapsulate(a_Data, a_Option);
|
DataBuffer data = io::MessageEncapsulator<TOption>::Decapsulate(a_Data, a_Length, a_Option);
|
||||||
return MessageEncapsulatorPack<TOptions...>::Decapsulate(data, a_Options...);
|
return MessageEncapsulatorPack<TOptions...>::Decapsulate(data, data.GetSize(), a_Options...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ void Stream<IOTag, MessageDispatcher, MessageFactory, TOptions...>::RecieveMessa
|
|||||||
buffer = m_Interface.Read(lenghtValue);
|
buffer = m_Interface.Read(lenghtValue);
|
||||||
|
|
||||||
buffer = std::apply([&buffer, lenghtValue](const auto&... a_Options) {
|
buffer = std::apply([&buffer, lenghtValue](const auto&... a_Options) {
|
||||||
return Decapsulate(buffer, a_Options...);
|
return Decapsulate(buffer, lenghtValue, a_Options...);
|
||||||
}, m_Options);
|
}, m_Options);
|
||||||
|
|
||||||
VarInt packetType;
|
VarInt packetType;
|
||||||
@@ -120,8 +120,8 @@ DataBuffer Stream<IOTag, MessageDispatcher, MessageFactory, TOptions...>::Encaps
|
|||||||
|
|
||||||
template <typename IOTag, typename MessageDispatcher, typename MessageFactory, typename... TOptions>
|
template <typename IOTag, typename MessageDispatcher, typename MessageFactory, typename... TOptions>
|
||||||
DataBuffer Stream<IOTag, MessageDispatcher, MessageFactory, TOptions...>::Decapsulate(
|
DataBuffer Stream<IOTag, MessageDispatcher, MessageFactory, TOptions...>::Decapsulate(
|
||||||
DataBuffer& a_Data, const TOptions&... a_Options) {
|
DataBuffer& a_Data, std::size_t a_Length, const TOptions&... a_Options) {
|
||||||
return details::MessageEncapsulatorPack<TOptions...>::Decapsulate(a_Data, a_Options...);
|
return details::MessageEncapsulatorPack<TOptions...>::Decapsulate(a_Data, a_Length, a_Options...);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace io
|
} // namespace io
|
||||||
|
|||||||
@@ -81,8 +81,9 @@ DataBuffer MessageEncapsulator<option::ZlibCompress>::Encapsulate(const DataBuff
|
|||||||
return zlib::Compress(a_Data, a_Option.m_Enabled ? a_Option.m_CompressionThreshold : MAX_COMPRESS_THRESHOLD);
|
return zlib::Compress(a_Data, a_Option.m_Enabled ? a_Option.m_CompressionThreshold : MAX_COMPRESS_THRESHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBuffer MessageEncapsulator<option::ZlibCompress>::Decapsulate(DataBuffer& a_Data, const option::ZlibCompress& a_Option) {
|
DataBuffer MessageEncapsulator<option::ZlibCompress>::Decapsulate(
|
||||||
return zlib::Decompress(a_Data, a_Data.GetSize());
|
DataBuffer& a_Data, std::size_t a_Length, const option::ZlibCompress& a_Option) {
|
||||||
|
return zlib::Decompress(a_Data, a_Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace io
|
} // namespace io
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#include <sp/extensions/Encrypt.h>
|
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
@@ -6,14 +6,9 @@ local modules = {
|
|||||||
Compression = {
|
Compression = {
|
||||||
Option = "zlib",
|
Option = "zlib",
|
||||||
Deps = {"zlib"},
|
Deps = {"zlib"},
|
||||||
|
Packages = {"zlib"},
|
||||||
Includes = {"include/(sp/extensions/Compress.h)"},
|
Includes = {"include/(sp/extensions/Compress.h)"},
|
||||||
Sources = {"src/sp/extensions/Compress.cpp"}
|
Sources = {"src/sp/extensions/Compress.cpp"}
|
||||||
},
|
|
||||||
Encryption = {
|
|
||||||
Option = "ssl",
|
|
||||||
Deps = {"openssl"},
|
|
||||||
Includes = {"include/(sp/extensions/Encrypt.h)"},
|
|
||||||
Sources = {"src/sp/extensions/Encrypt.cpp"}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +37,7 @@ for name, module in table.orderpairs(modules) do
|
|||||||
for _, source in table.orderpairs(module.Sources) do
|
for _, source in table.orderpairs(module.Sources) do
|
||||||
add_files(source)
|
add_files(source)
|
||||||
end
|
end
|
||||||
for _, package in table.orderpairs(module.Deps) do
|
for _, package in table.orderpairs(module.Packages) do
|
||||||
add_packages(package)
|
add_packages(package)
|
||||||
end
|
end
|
||||||
set_group("Library")
|
set_group("Library")
|
||||||
|
|||||||
Reference in New Issue
Block a user