File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-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 @@ -106,4 +106,33 @@ IpMode Server::getIpMode() const
106106 return mp_server->getIpMode ();
107107}
108108
109+ std::vector<std::string> Server::getServerAccessUrls () const
110+ {
111+ std::vector<std::string> result;
112+ const kiwix::IpAddress addresses = m_addr;
113+ const int port = m_port;
114+ const std::string root = m_root;
115+ if (!addresses.addr .empty ()) {
116+ result.push_back (makeServerUrl (addresses.addr , port, root));
117+ }
118+ if (!addresses.addr6 .empty ()) {
119+ result.push_back (makeServerUrl (" [" + addresses.addr6 + " ]" , port, root));
120+ }
121+ return result;
109122}
123+
124+ namespace
125+ {
126+ std::string makeServerUrl (std::string host, int port, std::string root)
127+ {
128+ const int httpDefaultPort = 80 ;
129+
130+ if (port == httpDefaultPort) {
131+ return " http://" + host + root;
132+ } else {
133+ return " http://" + host + " :" + std::to_string (port) + root;
134+ }
135+ }
136+ } // unnamed namespace
137+
138+ }
You can’t perform that action at this time.
0 commit comments