Make JSON API server bind address configurable

Enforce it being 127.0.0.1 by default, I assumed 127.0.0.1 was restbed
default, but as reported by sehraf is not alwayd the case

JSON API bind address now is also configurable via commandline on
retroshare-android-service and retroshare-nogui, while it obey the
configuration of webui (execept for that port is incremented by 2)
in retroshare-gui
This commit is contained in:
Gioacchino Mazzurco 2018-09-05 00:08:56 +02:00
parent 4acbf775a5
commit a194e4cf56
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
5 changed files with 76 additions and 24 deletions

View file

@ -58,8 +58,9 @@ static bool checkRsServicePtrReady(
}
JsonApiServer::JsonApiServer(
uint16_t port, const std::function<void(int)> shutdownCallback) :
mPort(port), mShutdownCallback(shutdownCallback)
uint16_t port, const std::string& bindAddress,
const std::function<void(int)> shutdownCallback ) :
mPort(port), mBindAddress(bindAddress), mShutdownCallback(shutdownCallback)
{
registerHandler("/jsonApiServer/shutdown",
[this](const std::shared_ptr<rb::Session> session)
@ -153,7 +154,7 @@ void JsonApiServer::run()
{
std::shared_ptr<rb::Settings> settings(new rb::Settings);
settings->set_port(mPort);
// settings->set_default_header("Connection", "close");
settings->set_bind_address(mBindAddress);
settings->set_default_header("Cache-Control", "no-cache");
mService.start(settings);
}