Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
shrapnel
Commits
d2a1d432
Commit
d2a1d432
authored
Jul 06, 2014
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exceptions were over-tuple-ized when translated to new-style "raise".
parent
3b72334c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
coro/dns/cache.py
coro/dns/cache.py
+11
-11
No files found.
coro/dns/cache.py
View file @
d2a1d432
...
...
@@ -267,7 +267,7 @@ class dns_cache:
s
=
coro
.
make_socket
(
sfamily
,
stype
)
except
OSError
,
why
:
self
.
log
(
'COMMON.APP_FAILURE'
,
tb
.
traceback_string
()
+
' why: '
+
str
(
why
))
raise
DNS_Soft_Error
(
(
qname
,
qtype
,
ip
,
str
(
why
)
))
raise
DNS_Soft_Error
(
qname
,
qtype
,
ip
,
str
(
why
))
try
:
try
:
...
...
@@ -280,7 +280,7 @@ class dns_cache:
n
=
s
.
send
(
r
)
if
n
!=
len
(
r
):
self
.
log
(
'DNS.NETWORK_ERROR'
,
'send'
,
ip
,
qname
)
raise
DNS_Soft_Error
(
(
qname
,
qtype
,
ip
,
'Failed to send all data.'
)
)
raise
DNS_Soft_Error
(
qname
,
qtype
,
ip
,
'Failed to send all data.'
)
if
use_tcp
:
rlen_bytes
=
s
.
recv_exact
(
2
)
rlen
,
=
struct
.
unpack
(
'>H'
,
rlen_bytes
)
...
...
@@ -295,10 +295,10 @@ class dns_cache:
reply
=
unpack_reply
(
data
,
use_actual_ttl
=
self
.
use_actual_ttl
,
ttl_min
=
self
.
ttl_min
)
except
packet
.
UnpackError
:
self
.
log
(
'DNS.RESPONSE_ERROR'
,
repr
(
data
),
ip
,
qname
)
raise
DNS_Soft_Error
(
(
qname
,
qtype
,
ip
,
'Packet was corrupted.'
)
)
raise
DNS_Soft_Error
(
qname
,
qtype
,
ip
,
'Packet was corrupted.'
)
except
:
self
.
log
(
'COMMON.APP_FAILURE'
,
tb
.
traceback_string
()
+
' REPR:'
+
repr
(
data
))
raise
DNS_Soft_Error
(
(
qname
,
qtype
,
ip
,
'Unknown Error'
)
)
raise
DNS_Soft_Error
(
qname
,
qtype
,
ip
,
'Unknown Error'
)
if
reply
.
id
!=
qid
:
# probably a DoS attack...
self
.
log
(
'DNS.RESPONSE_ERROR'
,
'id(%i)!=qid(%i)'
%
(
reply
.
id
,
qid
),
ip
,
qname
)
...
...
@@ -307,12 +307,12 @@ class dns_cache:
elif
reply
.
rcode
and
reply
.
rcode
!=
packet
.
RCODE
.
NXDomain
:
rcode
=
packet
.
RCODE_MAP
.
get
(
reply
.
rcode
,
str
(
reply
.
rcode
))
self
.
log
(
'DNS.RESPONSE_ERROR'
,
'rcode=%s data=%r'
%
(
rcode
,
repr
(
data
)),
ip
,
qname
)
raise
DNS_Soft_Error
(
(
qname
,
qtype
,
ip
,
rcode
)
)
raise
DNS_Soft_Error
(
qname
,
qtype
,
ip
,
rcode
)
else
:
return
reply
except
OSError
,
why
:
self
.
log
(
'DNS.NETWORK_ERROR'
,
why
,
ip
,
qname
)
raise
DNS_Soft_Error
(
(
qname
,
qtype
,
ip
,
str
(
why
)
))
raise
DNS_Soft_Error
(
qname
,
qtype
,
ip
,
str
(
why
))
except
EOFError
:
# recv_exact will raise EOFError if it doesn't get enough data.
self
.
log
(
'DNS.NETWORK_ERROR'
,
'EOF'
,
ip
,
qname
)
...
...
@@ -364,7 +364,7 @@ class dns_cache:
if
self
.
need_bootstrapping
:
# the bootstrapping process failed
self
.
log
(
'DNS.BOOTSTRAP_FAILED'
)
raise
DNS_Soft_Error
(
(
''
,
'NS'
,
'bootstrapping'
,
'Failed to bootstrap the DNS cache.'
)
)
raise
DNS_Soft_Error
(
''
,
'NS'
,
'bootstrapping'
,
'Failed to bootstrap the DNS cache.'
)
elif
self
.
need_bootstrapping
==
1
:
# need to bootstrap the cache
self
.
need_bootstrapping
=
2
...
...
@@ -416,7 +416,7 @@ class dns_cache:
except
coro
.
TimeoutError
:
pass
self
.
log
(
'DNS.BOOTSTRAP_FAILED'
)
raise
DNS_Soft_Error
(
(
''
,
'NS'
,
'bootstrapping'
,
'Failed to bootstrap the DNS cache.'
)
)
raise
DNS_Soft_Error
(
''
,
'NS'
,
'bootstrapping'
,
'Failed to bootstrap the DNS cache.'
)
def
authoritative
(
self
,
name
,
base
):
"is a reply from server for <base> authoritative for <name>?"
...
...
@@ -520,7 +520,7 @@ class dns_cache:
if
data0
is
CACHE_NXDOMAIN
:
# negative cache
cache_exception
.
inc
()
raise
DNS_Hard_Error
(
(
qname
,
qtype
,
(
packet
.
RCODE
.
NXDomain
,
'NXDomain'
)
))
raise
DNS_Hard_Error
(
qname
,
qtype
,
(
packet
.
RCODE
.
NXDomain
,
'NXDomain'
))
elif
data0
is
CACHE_NODATA
:
# negative cache
# [XXX in what way does this qualify as an exception?]
...
...
@@ -580,7 +580,7 @@ class dns_cache:
if
self
.
debug
:
self
.
log
(
'DNS.QUERY'
,
'Q'
,
work
.
indent
(),
"%r, %r"
%
(
qname
,
qtype
))
if
not
packet
.
dot_sane
(
qname
):
raise
DNS_Malformed_Qname_Error
(
(
qname
,
qtype
,
(
packet
.
RCODE
.
ServFail
,
''
)
))
raise
DNS_Malformed_Qname_Error
(
qname
,
qtype
,
(
packet
.
RCODE
.
ServFail
,
''
))
if
not
no_cache
:
results
=
self
.
cache_get
(
qname
,
qtype
,
None
)
if
results
is
not
None
:
...
...
@@ -701,7 +701,7 @@ class dns_cache:
self
.
encache
(
qname
,
qtype
,
[(
ttl
,
CACHE_NXDOMAIN
)],
stomp
=
1
)
if
self
.
debug
:
self
.
log
(
'DNS.NXDOMAIN'
,
qname
,
qtype
)
raise
DNS_Hard_Error
(
(
qname
,
qtype
,
(
r
.
rcode
,
packet
.
RCODE_MAP
[
r
.
rcode
])
))
raise
DNS_Hard_Error
(
qname
,
qtype
,
(
r
.
rcode
,
packet
.
RCODE_MAP
[
r
.
rcode
]
))
# 3.``The query name has one or more records answering the query.'' This applies if
# the answer section of the response contains one or more records under the query
...
...
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