Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
svn
ddnssync
Commits
9425deef
Commit
9425deef
authored
Oct 14, 2007
by
mr-ti
Browse files
relase 0.70a0.
parent
49a597f9
Changes
5
Hide whitespace changes
Inline
Side-by-side
ddnssbase/ddnsshttpcl.cpp
View file @
9425deef
...
...
@@ -51,8 +51,8 @@ void DdnssHttpCl::setCurPubIp(const string &ip){
}
void
DdnssHttpCl
::
setHttpUserPwd
(
const
string
&
login
,
const
string
&
passwd
){
string
tmp
=
login
+
":"
+
passwd
;
curl_easy_setopt
(
handle
,
CURLOPT_USERPWD
,
tmp
.
c_str
());
loginpw
=
login
+
":"
+
passwd
;
curl_easy_setopt
(
handle
,
CURLOPT_USERPWD
,
loginpw
.
c_str
());
}
bool
DdnssHttpCl
::
get
(
string
&
result
,
const
string
&
url
){
...
...
ddnssbase/ddnsshttpcl.h
View file @
9425deef
...
...
@@ -32,6 +32,7 @@ public:
private:
string
publicIpGetAdress
;
CURL
*
handle
;
string
loginpw
;
static
string
curPubIp
;
static
size_t
writeInRepBuf
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FILE
*
out
);
};
...
...
ddnssplugins/dyndns/dyndns.cpp
View file @
9425deef
...
...
@@ -23,13 +23,14 @@ extern "C"
string
res
;
httpcl
.
post
(
res
,
"https://members.dyndns.org/nic/update?system=dyndns&hostname="
+
elts
.
at
(
0
)
+
"&myip="
+
newIp
);
if
(
res
==
"good "
+
newIp
){
CUniObj
::
printd
(
"DynDNS plugin"
,
"Success...
\n
"
);
}
else
if
(
res
==
"nochg "
+
newIp
){
string
err
=
"Warning >> Duplicate updates for the same host/ip, you should verify client settings..."
;
CUniObj
::
prints
(
"DynDNS plugin"
,
err
+
"
\n
"
);
throw
string
(
err
);
}
else
{
string
err
=
"FATAL ERROR >> See logs for more details, you must verify client settings..."
;
CUniObj
::
print
s
(
"DynDNS plugin"
,
err
+
"
\n
Request result :
\n
"
+
res
+
"
\n
"
);
CUniObj
::
print
c
(
"DynDNS plugin"
,
err
+
"
\n
Request result :
\n
"
+
res
+
"
\n
"
);
throw
string
(
err
);
}
}
...
...
ddnssplugins/zoneedit/zoneedit.cpp
View file @
9425deef
...
...
@@ -16,20 +16,34 @@ extern "C"
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
));
string
res
;
string
res
,
tmp
;
CRegex
regexRes
(
"(<[A-Z]+ CODE=
\"
[0-9]+
\"
)"
);
CRegex
regexTextTag
(
"(TEXT=
\"
[^
\"
]+
\"
)"
);
CRegex
regexState
(
"([^< ]+)"
);
CRegex
regexCode
(
"([0-9]+)"
);
string
state
,
code
,
text
;
httpcl
.
post
(
res
,
"http://dynamic.zoneedit.com/auth/dynamic.html?zones="
+
elts
.
at
(
0
));
if
(
res
==
"<SUCCESS CODE=
\"
200
\"
TEXT=
\"
Update succeeded.
\"
ZONE=
\"
"
+
elts
.
at
(
0
)
+
"
\"
IP=
\"
"
+
newIp
+
"
\"
>"
){
}
else
if
(
res
==
"<ERROR CODE=
\"
707
\"
TEXT=
\"
Duplicate updates for the same host/ip, adjust client settings
\"
ZONE=
\"
"
+
elts
.
at
(
0
)
+
"
\"
>"
){
string
err
=
"Warning >> Duplicate updates for the same host/ip, you should verify client settings..."
;
CUniObj
::
prints
(
"DynDNS plugin"
,
err
+
"
\n
"
);
throw
string
(
err
);
regexTextTag
.
setBuffer
(
&
res
);
text
=
regexTextTag
.
getFirstMatch
();
regexRes
.
setBuffer
(
&
res
);
tmp
=
regexRes
.
getFirstMatch
();
regexState
.
setBuffer
(
&
tmp
);
regexCode
.
setBuffer
(
&
tmp
);
state
=
regexState
.
getFirstMatch
();
code
=
regexCode
.
getFirstMatch
();
if
(
state
==
"SUCCESS"
){
CUniObj
::
printd
(
"DynDNS plugin"
,
"Code="
+
code
+
", "
+
text
+
"
\n
"
);
}
else
{
string
err
=
"FATAL ERROR >> See logs for more details, you must verify client settings..."
;
CUniObj
::
print
s
(
"DynDNS plugin"
,
err
+
"
\n
Request result :
\n
"
+
res
+
"
\n
"
);
string
err
=
"FATAL ERROR >>
State="
+
state
+
", CODE="
+
code
+
", "
+
text
+
"
\n
See logs for more details, you must verify client settings..."
;
CUniObj
::
print
c
(
"DynDNS plugin"
,
err
+
"
\n
Request result :
\n
"
+
res
+
"
\n
"
);
throw
string
(
err
);
}
}
...
...
ddnssync/ddnssslist.cpp
View file @
9425deef
...
...
@@ -17,9 +17,12 @@
DDnsSSList
::
DDnsSSList
(
CUniConf
&
cf
)
:
CUniThread
()
{
StringList
dnsList
=
cf
.
getListValue
(
"dn_list"
);
for
(
StringList
::
iterator
it
=
dnsList
.
begin
();
it
!=
dnsList
.
begin
();
it
++
){
dnList
.
push_back
(
new
DName
(
cf
,
*
it
));
StringList
dn_list
=
cf
.
getListValue
(
"dn_list"
);
DName
*
name
;
for
(
StringList
::
iterator
it
=
dn_list
.
begin
();
it
!=
dn_list
.
end
();
it
++
){
name
=
new
DName
(
cf
,
*
it
);
name
->
start
();
dnList
.
push_back
(
name
);
}
time
=
cf
.
getValueToInt
(
"time"
);
doStop
=
false
;
...
...
@@ -43,7 +46,7 @@ int DDnsSSList::run(){
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
++
){
for
(
list
<
DName
*>::
iterator
it
=
dnList
.
begin
();
it
!=
dnList
.
end
();
it
++
){
(
*
it
)
->
doSync
();
}
}
...
...
@@ -92,7 +95,7 @@ void DDnsSSList::DName::doSync(){
}
int
DDnsSSList
::
DName
::
run
(){
queue
<
string
>
q1
,
q2
,
*
orig
=&
q1
,
*
dest
=&
q2
,
*
tmp
;
queue
<
string
>
q1
,
q2
,
*
orig
=&
q1
,
*
dest
=&
q2
/*
,*tmp
*/
;
do
{
if
(
!
condSync
.
lock
())
return
0
;
...
...
@@ -106,28 +109,28 @@ int DDnsSSList::DName::run(){
orig
->
push
(
*
it
);
}
// Traitement de la file
while
(
!
orig
->
empty
()
&&
!
dest
->
empty
()){
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
());
//
dest->push(orig->front());
printc
(
"exec() failed >> "
+
orig
->
front
()
+
"
\n
"
);
}
orig
->
pop
();
if
(
orig
->
empty
()
&&
!
dest
->
empty
()){
// Inverse les files et attend 3 minutes avant de réexécuter les commande qui ont échoué
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(orig->empty() && !dest->empty()){
//
// Inverse les files et attend 3 minutes avant de réexécuter les commande qui ont échoué
//
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
())
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment