mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-18 20:47:53 +00:00
CLI work and Makefile cleanup.
This commit is contained in:
parent
8333bf065e
commit
13d5073e5b
@ -72,7 +72,7 @@ selftest: $(OBJS) selftest.o
|
||||
# ./buildinstaller.sh
|
||||
|
||||
clean:
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o build-* zerotier-one zerotier-idtool zerotier-selftest ZeroTierOneInstaller-*
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o build-* zerotier-one zerotier-idtool zerotier-selftest zerotier-cli ZeroTierOneInstaller-*
|
||||
|
||||
debug: FORCE
|
||||
make -j 4 ZT_DEBUG=1
|
||||
|
@ -77,7 +77,7 @@ installer: one FORCE
|
||||
./buildinstaller.sh
|
||||
|
||||
clean:
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm
|
||||
|
||||
debug: FORCE
|
||||
make -j 4 ZT_DEBUG=1
|
||||
|
@ -76,7 +76,7 @@ selftest: $(OBJS) selftest.o
|
||||
# $(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app"
|
||||
|
||||
clean:
|
||||
rm -rf *.dSYM build-* *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-selftest ZeroTierOneInstaller-*
|
||||
rm -rf *.dSYM build-* *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-selftest zerotier-cli ZeroTierOneInstaller-*
|
||||
|
||||
# For our use -- builds official signed binary, packages in installer and download DMG
|
||||
official: FORCE
|
||||
|
47
one.cpp
47
one.cpp
@ -298,7 +298,54 @@ static int cli(int argc,char **argv)
|
||||
return 1;
|
||||
}
|
||||
} else if (command == "join") {
|
||||
if (arg1.length() != 16) {
|
||||
cliPrintHelp(argv[0],stderr);
|
||||
return 2;
|
||||
}
|
||||
unsigned int scode = Http::POST(
|
||||
1024 * 1024 * 16,
|
||||
60000,
|
||||
(const struct sockaddr *)&addr,
|
||||
(std::string("/network/") + arg1).c_str(),
|
||||
requestHeaders,
|
||||
"",
|
||||
0,
|
||||
responseHeaders,
|
||||
responseBody);
|
||||
if (scode == 200) {
|
||||
if (json) {
|
||||
printf("%s",cliFixJsonCRs(responseBody).c_str());
|
||||
} else {
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str());
|
||||
return 1;
|
||||
}
|
||||
} else if (command == "leave") {
|
||||
if (arg1.length() != 16) {
|
||||
cliPrintHelp(argv[0],stderr);
|
||||
return 2;
|
||||
}
|
||||
unsigned int scode = Http::DELETE(
|
||||
1024 * 1024 * 16,
|
||||
60000,
|
||||
(const struct sockaddr *)&addr,
|
||||
(std::string("/network/") + arg1).c_str(),
|
||||
requestHeaders,
|
||||
responseHeaders,
|
||||
responseBody);
|
||||
if (scode == 200) {
|
||||
if (json) {
|
||||
printf("%s",cliFixJsonCRs(responseBody).c_str());
|
||||
} else {
|
||||
printf("200 leave OK"ZT_EOL_S);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str());
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
cliPrintHelp(argv[0],stderr);
|
||||
return 0;
|
||||
|
@ -82,6 +82,35 @@ public:
|
||||
responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make HTTP DELETE request
|
||||
*
|
||||
* The caller must set all headers, including Host.
|
||||
*
|
||||
* @return HTTP status code or 0 on error (responseBody will contain error message)
|
||||
*/
|
||||
static inline unsigned int DELETE(
|
||||
unsigned long maxResponseSize,
|
||||
unsigned long timeout,
|
||||
const struct sockaddr *remoteAddress,
|
||||
const char *path,
|
||||
const std::map<std::string,std::string> &requestHeaders,
|
||||
std::map<std::string,std::string> &responseHeaders,
|
||||
std::string &responseBody)
|
||||
{
|
||||
return _do(
|
||||
"DELETE",
|
||||
maxResponseSize,
|
||||
timeout,
|
||||
remoteAddress,
|
||||
path,
|
||||
requestHeaders,
|
||||
(const void *)0,
|
||||
0,
|
||||
responseHeaders,
|
||||
responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make HTTP POST request
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user