Last active
February 19, 2024 21:36
-
-
Save Mixaill/73e2d153b741a368e13fe7861968d65b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Mastodon Tor Exit Nodes Block | |
| # | |
| # V4 (2024.02.19) | |
| # | |
| # * v1: initial version | |
| # * v2: fix compatibility with HAProxy (set MASTODON_CONVERT_IPV4toV6 to true) | |
| # * v3: minor cleanup | |
| # * v4: added support for the IPv6 exit nodes, change default settings | |
| # | |
| # Config | |
| # | |
| MASTODON_HOME=${MASTODON_HOME:-/home/mastodon/live/} | |
| MASTODON_CONVERT_IPV4_TO_V6=${MASTODON_CONVERT_IPV4_TO_V6:-false} | |
| MASTODON_BLOCK_DURATION=${MASTODON_BLOCK_DURATION:-604800} | |
| MASTODON_BLOCK_SEVERITY=${MASTODON_BLOCK_SEVERITY:-sign_up_requires_approval} | |
| # | |
| # Script | |
| # | |
| pushd $MASTODON_HOME >/dev/null | |
| tempfile=$(mktemp) | |
| wget --quiet --no-cache https://www.dan.me.uk/torlist/?exit -O "$tempfile" | |
| ips=$(cat "$tempfile") | |
| if [ "$MASTODON_CONVERT_IPV4_TO_V6" = true ]; then | |
| ips=$(echo $ips | sed -e 's/\(\([0-9]\{1,3\}\.\)\{1,3\}\).[0-9]/::ffff:\0/g') | |
| fi | |
| ips="${ips//$'\n'/ }" | |
| RAILS_ENV=production bin/tootctl ip_blocks add $ips --severity=$MASTODON_BLOCK_SEVERITY --duration=$MASTODON_BLOCK_DURATION --comment="Tor exit node" --force | |
| rm "$tempfile" | |
| popd >/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment