Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
91230381
Commit
91230381
authored
17 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Test dns.py
parent
46ed3ddb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Milter/dns.py
+28
-2
28 additions, 2 deletions
Milter/dns.py
with
28 additions
and
2 deletions
Milter/dns.py
+
28
−
2
View file @
91230381
...
@@ -24,6 +24,23 @@ class Session(object):
...
@@ -24,6 +24,23 @@ class Session(object):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
cache
=
{}
self
.
cache
=
{}
# We have to be careful which additional DNS RRs we cache. For
# instance, PTR records are controlled by the connecting IP, and they
# could poison our local cache with bogus A and MX records.
SAFE2CACHE
=
{
(
'
MX
'
,
'
A
'
):
None
,
(
'
MX
'
,
'
MX
'
):
None
,
(
'
CNAME
'
,
'
A
'
):
None
,
(
'
CNAME
'
,
'
CNAME
'
):
None
,
(
'
A
'
,
'
A
'
):
None
,
(
'
AAAA
'
,
'
AAAA
'
):
None
,
(
'
PTR
'
,
'
PTR
'
):
None
,
(
'
TXT
'
,
'
TXT
'
):
None
,
(
'
SPF
'
,
'
SPF
'
):
None
}
def
dns
(
self
,
name
,
qtype
,
cnames
=
None
):
def
dns
(
self
,
name
,
qtype
,
cnames
=
None
):
"""
DNS query.
"""
DNS query.
...
@@ -42,8 +59,8 @@ class Session(object):
...
@@ -42,8 +59,8 @@ class Session(object):
cname
=
None
cname
=
None
if
not
result
:
if
not
result
:
safe2cache
=
query
.
SAFE2CACHE
safe2cache
=
Session
.
SAFE2CACHE
for
k
,
v
in
DNSLookup
(
name
,
qtype
,
self
.
strict
):
for
k
,
v
in
DNSLookup
(
name
,
qtype
):
if
k
==
(
name
,
'
CNAME
'
):
if
k
==
(
name
,
'
CNAME
'
):
cname
=
v
cname
=
v
if
(
qtype
,
k
[
1
])
in
safe2cache
:
if
(
qtype
,
k
[
1
])
in
safe2cache
:
...
@@ -60,3 +77,12 @@ class Session(object):
...
@@ -60,3 +77,12 @@ class Session(object):
raise
DNSError
,
'
CNAME loop
'
raise
DNSError
,
'
CNAME loop
'
result
=
self
.
dns
(
cname
,
qtype
,
cnames
=
cnames
)
result
=
self
.
dns
(
cname
,
qtype
,
cnames
=
cnames
)
return
result
return
result
DNS
.
DiscoverNameServers
()
if
__name__
==
'
__main__
'
:
import
sys
s
=
Session
()
for
n
,
t
in
zip
(
*
[
iter
(
sys
.
argv
[
1
:])]
*
2
):
print
n
,
t
print
s
.
dns
(
n
,
t
)
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