partial implementation of android direct-call API -- still has path problems
This commit is contained in:
@@ -94,7 +94,8 @@ void zt_init_rpc(const char * path, const char * nwid);
|
||||
|
||||
//zt1Service->join(nwid);
|
||||
LOGV("started up\n");
|
||||
//zt_init_rpc(homeDir.c_str(), nwid); // This provides the shim API with the RPC information
|
||||
// This provides the shim API with the RPC information
|
||||
zt_init_rpc(homeDir.c_str(), nwid);
|
||||
}
|
||||
|
||||
void leave_network(const char *nwid) { zt1Service->leave(nwid); }
|
||||
@@ -175,7 +176,7 @@ void zt_init_rpc(const char * path, const char * nwid);
|
||||
void *startOneService(void *thread_id) {
|
||||
#endif
|
||||
|
||||
#if defined(SDK_BUNDLED)
|
||||
#if defined(SDK_BUNDLED) && !defined(__ANDROID__)
|
||||
// Don't intercept network calls originating from ZeroTier service
|
||||
set_intercept_status(INTERCEPT_DISABLED);
|
||||
#endif
|
||||
@@ -196,11 +197,6 @@ void zt_init_rpc(const char * path, const char * nwid);
|
||||
homeDir = current_dir; // homeDir shall be current dir
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
homeDir = "/sdcard/zerotier";
|
||||
join_network("565799d8f65063e5");
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
@@ -211,6 +207,15 @@ void zt_init_rpc(const char * path, const char * nwid);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
/* NOTE: Since on Android devices the sdcard is formatted as fat32, we can't use this
|
||||
location to set up the RPC unix domain socket. Rather we must use the application's
|
||||
specific data directory given by getApplicationContext().getFilesDir() */
|
||||
//rpcDir = homeDir; // Take given homeDir as rpcDir
|
||||
//homeDir = "/sdcard/zerotier"; // Use fat32-formatted sdcard for writing network conf & supporting files
|
||||
//join_network("565799d8f65063e5");
|
||||
#endif
|
||||
|
||||
LOGV("homeDir = %s", homeDir.c_str());
|
||||
// Where network .conf files will be stored
|
||||
netDir = homeDir + "/networks.d";
|
||||
@@ -225,8 +230,7 @@ void zt_init_rpc(const char * path, const char * nwid);
|
||||
return NULL;
|
||||
#endif
|
||||
} else {
|
||||
LOGV("constructing path...\n");
|
||||
|
||||
LOGV("startOneService(): constructing path...\n");
|
||||
std::vector<std::string> hpsp(ZeroTier::Utils::split(homeDir.c_str(),ZT_PATH_SEPARATOR_S,"",""));
|
||||
std::string ptmp;
|
||||
if (homeDir[0] == ZT_PATH_SEPARATOR)
|
||||
@@ -237,28 +241,22 @@ void zt_init_rpc(const char * path, const char * nwid);
|
||||
ptmp.append(*pi);
|
||||
if ((*pi != ".")&&(*pi != "..")) {
|
||||
if (!ZeroTier::OSUtils::mkdir(ptmp)) {
|
||||
std::string homePathErrStr = "home path does not exist, and could not create";
|
||||
throw std::runtime_error(homePathErrStr);
|
||||
LOGV("startOneService(): home path does not exist, and could not create\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//chdir(current_dir); // Return to previous current working directory (at the request of Unity3D)
|
||||
|
||||
//Debug(homeDir.c_str());
|
||||
|
||||
// Generate random port for new service instance
|
||||
unsigned int randp = 0;
|
||||
ZeroTier::Utils::getSecureRandom(&randp,sizeof(randp));
|
||||
int servicePort = 9000 + (randp % 1000);
|
||||
|
||||
LOGV("generated port\n");
|
||||
|
||||
|
||||
for(;;) {
|
||||
zt1Service = ZeroTier::OneService::newInstance(homeDir.c_str(),servicePort);
|
||||
LOGV("created new instance\n");
|
||||
|
||||
switch(zt1Service->run()) {
|
||||
case ZeroTier::OneService::ONE_STILL_RUNNING: // shouldn't happen, run() won't return until done
|
||||
case ZeroTier::OneService::ONE_NORMAL_TERMINATION:
|
||||
|
||||
Reference in New Issue
Block a user