File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ namespace kiwix
6969 int getPort () const ;
7070 IpAddress getAddress () const ;
7171 IpMode getIpMode () const ;
72+ std::vector<std::string> getServerAccessUrls () const ;
7273
7374 protected:
7475 std::shared_ptr<Library> mp_library;
Original file line number Diff line number Diff line change 2929
3030namespace kiwix {
3131
32+ namespace
33+ {
34+
35+ std::string makeServerUrl (std::string host, int port, std::string root)
36+ {
37+ const int httpDefaultPort = 80 ;
38+
39+ if (port == httpDefaultPort) {
40+ return " http://" + host + root;
41+ } else {
42+ return " http://" + host + " :" + std::to_string (port) + root;
43+ }
44+ }
45+
46+ } // unnamed namespace
47+
3248Server::Server (LibraryPtr library, std::shared_ptr<NameMapper> nameMapper) :
3349 mp_library (library),
3450 mp_nameMapper (nameMapper),
@@ -112,4 +128,19 @@ IpMode Server::getIpMode() const
112128 return mp_server->getIpMode ();
113129}
114130
131+ std::vector<std::string> Server::getServerAccessUrls () const
132+ {
133+ std::vector<std::string> result;
134+ const kiwix::IpAddress addresses = m_addr;
135+ const int port = m_port;
136+ const std::string root = m_root;
137+ if (!addresses.addr .empty ()) {
138+ result.push_back (makeServerUrl (addresses.addr , port, root));
139+ }
140+ if (!addresses.addr6 .empty ()) {
141+ result.push_back (makeServerUrl (" [" + addresses.addr6 + " ]" , port, root));
142+ }
143+ return result;
115144}
145+
146+ }
You can’t perform that action at this time.
0 commit comments