|
|
@ -284,10 +284,10 @@ void ServerConnection::threadFn()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (((fn->flags & SF_ALLOW_REMOTE) != SF_ALLOW_REMOTE) && strcmp(socket->GetClientAddr(), "127.0.0.1") != 0)
|
|
|
|
if (((fn->flags & SF_ALLOW_REMOTE) != SF_ALLOW_REMOTE) && strcmp(socket->GetClientAddr(), "127.0.0.1") != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stream.printerr("In call to %s: forbidden host: %s\n", fn->name, socket->GetClientAddr());
|
|
|
|
stream.printerr("In call to %s: forbidden host: %s\n", fn->name, socket->GetClientAddr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!fn->in()->ParseFromArray(buf.get(), header.size))
|
|
|
|
else if (!fn->in()->ParseFromArray(buf.get(), header.size))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stream.printerr("In call to %s: could not decode input args.\n", fn->name);
|
|
|
|
stream.printerr("In call to %s: could not decode input args.\n", fn->name);
|
|
|
@ -379,33 +379,33 @@ bool ServerMain::listen(int port)
|
|
|
|
|
|
|
|
|
|
|
|
socket->Initialize();
|
|
|
|
socket->Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
bool allow_remote = false;
|
|
|
|
bool allow_remote = false;
|
|
|
|
std::string filename("dfhack-config/remote-server.cfg");
|
|
|
|
std::string filename("dfhack-config/remote-server.cfg");
|
|
|
|
|
|
|
|
|
|
|
|
std::ifstream configFile(filename);
|
|
|
|
std::ifstream configFile(filename);
|
|
|
|
if (configFile.is_open())
|
|
|
|
if (configFile.is_open())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string line;
|
|
|
|
std::string line;
|
|
|
|
while (std::getline(configFile, line))
|
|
|
|
while (std::getline(configFile, line))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (line.compare(0, 1, "#") == 0)
|
|
|
|
if (line.compare(0, 1, "#") == 0)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
if (line.compare(0, 24, "allow-remote-connections") == 0)
|
|
|
|
if (line.compare(0, 24, "allow-remote-connections") == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
allow_remote = (line.compare(25, std::string::npos, "true") == 0);
|
|
|
|
allow_remote = (line.compare(25, std::string::npos, "true") == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (allow_remote)
|
|
|
|
if (allow_remote)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!socket->Listen(NULL, port))
|
|
|
|
if (!socket->Listen(NULL, port))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!socket->Listen("127.0.0.1", port))
|
|
|
|
if (!socket->Listen("127.0.0.1", port))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
thread = new tthread::thread(threadFn, this);
|
|
|
|
thread = new tthread::thread(threadFn, this);
|
|
|
|
thread->detach();
|
|
|
|
thread->detach();
|
|
|
|