syntax update and sperate variable for dynu domain id
This commit is contained in:
parent
acd33bbbad
commit
1754dd8385
25
src/main.cpp
25
src/main.cpp
@ -11,38 +11,39 @@ int main() {
|
|||||||
|
|
||||||
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 << "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 << "ip changed! -- from :" << oldip << "to: " << ip << std::endl;
|
||||||
|
|
||||||
//api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg
|
//dynu api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg
|
||||||
|
|
||||||
|
static std::string domainid = "8506047"; //id of the dynu domain
|
||||||
|
|
||||||
Hashmap<std::string, std::string> args;
|
Hashmap<std::string, std::string> args;
|
||||||
|
args.add("name", "luki.dynu.net");
|
||||||
args.add("name","luki.dynu.net");
|
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: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg");
|
||||||
|
|
||||||
std::string dynurepl = api.request("https://api.dynu.com/v2/dns/8506047",true, args,headers);
|
std::string dynurepl = api.request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers);
|
||||||
|
|
||||||
std::cout << "[ DEBUG ] api reply:: " << dynurepl << std::endl;
|
std::cout << "[ DEBUG ] api reply:: " << dynurepl << std::endl;
|
||||||
|
|
||||||
if (dynurepl != "{\"statusCode\":200}"){
|
if (dynurepl != "{\"statusCode\":200}") {
|
||||||
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");
|
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user