Merge pull request #7 from Lukas-Heiligenbrunner/currentipparameter

added option to get current global ip
This commit is contained in:
Lukas-Heiligenbrunner 2020-05-05 15:57:16 +02:00 committed by GitHub
commit 8a9c39051d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,8 @@
#include <Config.h> #include <Config.h>
#include <iostream> #include <iostream>
#include <api/IPAPI.h>
/** /**
* application entry point * application entry point
*/ */
@ -20,6 +22,7 @@ int main(int argc, char *argv[]) {
<< "[-f] [--force] force refresh of ip" << std::endl << "[-f] [--force] force refresh of ip" << std::endl
<< "[-l] [--loop] infinite loop to refresh ip every five minutes" << std::endl << "[-l] [--loop] infinite loop to refresh ip every five minutes" << std::endl
<< "[-c] [--checkconfig] validate configuration" << std::endl << "[-c] [--checkconfig] validate configuration" << std::endl
<< "[-ip] [--currentip] get current global ip" << std::endl
<< "[no argument] normal ip check and refresh" << 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 " << Version::VERSION << std::endl; std::cout << "Version " << Version::VERSION << std::endl;
@ -40,6 +43,9 @@ int main(int argc, char *argv[]) {
Logger::warning("There are errors in config file!"); Logger::warning("There are errors in config file!");
return -1; return -1;
} }
} else if (firstarg == "-ip" || firstarg == "--currentip") {
IPAPI ipapi;
std::cout << "Current global IP: " << ipapi.getGlobalIp() << std::endl;
} else { } else {
Logger::message("wrong arguments! -h for help"); Logger::message("wrong arguments! -h for help");
} }