reformated output of main
This commit is contained in:
parent
1c752847d9
commit
3971a8ab24
17
src/main.cpp
17
src/main.cpp
@ -9,7 +9,9 @@ int main(int argc, char *argv[]) {
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
std::string firstarg(argv[1]);
|
std::string firstarg(argv[1]);
|
||||||
if (firstarg == "-h" || firstarg == "--help") {
|
if (firstarg == "-h" || firstarg == "--help") {
|
||||||
std::cout << "help page: " << std::endl << "[-h] [--help] print this help page" << std::endl << "[-v] [--version] print the software version" <<std::endl << "[no argument] normal ip check and refresh" << std::endl;
|
std::cout << "help page: " << std::endl << "[-h] [--help] print this help page" << std::endl
|
||||||
|
<< "[-v] [--version] print the software version" << std::endl
|
||||||
|
<< "[no argument] normal ip check and refresh" << std::endl;
|
||||||
} else if (firstarg == "-v" || firstarg == "--version") {
|
} else if (firstarg == "-v" || firstarg == "--version") {
|
||||||
std::cout << "Version 1.0" << std::endl;
|
std::cout << "Version 1.0" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
@ -19,36 +21,35 @@ int main(int argc, char *argv[]) {
|
|||||||
API api;
|
API api;
|
||||||
Logger logger;
|
Logger logger;
|
||||||
|
|
||||||
|
|
||||||
std::string ip = api.request("https://api.ipify.org");
|
std::string ip = api.request("https://api.ipify.org");
|
||||||
|
|
||||||
if (ip == "") {
|
if (ip == "") {
|
||||||
//no internet connection
|
//no internet connection
|
||||||
logger.logToLogfile("[WARNING] no internet connection");
|
logger.logToLogfile("[WARNING] no internet connection");
|
||||||
std::cout << "[WARNING] no internet connection" << std::endl;
|
std::cout << "[WARNING] no internet connection" << std::endl;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::string oldip = logger.readip();
|
std::string oldip = logger.readip();
|
||||||
|
|
||||||
if (oldip == ip) {
|
if (oldip == ip) {
|
||||||
std::cout << "no change -- ip: " << ip << std::endl;
|
std::cout << "[INFO] no change -- ip: " << ip << std::endl;
|
||||||
logger.logToLogfile(" [INFO] no change -- ip: " + ip);
|
logger.logToLogfile(" [INFO] no change -- ip: " + ip);
|
||||||
} else {
|
} else {
|
||||||
logger.logToLogfile(" [INFO] ip changed! -- from :" + oldip + "to: " + ip);
|
logger.logToLogfile(" [INFO] ip changed! -- from :" + oldip + "to: " + ip);
|
||||||
std::cout << "ip changed! -- from :" << oldip << "to: " << ip << std::endl;
|
std::cout << "[INFO] ip changed! -- from :" << oldip << "to: " << ip << std::endl;
|
||||||
|
|
||||||
//dynu api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg
|
static std::string dynuapikey = "88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg";
|
||||||
|
|
||||||
static std::string domainid = "8506047"; //id of the dynu domain
|
static std::string domainid = "8506047"; //id of the dynu domain
|
||||||
|
static std::string domainname = "luki.dynu.net";
|
||||||
|
|
||||||
Hashmap<std::string, std::string> args;
|
Hashmap<std::string, std::string> args;
|
||||||
args.add("name", "luki.dynu.net");
|
args.add("name", domainname);
|
||||||
args.add("ipv4Address", ip);
|
args.add("ipv4Address", ip);
|
||||||
|
|
||||||
std::vector<std::string> headers;
|
std::vector<std::string> headers;
|
||||||
headers.push_back("accept: application/json");
|
headers.push_back("accept: application/json");
|
||||||
headers.push_back("User-Agent: Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)");
|
headers.push_back("User-Agent: Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)");
|
||||||
headers.push_back("API-Key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg");
|
headers.push_back("API-Key: " + dynuapikey);
|
||||||
|
|
||||||
std::string dynurepl = api.request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers);
|
std::string dynurepl = api.request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user