mirror of
https://github.com/PurpleI2P/i2pd-tools
synced 2025-01-15 17:20:08 +00:00
[AutoConf] FirstSection
This commit is contained in:
parent
35a2e59dc7
commit
205f7c61ae
77
autoconf.cpp
77
autoconf.cpp
@ -41,7 +41,7 @@ const std::map<std::string, AsksT> Texts = // maybe vector better
|
|||||||
//TODO: an another
|
//TODO: an another
|
||||||
{"UseIPv6", "Использовать ipv6?"},
|
{"UseIPv6", "Использовать ipv6?"},
|
||||||
{"UseIPv4", "Использовать ipv4?"},
|
{"UseIPv4", "Использовать ipv4?"},
|
||||||
{"BeFloodfill", "Быть флудфиллом?"},
|
{"BeFloodfillYN", "Быть флудфиллом?"},
|
||||||
{"NoTransit", "Отключить транзит? (это уменьшит анонимность)"}
|
{"NoTransit", "Отключить транзит? (это уменьшит анонимность)"}
|
||||||
}},
|
}},
|
||||||
{"en", {
|
{"en", {
|
||||||
@ -66,7 +66,7 @@ const std::map<std::string, AsksT> Texts = // maybe vector better
|
|||||||
//TODO: an another
|
//TODO: an another
|
||||||
{"UseIPv6", "Use ipv6?"},
|
{"UseIPv6", "Use ipv6?"},
|
||||||
{"UseIPv4", "Use ipv4?"},
|
{"UseIPv4", "Use ipv4?"},
|
||||||
{"BeFloodfill", "Be a floodfill?"},
|
{"BeFloodfillYN", "Be a floodfill?"},
|
||||||
{"NoTransit", "Disable transit? (this will reduce anonymity)"}
|
{"NoTransit", "Disable transit? (this will reduce anonymity)"}
|
||||||
}}
|
}}
|
||||||
};
|
};
|
||||||
@ -130,41 +130,60 @@ main(void) {
|
|||||||
// Asks
|
// Asks
|
||||||
using namespace AutoConf;
|
using namespace AutoConf;
|
||||||
[](std::ostringstream &conf, const std::string &lang) {
|
[](std::ostringstream &conf, const std::string &lang) {
|
||||||
std::cout << AutoConf::Texts.at(lang).at("TunConfYN") << std::endl;
|
|
||||||
if (AskYN()) {
|
|
||||||
std::cout << AutoConf::Texts.at(lang).at("TunConf") << "\r\n";
|
|
||||||
std::string tunConf;
|
|
||||||
std::cin.ignore();
|
|
||||||
std::getline(std::cin, tunConf);
|
|
||||||
conf << "tunnels.path=" << tunConf << "\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << AutoConf::Texts.at(lang).at("TunnelsDirYN") << std::endl;
|
|
||||||
if (AskYN()) {
|
|
||||||
std::cout << AutoConf::Texts.at(lang).at("TunnelsDir") << "\r\n";
|
|
||||||
std::string tunnelsDir;
|
|
||||||
std::cin.ignore();
|
|
||||||
std::getline(std::cin, tunnelsDir);
|
|
||||||
conf << "tunnels.dir=" << tunnelsDir << "\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#define ASKYN_MACRO(A,B,C) { \
|
||||||
|
std::cout << AutoConf::Texts.at(lang).at(A) << std::endl; \
|
||||||
|
if(AskYN()) { \
|
||||||
|
std::cout << AutoConf::Texts.at(lang).at(B) << "\r\n"; \
|
||||||
|
std::string inp; \
|
||||||
|
std::cin.ignore(); \
|
||||||
|
std::getline(std::cin, inp); \
|
||||||
|
conf << C "=" << inp << "\r\n"; \
|
||||||
|
} \
|
||||||
|
};
|
||||||
|
ASKYN_MACRO("TunConfYN","TunConf","tunconf");
|
||||||
|
ASKYN_MACRO("TunnelsDirYN","TunnelsDir","tunnelsdir");
|
||||||
// TODO:
|
// TODO:
|
||||||
{
|
/*
|
||||||
std::cout << AutoConf::Texts.at(lang).at("UseIPv6") << "\r\n";
|
{"daemonYN", "Use daemon mode?"},
|
||||||
bool useIPv6 = AskYN();
|
{"FamilyUsing", "Enter your last name or just hit enter."},
|
||||||
conf << "ipv6=" << (useIPv6 ? "true" : "false") << "\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
*/
|
||||||
std::cout << AutoConf::Texts.at(lang).at("UseIPv4") << "\r\n";
|
ASKYN_MACRO("certsdirYN","certsdir","certsdir");
|
||||||
bool useIPv4 = AskYN();
|
ASKYN_MACRO("pidfileYN","pidfile","pidfile");
|
||||||
conf << "ipv4=" << (useIPv4 ? "true" : "false") << "\r\n";
|
ASKYN_MACRO("logYN","log","log");
|
||||||
|
ASKYN_MACRO("loglevelYN","loglevel","loglevel");
|
||||||
|
#define ASK_BOOL(A,B) { \
|
||||||
|
std::cout << AutoConf::Texts.at(lang).at(A) << std::endl; \
|
||||||
|
bool v = AskYN();\
|
||||||
|
conf << B "=" << (v ? "true":"false") << "\r\n";\
|
||||||
}
|
}
|
||||||
|
ASK_BOOL("UseIPv6", "ipv6");
|
||||||
|
ASK_BOOL("UseIPv4", "ipv4");
|
||||||
|
ASK_BOOL("logCFLYN", "logclftime");
|
||||||
|
ASK_BOOL("daemonYN", "daemon");
|
||||||
|
#define ASK_TEXT(A, B) {\
|
||||||
|
std::cout << AutoConf::Texts.at(lang).at(A) << std::endl;\
|
||||||
|
std::string inp; std::cin.ignore(); std::getline(std::cin, inp);; if (inp.length() != 0) {\
|
||||||
|
conf << B "=" << inp << "\r\n";\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
ASK_TEXT("FamilyUsing","family");
|
||||||
|
ASK_BOOL("BeFloodfillYN", "floodflill");
|
||||||
|
|
||||||
|
/////
|
||||||
}(conf, lang);
|
}(conf, lang);
|
||||||
}
|
}
|
||||||
std::cout << "Config: " << std::endl;
|
std::cout << "Config: " << std::endl;
|
||||||
std::cout << conf.str() << std::endl;
|
std::cout << conf.str() << std::endl;
|
||||||
std::ofstream confFile("i2pd_.conf");
|
//TODO: To Constexpr
|
||||||
|
std::cout << "Save File: (\"i2pd_.conf\"):";
|
||||||
|
std::string outFileName;
|
||||||
|
std::cin.ignore(); //maybe not need write everywhere cin.ignore() one time maybe will be enough
|
||||||
|
std::getline(std::cin, outFileName);
|
||||||
|
//TODO: to constxpr
|
||||||
|
if (outFileName.length() == 0) outFileName = "i2pd_.conf";
|
||||||
|
std::ofstream confFile(outFileName);
|
||||||
confFile << conf.str();
|
confFile << conf.str();
|
||||||
confFile.close();
|
confFile.close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user