Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
91c87446
Unverified
Commit
91c87446
authored
Sep 24, 2022
by
neil
Committed by
GitHub
Sep 24, 2022
Browse files
Merge pull request #4115 from koter84/dev
make ip-whitelisting configurable for DNS TransIP
parents
dd207e1f
7122a960
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_transip.sh
View file @
91c87446
#!/usr/bin/env sh
#!/usr/bin/env sh
TRANSIP_Api_Url
=
"https://api.transip.nl/v6"
TRANSIP_Api_Url
=
"https://api.transip.nl/v6"
TRANSIP_Token_Read_Only
=
"false"
TRANSIP_Token_Read_Only
=
"false"
TRANSIP_Token_Global_Key
=
"false"
TRANSIP_Token_Expiration
=
"30 minutes"
TRANSIP_Token_Expiration
=
"30 minutes"
# You can't reuse a label token, so we leave this empty normally
# You can't reuse a label token, so we leave this empty normally
TRANSIP_Token_Label
=
""
TRANSIP_Token_Label
=
""
...
@@ -96,7 +95,11 @@ _transip_get_token() {
...
@@ -96,7 +95,11 @@ _transip_get_token() {
nonce
=
$(
echo
"TRANSIP
$(
_time
)
"
| _digest sha1 hex |
cut
-c
1-32
)
nonce
=
$(
echo
"TRANSIP
$(
_time
)
"
| _digest sha1 hex |
cut
-c
1-32
)
_debug nonce
"
$nonce
"
_debug nonce
"
$nonce
"
data
=
"{
\"
login
\"
:
\"
${
TRANSIP_Username
}
\"
,
\"
nonce
\"
:
\"
${
nonce
}
\"
,
\"
read_only
\"
:
\"
${
TRANSIP_Token_Read_Only
}
\"
,
\"
expiration_time
\"
:
\"
${
TRANSIP_Token_Expiration
}
\"
,
\"
label
\"
:
\"
${
TRANSIP_Token_Label
}
\"
,
\"
global_key
\"
:
\"
${
TRANSIP_Token_Global_Key
}
\"
}"
# make IP whitelisting configurable
TRANSIP_Token_Global_Key
=
"
${
TRANSIP_Token_Global_Key
:-
$(
_readaccountconf_mutable TRANSIP_Token_Global_Key
)
}
"
_saveaccountconf_mutable TRANSIP_Token_Global_Key
"
$TRANSIP_Token_Global_Key
"
data
=
"{
\"
login
\"
:
\"
${
TRANSIP_Username
}
\"
,
\"
nonce
\"
:
\"
${
nonce
}
\"
,
\"
read_only
\"
:
\"
${
TRANSIP_Token_Read_Only
}
\"
,
\"
expiration_time
\"
:
\"
${
TRANSIP_Token_Expiration
}
\"
,
\"
label
\"
:
\"
${
TRANSIP_Token_Label
}
\"
,
\"
global_key
\"
:
\"
${
TRANSIP_Token_Global_Key
:-
false
}
\"
}"
_debug data
"
$data
"
_debug data
"
$data
"
#_signature=$(printf "%s" "$data" | openssl dgst -sha512 -sign "$TRANSIP_Key_File" | _base64)
#_signature=$(printf "%s" "$data" | openssl dgst -sha512 -sign "$TRANSIP_Key_File" | _base64)
...
@@ -139,6 +142,18 @@ _transip_setup() {
...
@@ -139,6 +142,18 @@ _transip_setup() {
_saveaccountconf_mutable TRANSIP_Username
"
$TRANSIP_Username
"
_saveaccountconf_mutable TRANSIP_Username
"
$TRANSIP_Username
"
_saveaccountconf_mutable TRANSIP_Key_File
"
$TRANSIP_Key_File
"
_saveaccountconf_mutable TRANSIP_Key_File
"
$TRANSIP_Key_File
"
# download key file if it's an URL
if
_startswith
"
$TRANSIP_Key_File
"
"http"
;
then
_debug
"download transip key file"
TRANSIP_Key_URL
=
$TRANSIP_Key_File
TRANSIP_Key_File
=
"
$(
_mktemp
)
"
chmod
600
"
$TRANSIP_Key_File
"
if
!
_get
"
$TRANSIP_Key_URL
"
>
"
$TRANSIP_Key_File
"
;
then
_err
"Error getting key file from :
$TRANSIP_Key_URL
"
return
1
fi
fi
if
[
-f
"
$TRANSIP_Key_File
"
]
;
then
if
[
-f
"
$TRANSIP_Key_File
"
]
;
then
if
!
grep
"BEGIN PRIVATE KEY"
"
$TRANSIP_Key_File
"
>
/dev/null 2>&1
;
then
if
!
grep
"BEGIN PRIVATE KEY"
"
$TRANSIP_Key_File
"
>
/dev/null 2>&1
;
then
_err
"Key file doesn't seem to be a valid key:
${
TRANSIP_Key_File
}
"
_err
"Key file doesn't seem to be a valid key:
${
TRANSIP_Key_File
}
"
...
@@ -156,6 +171,12 @@ _transip_setup() {
...
@@ -156,6 +171,12 @@ _transip_setup() {
fi
fi
fi
fi
if
[
-n
"
${
TRANSIP_Key_URL
}
"
]
;
then
_debug
"delete transip key file"
rm
"
${
TRANSIP_Key_File
}
"
TRANSIP_Key_File
=
$TRANSIP_Key_URL
fi
_get_root
"
$fulldomain
"
||
return
1
_get_root
"
$fulldomain
"
||
return
1
return
0
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