Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
274fd5ab
Unverified
Commit
274fd5ab
authored
Jun 06, 2022
by
neil
Committed by
GitHub
Jun 06, 2022
Browse files
Merge pull request #4124 from rmalchow/dev
check all pages first, then go up
parents
6c11dd12
e48d7de7
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_aws.sh
View file @
274fd5ab
...
@@ -155,29 +155,18 @@ _get_root() {
...
@@ -155,29 +155,18 @@ _get_root() {
i
=
1
i
=
1
p
=
1
p
=
1
if
aws_rest GET
"2013-04-01/hostedzone"
;
then
# iterate over names (a.b.c.d -> b.c.d -> c.d -> d)
while
true
;
do
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug2
"Checking domain:
$h
"
_debug
"Checking domain:
$h
"
if
[
-z
"
$h
"
]
;
then
if
[
-z
"
$h
"
]
;
then
if
_contains
"
$response
"
"<IsTruncated>true</IsTruncated>"
&&
_contains
"
$response
"
"<NextMarker>"
;
then
_error
"invalid domain"
_debug
"IsTruncated"
return
1
_nextMarker
=
"
$(
echo
"
$response
"
| _egrep_o
"<NextMarker>.*</NextMarker>"
|
cut
-d
'>'
-f
2 |
cut
-d
'<'
-f
1
)
"
fi
_debug
"NextMarker"
"
$_nextMarker
"
if
aws_rest GET
"2013-04-01/hostedzone"
"marker=
$_nextMarker
"
;
then
_debug
"Truncated request OK"
i
=
2
p
=
1
continue
else
_err
"Truncated request error."
fi
fi
#not valid
_err
"Invalid domain"
return
1
fi
# iterate over paginated result for list_hosted_zones
aws_rest GET
"2013-04-01/hostedzone"
while
true
;
do
if
_contains
"
$response
"
"<Name>
$h
.</Name>"
;
then
if
_contains
"
$response
"
"<Name>
$h
.</Name>"
;
then
hostedzone
=
"
$(
echo
"
$response
"
|
sed
's/<HostedZone>/#&/g'
|
tr
'#'
'\n'
| _egrep_o
"<HostedZone><Id>[^<]*<.Id><Name>
$h
.<.Name>.*<PrivateZone>false<.PrivateZone>.*<.HostedZone>"
)
"
hostedzone
=
"
$(
echo
"
$response
"
|
sed
's/<HostedZone>/#&/g'
|
tr
'#'
'\n'
| _egrep_o
"<HostedZone><Id>[^<]*<.Id><Name>
$h
.<.Name>.*<PrivateZone>false<.PrivateZone>.*<.HostedZone>"
)
"
_debug hostedzone
"
$hostedzone
"
_debug hostedzone
"
$hostedzone
"
...
@@ -192,10 +181,19 @@ _get_root() {
...
@@ -192,10 +181,19 @@ _get_root() {
return
1
return
1
fi
fi
fi
fi
p
=
$i
if
_contains
"
$response
"
"<IsTruncated>true</IsTruncated>"
&&
_contains
"
$response
"
"<NextMarker>"
;
then
i
=
$(
_math
"
$i
"
+ 1
)
_debug
"IsTruncated"
_nextMarker
=
"
$(
echo
"
$response
"
| _egrep_o
"<NextMarker>.*</NextMarker>"
|
cut
-d
'>'
-f
2 |
cut
-d
'<'
-f
1
)
"
_debug
"NextMarker"
"
$_nextMarker
"
else
break
fi
_debug
"Checking domain:
$h
- Next Page "
aws_rest GET
"2013-04-01/hostedzone"
"marker=
$_nextMarker
"
done
done
fi
p
=
$i
i
=
$(
_math
"
$i
"
+ 1
)
done
return
1
return
1
}
}
...
...
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