Display better message when using standard port

This commit is contained in:
Vighnesh
2025-10-26 23:58:14 +05:30
committed by Kelson
parent 830a9e5e29
commit ae21ba42da

View File

@@ -104,16 +104,6 @@ std::string loadCustomTemplate (std::string customIndexPath) {
return indexTemplateString;
}
inline std::string normalizeRootUrl(std::string rootUrl)
{
while ( !rootUrl.empty() && rootUrl.back() == '/' )
rootUrl.pop_back();
while ( !rootUrl.empty() && rootUrl.front() == '/' )
rootUrl = rootUrl.substr(1);
return rootUrl.empty() ? rootUrl : "/" + rootUrl;
}
#ifndef _WIN32
volatile sig_atomic_t waiting = false;
volatile sig_atomic_t libraryMustBeReloaded = false;
@@ -393,13 +383,11 @@ int main(int argc, char** argv)
if (! server.start()) {
exit(1);
}
std::string prefix = "http://";
kiwix::IpAddress addresses = server.getAddress();
std::string suffix = ":" + std::to_string(server.getPort()) + normalizeRootUrl(rootLocation);
std::cout << "The Kiwix server is running and can be accessed in the local network at: " << std::endl;
if(!addresses.addr.empty()) std::cout << " - " << prefix << addresses.addr << suffix << std::endl;
if(!addresses.addr6.empty()) std::cout << " - " << prefix << "[" << addresses.addr6 << "]" << suffix << std::endl;
for (const auto& url : server.getServerAccessUrls()) {
std::cout << " - " << url << std::endl;
}
/* Run endless (until PPID dies) */
waiting = true;