Merge pull request #763 from vighnesh-sawant/standard-port-enhancment
Some checks failed
CI / Windows (push) Has been cancelled
CI / Linux (linux-x86_64, jammy, /x86_64-linux-gnu, linux-x86_64-dyn) (push) Has been cancelled
CI / Linux (linux-x86_64, jammy, /x86_64-linux-gnu, linux-x86_64-static) (push) Has been cancelled
Packages / build-deb (ubuntu-jammy) (push) Has been cancelled
Packages / build-deb (ubuntu-noble) (push) Has been cancelled

Improve message when server is running on standard port
This commit is contained in:
Kelson 2025-11-01 17:09:53 +01:00 committed by GitHub
commit d61eafe6a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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;