mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
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:
parent
4acbf775a5
commit
a194e4cf56
5 changed files with 76 additions and 24 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace rb = restbed;
|
|||
struct JsonApiServer : RsSingleJobThread
|
||||
{
|
||||
JsonApiServer(
|
||||
uint16_t port,
|
||||
uint16_t port = 9092,
|
||||
const std::string& bindAddress = "127.0.0.1",
|
||||
const std::function<void(int)> shutdownCallback = [](int){} );
|
||||
|
||||
/// @see RsSingleJobThread
|
||||
|
@ -66,7 +67,8 @@ struct JsonApiServer : RsSingleJobThread
|
|||
void shutdown(int exitCode = 0);
|
||||
|
||||
private:
|
||||
uint16_t mPort;
|
||||
const uint16_t mPort;
|
||||
const std::string mBindAddress;
|
||||
rb::Service mService;
|
||||
const std::function<void(int)> mShutdownCallback;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue