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
f8818c07
Commit
f8818c07
authored
Mar 09, 2013
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolver interface for coro.socket
parent
05f45e9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
coro/dns/cache.py
coro/dns/cache.py
+24
-3
No files found.
coro/dns/cache.py
View file @
f8818c07
...
...
@@ -834,9 +834,12 @@ class dns_cache:
del
self
.
cache
[
key
]
def
permute
(
x
):
x0
=
list
(
x
)
random
.
shuffle
(
x0
)
return
x0
if
len
(
x
)
==
1
:
return
x
else
:
x0
=
list
(
x
)
random
.
shuffle
(
x0
)
return
x0
import
coro
import
coro.dns
...
...
@@ -856,6 +859,24 @@ set_seed (os.urandom (128))
if
not
coro
.
has_ipv6
():
root_hints
=
[
x
for
x
in
root_hints
if
not
':'
in
x
]
class
resolver
:
def
__init__
(
self
):
self
.
cache
=
dns_cache
()
def
gethostbyname
(
self
,
name
,
qtype
):
for
ttl
,
addr
in
permute
(
self
.
cache
.
query
(
name
,
qtype
)):
return
addr
def
resolve_ipv4
(
self
,
name
):
return
self
.
gethostbyname
(
name
,
'A'
)
def
resolve_ipv6
(
self
,
name
):
return
self
.
gethostbyname
(
name
,
'AAAA'
)
def
install
():
"install the builtin resolver into the coro socket layer"
coro
.
set_resolver
(
resolver
())
# emulate 'statsmon' module
class
StaticCounter
:
def
__init__
(
self
,
name
):
...
...
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