Make requested tsync scenery-version settable from prop

set /sim/terrasync/scenery-version=ws30 to filter the DNS NAPTR
records for service=ws30
current default (and only available) scenery version is ws20

This enables usage of multiple scenery repositories
This commit is contained in:
Torsten Dreyer 2016-08-29 21:00:03 +02:00
parent d7d59b08a2
commit c1ba974538

View File

@ -271,6 +271,16 @@ public:
_httpServer = stripPath(server); _httpServer = stripPath(server);
} }
void setDNSDN( const std::string & dn )
{
_dnsdn = simgear::strutils::strip(dn);
}
void setSceneryVersion( const std::string & sceneryVersion )
{
_sceneryVersion = simgear::strutils::strip(sceneryVersion);
}
void setLocalDir(string dir) { _local_dir = stripPath(dir);} void setLocalDir(string dir) { _local_dir = stripPath(dir);}
string getLocalDir() { return _local_dir;} string getLocalDir() { return _local_dir;}
@ -334,6 +344,8 @@ private:
SGPath _persistentCachePath; SGPath _persistentCachePath;
string _httpServer; string _httpServer;
SGPath _installRoot; SGPath _installRoot;
string _sceneryVersion;
string _dnsdn;
TerrasyncThreadState _state; TerrasyncThreadState _state;
SGMutex _stateLock; SGMutex _stateLock;
@ -428,9 +440,8 @@ void SGTerraSync::WorkerThread::run()
if (_httpServer == "automatic" ) { if (_httpServer == "automatic" ) {
//TODO: make DN and service settable from properties DNS::NAPTRRequest * naptrRequest = new DNS::NAPTRRequest(_dnsdn);
DNS::NAPTRRequest * naptrRequest = new DNS::NAPTRRequest("terrasync.flightgear.org"); naptrRequest->qservice = _sceneryVersion;
naptrRequest->qservice = "ws20";
naptrRequest->qflags = "U"; naptrRequest->qflags = "U";
DNS::Request_ptr r(naptrRequest); DNS::Request_ptr r(naptrRequest);
@ -831,8 +842,14 @@ void SGTerraSync::reinit()
if (_terraRoot->getBoolValue("enabled",false)) if (_terraRoot->getBoolValue("enabled",false))
{ {
std::string httpServer(_terraRoot->getStringValue("http-server","")); _workerThread->setHTTPServer( _terraRoot->getStringValue("http-server","") );
_workerThread->setHTTPServer(httpServer); _workerThread->setSceneryVersion( _terraRoot->getStringValue("scenery-version","ws20") );
#if 1
// leave it hardcoded for now, not sure about the security implications for now
_workerThread->setDNSDN( "terrasync.flightgear.org");
#else
_workerThread->setDNSDN( _terraRoot->getStringValue("dnsdn","terrasync.flightgear.org") );
#endif
_workerThread->setLocalDir(_terraRoot->getStringValue("scenery-dir","")); _workerThread->setLocalDir(_terraRoot->getStringValue("scenery-dir",""));
SGPath installPath(_terraRoot->getStringValue("installation-dir")); SGPath installPath(_terraRoot->getStringValue("installation-dir"));