issue 547 make format

This commit is contained in:
Ryan Tharp 2019-04-23 14:57:01 -07:00
parent 8cf6a77c1d
commit b36b378583
2 changed files with 23 additions and 21 deletions

View File

@ -117,7 +117,7 @@ main(int argc, char *argv[])
("config","path to configuration file", cxxopts::value<std::string>());
options.parse_positional("config");
// clang-format on
// clang-format on
bool genconfigOnly = false;
bool asRouter = false;
@ -154,7 +154,7 @@ main(int argc, char *argv[])
asRouter = true;
}
if(result.count("config") > 0)
if(result.count("config") > 0)
{
auto arg = result["config"].as< std::string >();
if(!arg.empty())
@ -163,7 +163,7 @@ main(int argc, char *argv[])
}
}
}
catch (const cxxopts::option_not_exists_exception& ex)
catch(const cxxopts::option_not_exists_exception &ex)
{
std::cerr << ex.what();
return printHelp(argv[0]);
@ -186,8 +186,8 @@ main(int argc, char *argv[])
// does this file exist?
if(genconfigOnly)
{
if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(), overWrite,
asRouter))
if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(),
overWrite, asRouter))
return 1;
}
else

View File

@ -94,7 +94,8 @@ namespace llarp
} // namespace llarp
/// fname should be a relative path (from CWD) or absolute path to the config file
/// fname should be a relative path (from CWD) or absolute path to the config
/// file
extern "C" bool
llarp_ensure_config(const char *fname, const char *basedir, bool overwrite,
bool asRouter)
@ -128,8 +129,7 @@ llarp_ensure_config(const char *fname, const char *basedir, bool overwrite,
{
if(fs::exists(fname, ec) && !overwrite)
{
llarp::LogError(
fname, " currently exists, please use -f to overwrite");
llarp::LogError(fname, " currently exists, please use -f to overwrite");
return true;
}
if(ec)
@ -247,8 +247,8 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath)
f << "# if we don't have any peers we connect to this router" << std::endl;
f << "add-node=" << basepath << "bootstrap.signed" << std::endl;
// we only process one of these...
//f << "# add another bootstrap node" << std::endl;
//f << "#add-node=/path/to/alternative/self.signed" << std::endl;
// f << "# add another bootstrap node" << std::endl;
// f << "#add-node=/path/to/alternative/self.signed" << std::endl;
f << std::endl << std::endl;
}
@ -294,7 +294,7 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath)
const std::string snappExample_fpath = basepath + "snapp-example.ini";
{
std::ofstream example_f(snappExample_fpath,
std::ios::binary | std::ios::out);
std::ios::binary | std::ios::out);
if(f.is_open())
{
// pick ip
@ -302,23 +302,25 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath)
if(ip == "")
{
llarp::LogError(
"Couldn't easily detect a private range to map lokinet onto");
"Couldn't easily detect a private range to map lokinet onto");
return false;
}
example_f << "# this is an example configuration for a snapp"
<< std::endl;
<< std::endl;
example_f << "[example-snapp]" << std::endl;
example_f << "# keyfile is the path to the private key of the snapp, your .loki is tied to this key, DON'T LOSE IT"
<< std::endl;
example_f << "# keyfile is the path to the private key of the snapp, "
"your .loki is tied to this key, DON'T LOSE IT"
<< std::endl;
example_f << "keyfile=" << basepath << "example-snap-keyfile.private"
<< std::endl;
<< std::endl;
example_f << "# ifaddr is the ip range to allocate to this snapp"
<< std::endl;
<< std::endl;
example_f << "ifaddr=" << ip << std::endl;
// probably fine to leave this (and not-auto-detect it) I'm not worried about any collisions
// probably fine to leave this (and not-auto-detect it) I'm not worried
// about any collisions
example_f << "# ifname is the name to try and give to the network "
"interface this snap owns"
<< std::endl;
"interface this snap owns"
<< std::endl;
example_f << "ifname=snapp-tun0" << std::endl;
}
else
@ -349,7 +351,7 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath)
// operating environment may change over time and this will help adapt
f << "ifname=auto" << std::endl;
f << "ifaddr=auto" << std::endl;
// should this also be auto? or not declared?
// probably auto in case they want to set up a hidden service
f << "enabled=true" << std::endl;