알려진 버그 픽스
This commit is contained in:
4
Chattering.log
Normal file
4
Chattering.log
Normal file
@@ -0,0 +1,4 @@
|
||||
[2025-04-23 02:12:26.679] [Chattering Logger] [info] Waiting for connection...
|
||||
[2025-04-23 02:12:32.642] [Chattering Logger] [critical] [socket()] No such file or directory
|
||||
[2025-04-23 02:24:30.033] [Chattering Logger] [info] Waiting for connection...
|
||||
[2025-04-23 02:58:01.648] [Chattering Logger] [info] Waiting for connection...
|
||||
@@ -2,12 +2,56 @@ cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
set(PROJECT_NAME "Client")
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
project(${PROJECT_NAME})
|
||||
project(${PROJECT_NAME} CXX)
|
||||
|
||||
add_executable(${PROJECT_NAME} src/client.cpp)
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
spdlog
|
||||
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
|
||||
GIT_TAG "v1.11.0"
|
||||
GIT_SHALLOW ON
|
||||
)
|
||||
FetchContent_MakeAvailable(spdlog)
|
||||
|
||||
FetchContent_Declare(
|
||||
GSL
|
||||
GIT_REPOSITORY "https://github.com/microsoft/GSL.git"
|
||||
GIT_TAG "v4.2.0"
|
||||
GIT_SHALLOW ON
|
||||
)
|
||||
FetchContent_MakeAvailable(GSL)
|
||||
|
||||
FetchContent_Declare(
|
||||
JSONCPP
|
||||
GIT_REPOSITORY "https://github.com/open-source-parsers/jsoncpp.git"
|
||||
GIT_TAG "1.9.6"
|
||||
GIT_SHALLOW ON
|
||||
)
|
||||
FetchContent_MakeAvailable(JSONCPP)
|
||||
|
||||
file(GLOB_RECURSE additional_sources CONFIGURE_DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../impl/*.cpp"
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/client.cpp
|
||||
${additional_sources}
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft.GSL::GSL)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE jsoncpp_lib)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ws2_32)
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
|
||||
|
||||
target_precompile_headers(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../include/precomp.hpp")
|
||||
@@ -1,5 +1,17 @@
|
||||
#include <iostream>
|
||||
#include "Socket/TCPSocket.hpp"
|
||||
#include "Socket/Address.hpp"
|
||||
#include "Socket/Log.hpp"
|
||||
#include "precomp.hpp"
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, world!" << std::endl;
|
||||
Chattr::TCPSocket sock;
|
||||
sock.init(AF_INET6);
|
||||
|
||||
Chattr::Address serveraddr;
|
||||
serveraddr.addr_in6.sin6_family = AF_INET6;
|
||||
inet_pton(AF_INET6, "fd8a:5f:3adb:774d:dfae:983f:2e7a:ffba", &serveraddr.addr_in6.sin6_addr);
|
||||
serveraddr.addr_in6.sin6_port = htons(9010);
|
||||
serveraddr.length = sizeof(sockaddr_in6);
|
||||
|
||||
sock.connect(serveraddr);
|
||||
}
|
||||
@@ -34,6 +34,7 @@ FetchContent_MakeAvailable(JSONCPP)
|
||||
|
||||
file(GLOB_RECURSE additional_sources CONFIGURE_DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../impl/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/Utils/*.cpp"
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[2025-04-22 20:30:06.838] [Chattering Logger] [critical] [bind()] Invalid argument
|
||||
[2025-04-22 22:26:22.198] [Chattering Logger] [critical] [bind()] Socket operation on non-socket
|
||||
[2025-04-22 23:38:21.098] [Chattering Logger] [critical] [listen()] Operation not supported
|
||||
[2025-04-22 23:39:00.008] [Chattering Logger] [critical] [listen()] Operation not supported
|
||||
[2025-04-22 23:40:54.696] [Chattering Logger] [critical] [listen()] Operation not supported
|
||||
[2025-04-22 23:41:11.774] [Chattering Logger] [critical] [listen()] Operation not supported
|
||||
[2025-04-22 23:41:21.669] [Chattering Logger] [critical] [listen()] Operation not supported
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"IP Version" : 4,
|
||||
"Listen Port" : 9010,
|
||||
"LogLevel" : 1,
|
||||
"LogfileCount" : 5,
|
||||
"LogfileName" : "Chattering.log",
|
||||
"LogfileSize" : 4294967295
|
||||
}
|
||||
@@ -7,27 +7,26 @@ int main() {
|
||||
auto config = Chattr::ConfigManager::load();
|
||||
Chattr::log::setDefaultLogger(config.logLevel, config.logFileName, config.logfileSize, config.logfileCount);
|
||||
|
||||
|
||||
struct Chattr::TCPSocket sock;
|
||||
if (config.ipVersion == 4) {
|
||||
sock.init(AF_INET);
|
||||
|
||||
struct sockaddr_in serveraddr;
|
||||
serveraddr.sin_family = AF_INET;
|
||||
serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
serveraddr.sin_port = htons(config.listenPort);
|
||||
struct Chattr::Address serveraddr;
|
||||
serveraddr.addr_in.sin_family = AF_INET;
|
||||
serveraddr.addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
serveraddr.addr_in.sin_port = htons(config.listenPort);
|
||||
|
||||
sock.bind(&serveraddr);
|
||||
sock.bind(&serveraddr.addr_in);
|
||||
}
|
||||
else {
|
||||
sock.init(AF_INET6);
|
||||
|
||||
struct sockaddr_in6 serveraddr;
|
||||
serveraddr.sin6_family = AF_INET6;
|
||||
serveraddr.sin6_addr = in6addr_any;
|
||||
serveraddr.sin6_port = htons(config.listenPort);
|
||||
struct Chattr::Address serveraddr;
|
||||
serveraddr.addr_in6.sin6_family = AF_INET6;
|
||||
serveraddr.addr_in6.sin6_addr = in6addr_any;
|
||||
serveraddr.addr_in6.sin6_port = htons(config.listenPort);
|
||||
|
||||
sock.bind(&serveraddr);
|
||||
sock.bind(&serveraddr.addr_in6);
|
||||
}
|
||||
sock.listen(SOMAXCONN);
|
||||
struct Chattr::TCPSocket clientSock;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
[2025-04-22 23:42:27.045] [Chattering Logger] [critical] [listen()] Operation not supported
|
||||
@@ -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_) {
|
||||
|
||||
@@ -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()");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,14 @@
|
||||
namespace Chattr {
|
||||
|
||||
struct Address {
|
||||
Address() {
|
||||
memset(&addr_in6, 0, sizeof(addr_in6));
|
||||
}
|
||||
|
||||
union {
|
||||
struct sockaddr sockaddr;
|
||||
struct sockaddr_in sockaddr_in;
|
||||
struct sockaddr_in6 sockaddr_in6;
|
||||
struct sockaddr addr;
|
||||
struct sockaddr_in addr_in;
|
||||
struct sockaddr_in6 addr_in6;
|
||||
};
|
||||
socklen_t length;
|
||||
};
|
||||
|
||||
@@ -6,10 +6,12 @@ namespace Chattr {
|
||||
|
||||
class TCPSocket : public Socket {
|
||||
public:
|
||||
using Socket::Socket;
|
||||
using Socket::init;
|
||||
void init(int domain);
|
||||
void listen(int __n);
|
||||
void accept(TCPSocket& newSock, Address& addr);
|
||||
void connect(Chattr::Address serveraddr);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
#elif __linux__
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#define SOCKET int
|
||||
|
||||
Reference in New Issue
Block a user