알려진 버그 픽스

This commit is contained in:
2025-04-23 04:51:28 +09:00
parent cebf59ddd8
commit 995a27a15e
16 changed files with 98 additions and 38 deletions

View File

@@ -1 +0,0 @@
[2025-04-22 23:42:27.045] [Chattering Logger] [critical] [listen()] Operation not supported

View File

@@ -53,7 +53,7 @@ Socket::operator SOCKET() const {
}
void Socket::move(const SOCKET __sock) {
if (sock_ == INVALID_SOCKET)
if (__sock == INVALID_SOCKET)
log::critical("socket()");
if (valid_) {

View File

@@ -16,8 +16,17 @@ void TCPSocket::listen(int __n) {
}
void TCPSocket::accept(TCPSocket& newSock, Address& __addr) {
newSock.move(::accept(sock_, &__addr.sockaddr, &__addr.length));
newSock.move(::accept(sock_, &__addr.addr, &__addr.length));
if (newSock == INVALID_SOCKET)
log::critical("accept()");
}
}
void TCPSocket::connect(Chattr::Address serveraddr) {
int retVal = ::connect(sock_, (struct sockaddr *)&serveraddr, serveraddr.length);
if (retVal == INVALID_SOCKET)
log::critical("connect()");
}
}

View File

@@ -1,8 +0,0 @@
{
"IP Version" : 6,
"Listen Port" : 9010,
"LogLevel" : 1,
"LogfileCount" : 5,
"LogfileName" : "Chattering.log",
"LogfileSize" : 4294967295
}

View File

@@ -1,53 +0,0 @@
#include "Utils/ConfigManager.hpp"
#include "precomp.hpp"
#include <fstream>
#include <json/json.h>
#include <iostream>
#include <string>
namespace Chattr {
ConfigManager::Config ConfigManager::load() {
Config config;
std::ifstream configfile("config.json", std::ifstream::binary);
if (!configfile.is_open()) {
std::ofstream defaultConfig("config.json", std::ios::out);
config.configJsonRoot["IP Version"] = 6;
config.configJsonRoot["Listen Port"] = 9010;
config.configJsonRoot["LogLevel"] = 1;
config.configJsonRoot["LogfileName"] = "Chattering.log";
config.configJsonRoot["LogfileSize"] = UINT32_MAX;
config.configJsonRoot["LogfileCount"] = 5;
defaultConfig << config.configJsonRoot;
defaultConfig.close();
spdlog::critical("\"config.json\" is missing. Default configuration has been written.");
}
try {
if (configfile.is_open())
configfile >> config.configJsonRoot;
config.ipVersion = config.configJsonRoot["IP Version"].asInt();
if (config.ipVersion != 4 && config.ipVersion != 6)
throw std::runtime_error("Invalid IP Version.");
config.listenPort = config.configJsonRoot["Listen Port"].asInt();
if (config.listenPort < 0 || config.listenPort > 65535)
throw std::runtime_error("Invalid listen port.");
int ll_ = config.configJsonRoot["LogLevel"].asInt();
if (ll_ >= 0 && ll_ < spdlog::level::n_levels)
config.logLevel = (spdlog::level::level_enum)ll_;
else
throw std::runtime_error("Invalid log level.");
config.logFileName = config.configJsonRoot["LogfileName"].asCString();
config.logfileSize = config.configJsonRoot["LogfileSize"].asUInt();
config.logfileCount = config.configJsonRoot["LogfileCount"].asUInt();
}
catch (Json::RuntimeError e) {
spdlog::critical(std::string(std::string("[Json Error: ]") + e.what()).c_str());
std::exit(EXIT_FAILURE);
}
return config;
}
}