diff --git a/README-Android.asciidoc b/README-Android.asciidoc index ba95f3e10..3b6a845a3 100644 --- a/README-Android.asciidoc +++ b/README-Android.asciidoc @@ -84,11 +84,6 @@ CONFIG+=no_retroshare_gui CONFIG+=no_retroshare_nogui CONFIG+=no_retroshare_plug WARNING: SQLCipher is not supported yet on RetroShare for Android. This poses a major security concern, we are working to fix this ASAP. -WARNING: DHT is not supported yet on RetroShare for Android. So don't be -surprised if you are not able to connect to dynamic IP trusted nodes after not -using the app for a relatively long time. Once this happens getting a fresh -certificate link from your friends should work around the issue. - TIP: Some versions of QtCreator try to find the Android SDK in +/opt/android/sdk+. A workaround to this is to make a symbolic link there pointing to your SDK installation path, like diff --git a/libbitdht/src/libbitdht.pro b/libbitdht/src/libbitdht.pro index 738deeab1..ad6986f32 100644 --- a/libbitdht/src/libbitdht.pro +++ b/libbitdht/src/libbitdht.pro @@ -46,6 +46,12 @@ unix { INSTALLS += data_files } +android-* { + # see https://community.kde.org/Necessitas/Assets + bdboot.files=bitdht/bdboot.txt + bdboot.path=/assets/values + INSTALLS += bdboot +} #################### Cross compilation for windows under Linux #################### diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index dae235aa2..76aa66c9a 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -35,6 +35,11 @@ #include "util/rswin.h" #endif +#ifdef __ANDROID__ +# include // To install bdboot.txt +# include // for String::fromStdString(...) +#endif + #include "util/argstream.h" #include "util/rsdebug.h" #include "util/rsdir.h" @@ -1042,7 +1047,32 @@ int RsServer::StartupRetroShare() uint64_t tmp_size ; if (!RsDirUtil::checkFile(bootstrapfile,tmp_size,true)) { - std::cerr << "DHT bootstrap file not in ConfigDir: " << bootstrapfile << std::endl; + std::cerr << "DHT bootstrap file not in ConfigDir: " << bootstrapfile + << std::endl; +#ifdef __ANDROID__ + QFile bdbootRF("assets:/values/bdboot.txt"); + if(!bdbootRF.open(QIODevice::ReadOnly | QIODevice::Text)) + std::cerr << __PRETTY_FUNCTION__ + << " bdbootRF(assets:/values/bdboot.txt).open(...) fail: " + << bdbootRF.errorString().toStdString() << std::endl; + else + { + QFile bdbootCF(QString::fromStdString(bootstrapfile)); + if(!bdbootCF.open(QIODevice::WriteOnly | QIODevice::Text)) + std::cerr << __PRETTY_FUNCTION__ << " bdbootCF(" + << bootstrapfile << ").open(...) fail: " + << bdbootRF.errorString().toStdString() << std::endl; + else + { + bdbootCF.write(bdbootRF.readAll()); + bdbootCF.close(); + std::cerr << "Installed DHT bootstrap file not in ConfigDir: " + << bootstrapfile << std::endl; + } + + bdbootRF.close(); + } +#else std::string installfile = rsAccounts->PathDataDirectory(); installfile += "/"; installfile += BITDHT_BOOTSTRAP_FILENAME; @@ -1064,6 +1094,7 @@ int RsServer::StartupRetroShare() { std::cerr << "No Installation DHT bootstrap file to copy" << std::endl; } +#endif // def __ANDROID__ } /* construct the rest of the stack, important to build them in the correct order! */