diff --git a/src/server/main.cpp b/src/server/main.cpp index 080018b..66211d8 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -67,17 +67,22 @@ int main(int argc, char** argv) { bool ipv4Only = optionsObj["ipv4-only"].as(); log("ColumnLynx Server, Version " + getVersion()); - log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSES/ for details."); - -#if defined(__WIN32__) - //WintunInitialize(); -#endif - - std::unordered_map config = Utils::getConfigMap(optionsObj["config"].as()); + log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSES/ for details."); std::shared_ptr tun = std::make_shared(optionsObj["interface"].as()); log("Using virtual interface: " + tun->getName()); + // Get network configuration from config file + std::unordered_map config = Utils::getConfigMap(optionsObj["config"].as()); + std::string networkString = config.find("NETWORK") != config.end() ? config.find("NETWORK")->second : "10.10.0.0"; + uint8_t subnetMask = config.find("SUBNET_MASK") != config.end() ? std::stoi(config.find("SUBNET_MASK")->second) : 24; + uint32_t baseIP = VirtualInterface::stringToIpv4(networkString); + uint32_t serverIP = baseIP + 1; // e.g., 10.10.0.1 + + // Configure the server's TUN interface + tun->configureIP(serverIP, serverIP, subnetMask, 1420); + log("Configured TUN interface with IP " + VirtualInterface::ipv4ToString(serverIP) + "/" + std::to_string(subnetMask)); + // Generate a temporary keypair, replace with actual CA signed keys later (Note, these are stored in memory) std::shared_ptr sodiumWrapper = std::make_shared();