established buffer, must now switch to json

This commit is contained in:
2025-10-24 23:01:57 -05:00
parent fc0bbd18d6
commit bbed6bb653
6 changed files with 46 additions and 3 deletions

View File

@@ -1,2 +1,3 @@
[hostname]
base_path="https://tracker.example.com"
inter_comm_port=8032

View File

@@ -0,0 +1,25 @@
#include "socket-manager.hpp"
#include <netinet/in.h>
#include <sys/socket.h>
#include <thread>
void start_daemon(std::uint16_t port){
int server_socket = socket(AF_INET, SOCK_STREAM, 0);
sockaddr_in server_address;
server_address.sin_family = AF_INET;
server_address.sin_port = htons(8080);
server_address.sin_addr.s_addr = INADDR_ANY;
bind(server_socket, (struct sockaddr*)&server_address,
sizeof(server_address));
// listening to the assigned socket
listen(server_socket, 5);
while(true){
int client_socket = accept(server_socket, nullptr,nullptr);
std::thread client_handling_thread = std::thread{handle_client, client_socket};
}
}
void handle_client(int client_socket){
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include <sys/socket.h>
#include <cstdint>
#include <netinet/in.h>
void handle_client(int client_socket);
void start_daemon(std::uint16_t port);

View File

@@ -1,4 +1,7 @@
#include "spdlog/common.h"
#include "spdlog/spdlog.h"
#include <cstdint>
#include <filesystem>
#include <iostream>
#include <toml++/toml.hpp>
// This is the *daemon*
@@ -6,9 +9,18 @@
int main() {
std::cout << "Hello from the email tracker's daemon (C++23)\n";
spdlog::info("Logger is functional.");
spdlog::set_level(spdlog::level::debug);
bool does_exist_config = std::filesystem::exists("host-config.toml");
spdlog::debug("Host config existential status: {}", does_exist_config);
if (!does_exist_config) return -1;
auto config = toml::parse_file("host-config.toml");
std::string http_server_fqdn = config["hostname"]["base_path"].value_or("http://example.com");
std::uint16_t inter_comm_port = config["hostname"]["inter_comm_port"].value_or(8033);
spdlog::debug("Path collected: {}", http_server_fqdn);
spdlog::debug("Port collected for inter-process communication {}", inter_comm_port);
return 0;
}

View File

@@ -3,6 +3,5 @@
namespace serializable {
template <typename S>
void serialize(S &s, HandshakeConnection &object){
s.value2b(object.payload);
}
}

View File

@@ -1,5 +1,5 @@
#pragma once
#include <bitsery/bitsery.h>
#include <cstdint>
namespace serializable{