Update README and IPv6 preparations
This commit is contained in:
@@ -76,6 +76,8 @@ ColumnLynx makes use of both **TCP** and **UDP**. **TCP** is used for the initia
|
|||||||
|
|
||||||
It operates on port **48042** for both TCP and UDP.
|
It operates on port **48042** for both TCP and UDP.
|
||||||
|
|
||||||
|
Generally, all transmission is done in **little-endian byte order**, since pretty much every single modern architecture uses it by default. The only exemption to this is the **transmission of IP addresses** (for the **Virtual Interface**), which is **big-endian**.
|
||||||
|
|
||||||
### Handshake Procedure
|
### Handshake Procedure
|
||||||
|
|
||||||
The handshake between the client and server is done over **TCP**. This is to ensure delivery without much hassle.
|
The handshake between the client and server is done over **TCP**. This is to ensure delivery without much hassle.
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
@@ -22,6 +23,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace ColumnLynx {
|
||||||
|
using IPv6Addr = std::array<uint8_t, 16>;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ColumnLynx::Utils {
|
namespace ColumnLynx::Utils {
|
||||||
// General log function. Use for logging important information.
|
// General log function. Use for logging important information.
|
||||||
void log(const std::string &msg);
|
void log(const std::string &msg);
|
||||||
@@ -76,6 +81,18 @@ namespace ColumnLynx::Utils {
|
|||||||
return cbswap64(x);
|
return cbswap64(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T cbswap128(const T& x) {
|
||||||
|
static_assert(sizeof(T) == 16, "cbswap128 requires a 128-bit type");
|
||||||
|
|
||||||
|
T out{};
|
||||||
|
const uint8_t* src = reinterpret_cast<const uint8_t*>(&x);
|
||||||
|
uint8_t* dst = reinterpret_cast<uint8_t*>(&out);
|
||||||
|
std::reverse_copy(src, src + 16, dst);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the config file in an unordered_map format. This purely reads the config file, you still need to parse it manually.
|
// Returns the config file in an unordered_map format. This purely reads the config file, you still need to parse it manually.
|
||||||
std::unordered_map<std::string, std::string> getConfigMap(std::string path);
|
std::unordered_map<std::string, std::string> getConfigMap(std::string path);
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user