mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
Merge remote-tracking branch 'origin/stable' into ubuntu/bionic
This commit is contained in:
commit
ff2ef1780d
@ -9,6 +9,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
@ -28,6 +29,26 @@ namespace
|
|||||||
std::cout << msg << std::endl;
|
std::cout << msg << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
print_help(std::string exe)
|
||||||
|
{
|
||||||
|
std::cout << R"(Lokinet bootstrap.signed fetchy program thing
|
||||||
|
|
||||||
|
Downloads the initial bootstrap.signed for lokinet into a local file from a
|
||||||
|
default or user defined server via the reachable network.
|
||||||
|
|
||||||
|
Usage: )" << exe
|
||||||
|
<< R"( [bootstrap_url [output_file]]
|
||||||
|
|
||||||
|
bootstrap_url can be specified as a full URL, or a special named value
|
||||||
|
("mainnet" or "testnet") to download from the pre-defined mainnet or testnet
|
||||||
|
bootstrap URLs.
|
||||||
|
|
||||||
|
)";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -42,6 +63,15 @@ main(int argc, char* argv[])
|
|||||||
std::string bootstrap_url = bootstrap_urls.at("lokinet");
|
std::string bootstrap_url = bootstrap_urls.at("lokinet");
|
||||||
fs::path outputfile{llarp::GetDefaultBootstrap()};
|
fs::path outputfile{llarp::GetDefaultBootstrap()};
|
||||||
|
|
||||||
|
const std::unordered_set<std::string> help_args = {"-h", "--help"};
|
||||||
|
|
||||||
|
for (int idx = 1; idx < argc; idx++)
|
||||||
|
{
|
||||||
|
const std::string arg{argv[idx]};
|
||||||
|
if (help_args.count(arg))
|
||||||
|
return print_help(argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
if (auto itr = bootstrap_urls.find(argv[1]); itr != bootstrap_urls.end())
|
if (auto itr = bootstrap_urls.find(argv[1]); itr != bootstrap_urls.end())
|
||||||
@ -57,7 +87,7 @@ main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
outputfile = fs::path{argv[2]};
|
outputfile = fs::path{argv[2]};
|
||||||
}
|
}
|
||||||
|
std::cout << "fetching " << bootstrap_url << std::endl;
|
||||||
cpr::Response resp =
|
cpr::Response resp =
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cpr::Get(
|
cpr::Get(
|
||||||
@ -79,6 +109,7 @@ main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
std::cout << "writing bootstrap file to: " << outputfile << std::endl;
|
||||||
fs::ofstream ofs{outputfile, std::ios::binary};
|
fs::ofstream ofs{outputfile, std::ios::binary};
|
||||||
ofs.exceptions(fs::ofstream::failbit);
|
ofs.exceptions(fs::ofstream::failbit);
|
||||||
ofs << data;
|
ofs << data;
|
||||||
|
Loading…
Reference in New Issue
Block a user