Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
3afd59df
Unverified
Commit
3afd59df
authored
3 years ago
by
Claire
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix tootctl email_domain_blocks add (#17842)
Fixes #17831
parent
f29458da
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mastodon/email_domain_blocks_cli.rb
+13
-20
13 additions, 20 deletions
lib/mastodon/email_domain_blocks_cli.rb
with
13 additions
and
20 deletions
lib/mastodon/email_domain_blocks_cli.rb
+
13
−
20
View file @
3afd59df
...
...
@@ -32,9 +32,9 @@ module Mastodon
multiple domains to the command.
When the --with-dns-records option is given, an attempt to resolve the
given domains'
DNS
records will be made and the results
(A, AAAA and MX) will
also be blocked.
This can be helpful if you are blocking an e-mail server that
has many
different domains pointing to it as it allows you to essentially block
given domains'
MX
records will be made and the results
will also be blocked.
This can be helpful if you are blocking an e-mail server that
has many
different domains pointing to it as it allows you to essentially block
it at the root.
LONG_DESC
def
add
(
*
domains
)
...
...
@@ -53,26 +53,19 @@ module Mastodon
next
end
email_domain_block
=
EmailDomainBlock
.
new
(
domain:
domain
,
with_dns_records:
options
[
:with_dns_records
]
||
false
)
email_domain_block
.
save!
processed
+=
1
next
unless
email_domain_block
.
with_dns_records?
hostnames
=
[]
ips
=
[]
Resolv
::
DNS
.
open
do
|
dns
|
dns
.
timeouts
=
5
hostnames
=
dns
.
getresources
(
email_domain_block
.
domain
,
Resolv
::
DNS
::
Resource
::
IN
::
MX
).
to_a
.
map
{
|
e
|
e
.
exchange
.
to_s
}
([
email_domain_block
.
domain
]
+
hostnames
).
uniq
.
each
do
|
hostname
|
ips
.
concat
(
dns
.
getresources
(
hostname
,
Resolv
::
DNS
::
Resource
::
IN
::
A
).
to_a
.
map
{
|
e
|
e
.
address
.
to_s
})
ips
.
concat
(
dns
.
getresources
(
hostname
,
Resolv
::
DNS
::
Resource
::
IN
::
AAAA
).
to_a
.
map
{
|
e
|
e
.
address
.
to_s
})
other_domains
=
[]
if
options
[
:with_dns_records
]
Resolv
::
DNS
.
open
do
|
dns
|
dns
.
timeouts
=
5
other_domains
=
dns
.
getresources
(
@email_domain_block
.
domain
,
Resolv
::
DNS
::
Resource
::
IN
::
MX
).
to_a
end
end
(
hostnames
+
ips
).
uniq
.
each
do
|
hostname
|
email_domain_block
=
EmailDomainBlock
.
new
(
domain:
domain
,
other_domains:
other_domains
)
email_domain_block
.
save!
processed
+=
1
(
email_domain_block
.
other_domains
||
[]).
uniq
.
each
do
|
hostname
|
another_email_domain_block
=
EmailDomainBlock
.
new
(
domain:
hostname
,
parent:
email_domain_block
)
if
EmailDomainBlock
.
where
(
domain:
hostname
).
exists?
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment