mirror of https://github.com/infosecn1nja/C3.git
Add creating complementary channel
parent
7747a637a8
commit
bac6392961
|
@ -68,6 +68,11 @@ try
|
|||
auto createParams = form.FillForm(config.m_ChannelArguments);
|
||||
auto channel = C3::Linter::MakeDevice(createParams, chInfo);
|
||||
|
||||
std::cout << "Create channel 2" << std::endl;
|
||||
auto const& ch2Args = config.m_ComplementaryChannelArguments ? *config.m_ComplementaryChannelArguments : form.GetComplementaryArgs(createParams);
|
||||
json createParams2 = form.FillForm(ch2Args);
|
||||
auto ch2 = C3::Linter::MakeDevice(createParams2, chInfo);
|
||||
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
|
|
|
@ -36,4 +36,25 @@ namespace MWR::C3::Linter
|
|||
throw std::runtime_error("Failed to create channel: not enough arguments given");
|
||||
}
|
||||
}
|
||||
|
||||
StringVector Form::GetComplementaryArgs(json const& form)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
for (auto const& arg : form)
|
||||
{
|
||||
if (arg.is_array())
|
||||
{
|
||||
for (size_t j = 0; j < arg.size(); ++j)
|
||||
{
|
||||
auto rotateRight = [s = arg.size()](size_t index) { return (index + 1) % s; };
|
||||
args.emplace_back(arg[rotateRight(j)].at("value").get<std::string>());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args.emplace_back(arg["value"].get<std::string>());
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace MWR::C3::Linter
|
|||
|
||||
json FillForm(InputVector input);
|
||||
|
||||
StringVector GetComplementaryArgs(json const& form);
|
||||
|
||||
private:
|
||||
json m_ArgumentsForm;
|
||||
};
|
||||
|
|
|
@ -10,6 +10,10 @@ namespace MWR::C3::Linter
|
|||
InputContext::Config config;
|
||||
config.m_ChannelName = parser.retrieve<std::string>("name");
|
||||
config.m_ChannelArguments = parser.retrieve<std::vector<std::string>>("args");
|
||||
|
||||
if (parser.exists("complementary"))
|
||||
config.m_ComplementaryChannelArguments = parser.retrieve<std::vector<std::string>>("complementary");
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +29,7 @@ namespace MWR::C3::Linter
|
|||
{
|
||||
m_ArgParser.addArgument("-n", "--name", 1, false);
|
||||
m_ArgParser.addArgument("-a", "--args", '*', false);
|
||||
|
||||
m_ArgParser.addArgument("-c", "--complementary", '*');
|
||||
}
|
||||
|
||||
std::string InputContext::GetUsage()
|
||||
|
|
Loading…
Reference in New Issue