Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
3f0ec99b
Commit
3f0ec99b
authored
8 years ago
by
Pierre Lalet
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #548 from gpotter2/fix-as-resolver
[Tests] Fix AS_RESOLVER
parents
525339ef
d5670e8b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/as_resolvers.py
+13
-5
13 additions, 5 deletions
scapy/as_resolvers.py
test/regression.uts
+2
-2
2 additions, 2 deletions
test/regression.uts
with
15 additions
and
7 deletions
scapy/as_resolvers.py
+
13
−
5
View file @
3f0ec99b
...
...
@@ -8,7 +8,7 @@ Resolve Autonomous Systems (AS).
"""
import
socket
import
socket
,
errno
from
scapy.config
import
conf
class
AS_resolver
:
...
...
@@ -91,12 +91,12 @@ class AS_resolver_cymru(AS_resolver):
asn
,
ip
,
desc
=
map
(
str
.
strip
,
l
.
split
(
"
|
"
))
if
asn
==
"
NA
"
:
continue
asn
=
int
(
asn
)
ASNlist
.
append
((
ip
,
asn
,
desc
))
asn
=
"
AS
"
+
str
(
int
(
asn
)
)
ASNlist
.
append
((
ip
,
asn
,
desc
))
return
ASNlist
class
AS_resolver_multi
(
AS_resolver
):
resolvers_list
=
(
AS_resolver_cymru
(),
AS_resolver_riswhois
(),
AS_resolver_radb
()
)
resolvers_list
=
(
AS_resolver_riswhois
(),
AS_resolver_radb
()
,
AS_resolver_cymru
()
)
def
__init__
(
self
,
*
reslist
):
if
reslist
:
self
.
resolvers_list
=
reslist
...
...
@@ -104,10 +104,18 @@ class AS_resolver_multi(AS_resolver):
todo
=
ips
ret
=
[]
for
ASres
in
self
.
resolvers_list
:
res
=
ASres
.
resolve
(
*
todo
)
try
:
res
=
ASres
.
resolve
(
*
todo
)
except
socket
.
error
as
e
:
if
e
[
0
]
in
[
errno
.
ECONNREFUSED
,
errno
.
ETIMEDOUT
,
errno
.
ECONNRESET
]:
continue
resolved
=
[
ip
for
ip
,
asn
,
desc
in
res
]
todo
=
[
ip
for
ip
in
todo
if
ip
not
in
resolved
]
ret
+=
res
if
len
(
todo
)
==
0
:
break
if
len
(
ips
)
!=
len
(
ret
):
raise
RuntimeError
(
"
Could not contact whois providers
"
)
return
ret
...
...
This diff is collapsed.
Click to expand it.
test/regression.uts
+
2
−
2
View file @
3f0ec99b
...
...
@@ -508,7 +508,7 @@ success = False
for i in xrange(5):
try:
ret = conf.AS_resolver.resolve("8.8.8.8", "8.8.4.4")
except
socket.e
rror:
except
RuntimeE
rror:
time.sleep(2)
else:
success = True
...
...
@@ -516,7 +516,7 @@ for i in xrange(5):
assert (len(ret) == 2)
all(x[1] == 15169 for x in ret)
all(x[1] ==
"AS
15169
"
for x in ret)
############
...
...
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