From c1ba9745384243dfd5dbf4731fe61e472fa05928 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Mon, 29 Aug 2016 21:00:03 +0200 Subject: [PATCH] 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 --- simgear/scene/tsync/terrasync.cxx | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/simgear/scene/tsync/terrasync.cxx b/simgear/scene/tsync/terrasync.cxx index 1f3f8d2b..521fb5a6 100644 --- a/simgear/scene/tsync/terrasync.cxx +++ b/simgear/scene/tsync/terrasync.cxx @@ -271,6 +271,16 @@ public: _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);} string getLocalDir() { return _local_dir;} @@ -334,6 +344,8 @@ private: SGPath _persistentCachePath; string _httpServer; SGPath _installRoot; + string _sceneryVersion; + string _dnsdn; TerrasyncThreadState _state; SGMutex _stateLock; @@ -428,9 +440,8 @@ void SGTerraSync::WorkerThread::run() if (_httpServer == "automatic" ) { - //TODO: make DN and service settable from properties - DNS::NAPTRRequest * naptrRequest = new DNS::NAPTRRequest("terrasync.flightgear.org"); - naptrRequest->qservice = "ws20"; + DNS::NAPTRRequest * naptrRequest = new DNS::NAPTRRequest(_dnsdn); + naptrRequest->qservice = _sceneryVersion; naptrRequest->qflags = "U"; DNS::Request_ptr r(naptrRequest); @@ -831,8 +842,14 @@ void SGTerraSync::reinit() if (_terraRoot->getBoolValue("enabled",false)) { - std::string httpServer(_terraRoot->getStringValue("http-server","")); - _workerThread->setHTTPServer(httpServer); + _workerThread->setHTTPServer( _terraRoot->getStringValue("http-server","") ); + _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","")); SGPath installPath(_terraRoot->getStringValue("installation-dir"));