mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Add inject (undocumented in help) to NodeControlService.
This commit is contained in:
parent
351db7f1a0
commit
13fc20b0ee
1 changed files with 20 additions and 1 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "../node/Constants.hpp"
|
#include "../node/Constants.hpp"
|
||||||
|
#include "../node/MAC.hpp"
|
||||||
#include "NodeControlService.hpp"
|
#include "NodeControlService.hpp"
|
||||||
#include "NodeControlClient.hpp"
|
#include "NodeControlClient.hpp"
|
||||||
#include "../node/Node.hpp"
|
#include "../node/Node.hpp"
|
||||||
|
@ -118,6 +119,7 @@ void NodeControlService::_doCommand(IpcConnection *ipcc,const char *commandLine)
|
||||||
ipcc->printf("200 help leave <network ID>"ZT_EOL_S);
|
ipcc->printf("200 help leave <network ID>"ZT_EOL_S);
|
||||||
ipcc->printf("200 help terminate [<reason>]"ZT_EOL_S);
|
ipcc->printf("200 help terminate [<reason>]"ZT_EOL_S);
|
||||||
ipcc->printf("200 help updatecheck"ZT_EOL_S);
|
ipcc->printf("200 help updatecheck"ZT_EOL_S);
|
||||||
|
//ipcc->printf("200 help inject <network ID> <from MAC> <to MAC> <ethertype(hex)> <string>");
|
||||||
} else if (cmd[0] == "auth") {
|
} else if (cmd[0] == "auth") {
|
||||||
if ((cmd.size() > 1)&&(_authToken.length() > 0)&&(_authToken == cmd[1])) {
|
if ((cmd.size() > 1)&&(_authToken.length() > 0)&&(_authToken == cmd[1])) {
|
||||||
Mutex::Lock _l(_connections_m);
|
Mutex::Lock _l(_connections_m);
|
||||||
|
@ -227,12 +229,29 @@ void NodeControlService::_doCommand(IpcConnection *ipcc,const char *commandLine)
|
||||||
} else {
|
} else {
|
||||||
ipcc->printf("200 OK"ZT_EOL_S);
|
ipcc->printf("200 OK"ZT_EOL_S);
|
||||||
}
|
}
|
||||||
|
} else if (cmd[0] == "inject") {
|
||||||
|
if (cmd.size() >= 6) {
|
||||||
|
MAC from,to;
|
||||||
|
unsigned char from2[6];
|
||||||
|
unsigned char to2[6];
|
||||||
|
from.fromString(cmd[2].c_str());
|
||||||
|
to.fromString(cmd[3].c_str());
|
||||||
|
from.copyTo(from2,6);
|
||||||
|
to.copyTo(to2,6);
|
||||||
|
if (_node->injectPacketFromHost(Utils::hexStrToU64(cmd[1].c_str()),from2,to2,Utils::hexStrToUInt(cmd[4].c_str()),cmd[5].c_str(),cmd[5].length()+1)) {
|
||||||
|
ipcc->printf("200 OK"ZT_EOL_S);
|
||||||
|
} else {
|
||||||
|
ipcc->printf("500 inject failed or not supported by this tap device"ZT_EOL_S);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ipcc->printf("400 missing required arguments"ZT_EOL_S);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ipcc->printf("404 %s No such command. Use 'help' for help."ZT_EOL_S,cmd[0].c_str());
|
ipcc->printf("404 %s No such command. Use 'help' for help."ZT_EOL_S,cmd[0].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcc->printf("."ZT_EOL_S); // blank line ends response
|
ipcc->printf("."ZT_EOL_S);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
||||||
|
|
Loading…
Add table
Reference in a new issue