mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
More IPC work.
This commit is contained in:
parent
0d847d9410
commit
6fdb360e2a
4 changed files with 22 additions and 6 deletions
4
main.cpp
4
main.cpp
|
@ -154,6 +154,10 @@ static int main(int argc,char **argv)
|
||||||
try {
|
try {
|
||||||
volatile bool done = false;
|
volatile bool done = false;
|
||||||
Node::NodeControlClient client(hp,&_CBresultHandler,(void *)&done);
|
Node::NodeControlClient client(hp,&_CBresultHandler,(void *)&done);
|
||||||
|
if (client.error()) {
|
||||||
|
fprintf(stderr,"%s: fatal error: unable to connect (is ZeroTier One running?)"ZT_EOL_S,argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
client.send(query.c_str());
|
client.send(query.c_str());
|
||||||
while (!done)
|
while (!done)
|
||||||
Thread::sleep(250); // ghetto
|
Thread::sleep(250); // ghetto
|
||||||
|
|
|
@ -23,12 +23,12 @@ endif
|
||||||
#DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
|
#DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
|
||||||
|
|
||||||
# Uncomment for a release optimized universal binary build
|
# Uncomment for a release optimized universal binary build
|
||||||
CFLAGS=-arch i386 -arch x86_64 -Wall -O3 -flto -fPIE -fvectorize -fstack-protector -pthread -mmacosx-version-min=10.6 -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS)
|
#CFLAGS=-arch i386 -arch x86_64 -Wall -O3 -flto -fPIE -fvectorize -fstack-protector -pthread -mmacosx-version-min=10.6 -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS)
|
||||||
STRIP=strip
|
#STRIP=strip
|
||||||
|
|
||||||
# Uncomment for a debug build
|
# Uncomment for a debug build
|
||||||
#CFLAGS=-Wall -g -pthread -DZT_TRACE -DZT_LOG_STDOUT $(INCLUDES) $(DEFS)
|
CFLAGS=-Wall -g -pthread -DZT_TRACE -DZT_LOG_STDOUT $(INCLUDES) $(DEFS)
|
||||||
#STRIP=echo
|
STRIP=echo
|
||||||
|
|
||||||
CXXFLAGS=$(CFLAGS) -fno-rtti
|
CXXFLAGS=$(CFLAGS) -fno-rtti
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,7 @@ Node::NodeControlClient::NodeControlClient(const char *hp,void (*resultHandler)(
|
||||||
_impl((void *)new _NodeControlClientImpl)
|
_impl((void *)new _NodeControlClientImpl)
|
||||||
{
|
{
|
||||||
_NodeControlClientImpl *impl = (_NodeControlClientImpl *)_impl;
|
_NodeControlClientImpl *impl = (_NodeControlClientImpl *)_impl;
|
||||||
|
impl->ipcc = (IpcConnection *)0;
|
||||||
|
|
||||||
if (!hp)
|
if (!hp)
|
||||||
hp = ZT_DEFAULTS.defaultHomePath.c_str();
|
hp = ZT_DEFAULTS.defaultHomePath.c_str();
|
||||||
|
@ -121,6 +122,7 @@ Node::NodeControlClient::NodeControlClient(const char *hp,void (*resultHandler)(
|
||||||
impl->ipcc = new IpcConnection((std::string(ZT_IPC_ENDPOINT_BASE) + myaddr).c_str(),&_CBipcResultHandler,_impl);
|
impl->ipcc = new IpcConnection((std::string(ZT_IPC_ENDPOINT_BASE) + myaddr).c_str(),&_CBipcResultHandler,_impl);
|
||||||
impl->ipcc->printf("auth %s"ZT_EOL_S,at.c_str());
|
impl->ipcc->printf("auth %s"ZT_EOL_S,at.c_str());
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
|
impl->ipcc = (IpcConnection *)0;
|
||||||
impl->err = "failure connecting to running ZeroTier One service";
|
impl->err = "failure connecting to running ZeroTier One service";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,11 +138,20 @@ Node::NodeControlClient::~NodeControlClient()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *Node::NodeControlClient::error() const
|
||||||
|
throw()
|
||||||
|
{
|
||||||
|
if (((_NodeControlClientImpl *)_impl)->err.length())
|
||||||
|
return ((_NodeControlClientImpl *)_impl)->err.c_str();
|
||||||
|
return (const char *)0;
|
||||||
|
}
|
||||||
|
|
||||||
void Node::NodeControlClient::send(const char *command)
|
void Node::NodeControlClient::send(const char *command)
|
||||||
throw()
|
throw()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
((_NodeControlClientImpl *)_impl)->ipcc->printf("%s"ZT_EOL_S,command);
|
if (((_NodeControlClientImpl *)_impl)->ipcc)
|
||||||
|
((_NodeControlClientImpl *)_impl)->ipcc->printf("%s"ZT_EOL_S,command);
|
||||||
} catch ( ... ) {}
|
} catch ( ... ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* @return Initialization error or NULL if none
|
* @return Initialization error or NULL if none
|
||||||
*/
|
*/
|
||||||
const char *error() const;
|
const char *error() const
|
||||||
|
throw();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a command to the local node
|
* Send a command to the local node
|
||||||
|
|
Loading…
Add table
Reference in a new issue