nginx_ua_block_pleroma_rejects: Don't filter out wildcard domains.
This commit is contained in:
parent
207a20bf93
commit
186192d968
|
@ -4,10 +4,10 @@
|
|||
# Save the output to a file and include it in an nginx configuration file. Then
|
||||
# add `if ($blockedagent) { return 403; }` to your server blocks.
|
||||
|
||||
# Version: 2019-08-17_2
|
||||
# Version: 2019-08-17_3
|
||||
|
||||
|
||||
function get_domains() # Outputs domains, separated by newline.
|
||||
function get_domains() # Output domains, separated by newline.
|
||||
{
|
||||
local instance="${1}"
|
||||
local nodeinfo=$(curl -s "https://${instance}/nodeinfo/2.1.json")
|
||||
|
@ -17,14 +17,15 @@ function get_domains() # Outputs domains, separated by newline.
|
|||
sed -e 's/\[//' -e 's/\]//' -e 's/"//g' -e 's/,/\n/g' <<<"${domains_json}"
|
||||
}
|
||||
|
||||
function print_entry()
|
||||
function print_entry() # Output map entry.
|
||||
{
|
||||
local domain="${1}"
|
||||
# Filter out wildcard domains.
|
||||
if ! [[ "${domain}" =~ "\*" ]]; then
|
||||
domain=$(sed 's/\./\\./g' <<<${domain})
|
||||
echo " ~*${domain} 1;"
|
||||
fi
|
||||
|
||||
# Transform strings to regular expressions.
|
||||
domain=$(sed 's/\./\\./g' <<<${domain}) # . → \.
|
||||
domain=$(sed 's/\*/.*/g' <<<${domain}) # * → .*
|
||||
|
||||
echo " ~*${domain} 1;"
|
||||
}
|
||||
|
||||
function main()
|
||||
|
@ -33,7 +34,8 @@ function main()
|
|||
|
||||
if [[ -z "${instance}" ]]; then
|
||||
echo "Usage: ${ZSH_ARGZERO} instance" >&2
|
||||
echo " ${ZSH_ARGZERO} instance > /etc/nginx/useragents_fedi.rules"
|
||||
echo " ${ZSH_ARGZERO} instance" \
|
||||
"> /etc/nginx/useragents_fedi.rules" >&2
|
||||
return 1
|
||||
fi
|
||||
if ! command -v curl > /dev/null; then
|
||||
|
|
Loading…
Reference in New Issue
Block a user