mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-06 02:28:23 +00:00
Fix command line interface.
This commit is contained in:
parent
4e26ade2df
commit
d9b91758e0
10
main.cpp
10
main.cpp
@ -116,9 +116,11 @@ static void printHelp(FILE *out,const char *cn)
|
|||||||
|
|
||||||
static void _CBresultHandler(void *arg,const char *line)
|
static void _CBresultHandler(void *arg,const char *line)
|
||||||
{
|
{
|
||||||
if ((line)&&(line[0])) {
|
if (line) {
|
||||||
fprintf(stdout,"%s"ZT_EOL_S,line);
|
if ((line[0] == '.')&&(line[1] == (char)0))
|
||||||
} else *((bool *)arg) = true;
|
*((bool *)arg) = true;
|
||||||
|
else fprintf(stdout,"%s"ZT_EOL_S,line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
@ -160,7 +162,7 @@ static int main(int argc,char **argv)
|
|||||||
}
|
}
|
||||||
client.send(query.c_str());
|
client.send(query.c_str());
|
||||||
while (!done)
|
while (!done)
|
||||||
Thread::sleep(250); // ghetto
|
Thread::sleep(100); // ghetto
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
fprintf(stderr,"%s: fatal error: unable to connect (is ZeroTier One running?)"ZT_EOL_S,argv[0]);
|
fprintf(stderr,"%s: fatal error: unable to connect (is ZeroTier One running?)"ZT_EOL_S,argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -90,8 +90,10 @@ struct _NodeControlClientImpl
|
|||||||
|
|
||||||
static void _CBipcResultHandler(void *arg,IpcConnection *ipcc,IpcConnection::EventType event,const char *result)
|
static void _CBipcResultHandler(void *arg,IpcConnection *ipcc,IpcConnection::EventType event,const char *result)
|
||||||
{
|
{
|
||||||
if ((event == IpcConnection::IPC_EVENT_COMMAND)&&(result))
|
if ((event == IpcConnection::IPC_EVENT_COMMAND)&&(result)) {
|
||||||
|
if (strcmp(result,"200 auth OK"))
|
||||||
((_NodeControlClientImpl *)arg)->resultHandler(((_NodeControlClientImpl *)arg)->arg,result);
|
((_NodeControlClientImpl *)arg)->resultHandler(((_NodeControlClientImpl *)arg)->arg,result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::NodeControlClient::NodeControlClient(const char *hp,void (*resultHandler)(void *,const char *),void *arg,const char *authToken)
|
Node::NodeControlClient::NodeControlClient(const char *hp,void (*resultHandler)(void *,const char *),void *arg,const char *authToken)
|
||||||
|
@ -195,12 +195,12 @@ void NodeConfig::_doCommand(IpcConnection *ipcc,const char *commandLine)
|
|||||||
Mutex::Lock _l(_connections_m);
|
Mutex::Lock _l(_connections_m);
|
||||||
_connections[ipcc] = true;
|
_connections[ipcc] = true;
|
||||||
ipcc->printf("200 auth OK"ZT_EOL_S);
|
ipcc->printf("200 auth OK"ZT_EOL_S);
|
||||||
} else ipcc->printf("403 auth FAILED"ZT_EOL_S);
|
} else ipcc->printf("403 auth failed"ZT_EOL_S);
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_connections_m);
|
Mutex::Lock _l(_connections_m);
|
||||||
if (!_connections[ipcc]) {
|
if (!_connections[ipcc]) {
|
||||||
ipcc->printf("403 not authorized"ZT_EOL_S""ZT_EOL_S);
|
ipcc->printf("403 %s unauthorized"ZT_EOL_S"."ZT_EOL_S,cmd[0].c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ void NodeConfig::_doCommand(IpcConnection *ipcc,const char *commandLine)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcc->printf(ZT_EOL_S); // blank line ends response
|
ipcc->printf("."ZT_EOL_S); // blank line ends response
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeConfig::_readLocalConfig()
|
void NodeConfig::_readLocalConfig()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user