Commit 49a597f9 authored by mr-ti's avatar mr-ti
Browse files

No commit message

No commit message
parent 4612e926
......@@ -17,8 +17,8 @@
DDnsSSList::DDnsSSList(CUniConf &cf)
: CUniThread()
{
StringList cmdList=cf.getListValue("dn_list");
for(StringList::iterator it=cmdList.begin();it!=cmdList.begin();it++){
StringList dnsList=cf.getListValue("dn_list");
for(StringList::iterator it=dnsList.begin();it!=dnsList.begin();it++){
dnList.push_back(new DName(cf,*it));
}
time=cf.getValueToInt("time");
......@@ -41,6 +41,7 @@ int DDnsSSList::run(){
do{
ip=httpcl.getPubIp();
if(ip!=httpcl.getCurPubIp()){
printd("Detection of a change of public IP : "+httpcl.getCurPubIp()+" -> "+ip+"\n");
DdnssHttpCl::setCurPubIp(ip);
for(list<DName*>::iterator it=dnList.begin();it!=dnList.begin();it++){
(*it)->doSync();
......@@ -49,6 +50,7 @@ int DDnsSSList::run(){
for(int i=0;i<time;i++){
if(doStop)
return 0;
sleep(1);
}
}while(true);
return 0;
......@@ -82,6 +84,7 @@ DDnsSSList::DName::~DName()
}
void DDnsSSList::DName::doSync(){
printd("doSync()\n");
condSync.lock();
sync=true;
condSync.signal();
......@@ -105,10 +108,12 @@ int DDnsSSList::DName::run(){
// Traitement de la file
while(!orig->empty() && !dest->empty()){
try{
printd("exec() >> "+orig->front()+"\n");
DDnsSPlList::pList->exec(orig->front());
}catch(string err){
// Ajoute à la file des commandes à réexécuter
dest->push(orig->front());
printc("exec() failed >> "+orig->front()+"\n");
}
orig->pop();
if(orig->empty() && !dest->empty()){
......@@ -116,9 +121,11 @@ int DDnsSSList::DName::run(){
tmp=orig;
orig=dest;
dest=tmp;
printd("sleep() >> 300 sec...\n");
for(unsigned int i=0;i<300;i++){
if(!condSync.isEnabled())
return 0;
sleep(1);
}
}
if(!condSync.isEnabled())
......
......@@ -5,6 +5,7 @@
#include "../ddnssbase/ddnsshttpcl.h"
#include "ddnssreqanalyzer.h"
#include "ddnsspluginlist.h"
#include "ddnssslist.h"
#include <string>
#include <signal.h>
......@@ -61,13 +62,17 @@ int main(int argc, char **argv) {
"You must correct this error in the configuration file.\n");
DDnsSPlList::pList=new DDnsSPlList(config);
DDnsSSList *dnsList=new DDnsSSList(config);
dnsList->start();
DdnssHttpCl::setCurPubIp(config.getValue("public_ip"));
string server=config.getValue("server");
string user=config.getValue("user");
string passwd=config.getValue("passwd");
string name=config.getValue("name");
thList.addTypeToManage("DDnsSManager");
thList.addTypeToManage("DDnsSSList");
DDnsSManager *thread=new DDnsSManager(server);
if(!thread->isConnected()){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment