Commit 96acb387 authored by mr-ti's avatar mr-ti
Browse files

No commit message

No commit message
parent 9425deef
SET(CMAKE_VERBOSE_MAKEFILE FALSE)
SET(CMAKE_INSTALL_PREFIX /usr)
SET(Default_Project_WC_REVISION 2)
SET(global_unicomctrl_DEFS -Wall -g3 -D_REENTRANT)
SET(Default_Project_WC_REVISION 25)
SET(global_unicomctrl_DEFS -Wall -O2 -D_REENTRANT)
IF(NOT WIN32)
EXECUTE_PROCESS(COMMAND uname -s OUTPUT_VARIABLE SYSTEM_NAME)
......
......@@ -9,18 +9,17 @@ extern "C"
CRegex subRegex("([^']+)");
regex.setBuffer(&request);
if(equ(request,"HELP"))
throw string("zoneedit <domaine name> <IP> <login> <password>");
throw string("zoneedit <domaine name> <login> <password>");
vector<string> elts=regex.getMatchsToVect(&subRegex);
if(elts.size()!=4){
string err="Wrong zoneedit plugin use !\nUse : zoneedit <domaine name> <IP> <login> <password>";
if(elts.size()!=3){
string err="Wrong zoneedit plugin use !\nUse : zoneedit <domaine name> <login> <password>";
CUniObj::printc("ZoneEdit plugin",err+"\n");
throw string(err);
}
CUniObj::printd("ZoneEdit plugin","Request >> \""+request+"\"\n");
DdnssHttpCl httpcl;
string newIp=(elts.at(1)=="<IP>"?httpcl.getCurPubIp():elts.at(1));
httpcl.setHttpUserPwd(elts.at(2),elts.at(3));
httpcl.setHttpUserPwd(elts.at(1),elts.at(2));
string res,tmp;
CRegex regexRes("(<[A-Z]+ CODE=\"[0-9]+\")");
......@@ -42,7 +41,7 @@ extern "C"
if(state=="SUCCESS"){
CUniObj::printd("DynDNS plugin","Code="+code+", "+text+"\n");
}else{
string err="FATAL ERROR >> State="+state+", CODE="+code+", "+text+"\nSee logs for more details, you must verify client settings...";
string err="FATAL ERROR >> See logs for more details, you must verify client settings...";
CUniObj::printc("DynDNS plugin",err+"\nRequest result : \n"+res+"\n");
throw string(err);
}
......
......@@ -37,7 +37,7 @@ SET_TARGET_PROPERTIES(ddnssync PROPERTIES LINK_FLAGS "${ddnssync_LDFS}")
TARGET_LINK_LIBRARIES(ddnssync ${ddnssync_LIBS})
# ### INSTALL ###
INSTALL(TARGETS ddnssync DESTINATION bin PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
INSTALL(TARGETS ddnssync DESTINATION lib/unicomctrl PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
ADD_EXECUTABLE(test test.cpp)
TARGET_LINK_LIBRARIES(test ddnssbase)
......@@ -24,7 +24,12 @@ DDnsSSList::DDnsSSList(CUniConf &cf)
name->start();
dnList.push_back(name);
}
time=cf.getValueToInt("time");
time=cf.getValueToInt("time_check");
timeF=cf.getValueToInt("time_update");
if(time==0)
time=300;
if(timeF==0)
timeF=604800;
doStop=false;
}
......@@ -40,17 +45,21 @@ DDnsSSList::~DDnsSSList()
int DDnsSSList::run(){
DdnssHttpCl httpcl;
string ip;
int timeU=0;
string ip,tmp;
do{
ip=httpcl.getPubIp();
if(ip!=httpcl.getCurPubIp()){
printd("Detection of a change of public IP : "+httpcl.getCurPubIp()+" -> "+ip+"\n");
tmp=httpcl.getPubIp();
if(!tmp.empty())
ip=tmp;
if(ip!=httpcl.getCurPubIp() || timeU>=timeF){
timeU=0;
printd("Detection of a change of public IP or forced update.\n"+httpcl.getCurPubIp()+" -> "+ip+"\n");
DdnssHttpCl::setCurPubIp(ip);
for(list<DName*>::iterator it=dnList.begin();it!=dnList.end();it++){
(*it)->doSync();
}
}
for(int i=0;i<time;i++){
for(int i=0;i<time;i++,timeU++){
if(doStop)
return 0;
sleep(1);
......
......@@ -49,6 +49,7 @@ protected:
private:
list<DName*> dnList;
int time;
int timeF;
bool doStop;
};
......
......@@ -47,6 +47,7 @@ int main(int argc, char **argv) {
//Initialisation.
CUniSocket::init();
CUniConfFile config("/etc/ddnssync/ddnssync.conf");
CUniConfFile pubIp("/etc/ddnssync/publicip");
// Niveau bavard
string value=config.getValue("verbose_level");
......@@ -60,11 +61,17 @@ int main(int argc, char **argv) {
CUniObj::printc("AuthManager","Configuration file >> Bade value for the parameter \"verbose_level\"\n"
"Possible values are :\n\t* verbose\n\t* short\n\t* quiet\n"
"You must correct this error in the configuration file.\n");
// Syslog ?
CUniIO::globalIO.setSyslog(config.getValueToBool("syslog"));
// Log chemin
CUniIO::globalIO.setLogPath(config.getValue("log_path"));
// Log ?
CUniIO::globalIO.setLog(config.getValueToBool("log"));
DDnsSPlList::pList=new DDnsSPlList(config);
DDnsSSList *dnsList=new DDnsSSList(config);
dnsList->start();
DdnssHttpCl::setCurPubIp(config.getValue("public_ip"));
DdnssHttpCl::setCurPubIp(pubIp.getValue("public_ip"));
string server=config.getValue("server");
string user=config.getValue("user");
......@@ -94,7 +101,7 @@ int main(int argc, char **argv) {
thList.waitJoin();
thList.killall();
config.setValue("public_ip",DdnssHttpCl::getCurPubIp());
pubIp.setValue("public_ip",DdnssHttpCl::getCurPubIp());
delete DDnsSPlList::pList;
return 0;
......
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