Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
re6stnet
Commits
834959b9
Commit
834959b9
authored
Jan 30, 2017
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move iterRoutes helper from draft/ to re6st.ctl module
This is a useful class that can be used for other reasons.
parent
96104548
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
21 deletions
+22
-21
draft/re6st-geo
draft/re6st-geo
+1
-21
re6st/ctl.py
re6st/ctl.py
+21
-0
No files found.
draft/re6st-geo
View file @
834959b9
...
...
@@ -7,26 +7,6 @@ if 're6st' not in sys.modules:
import
os
;
sys
.
path
[
0
]
=
os
.
path
.
dirname
(
sys
.
path
[
0
])
from
re6st
import
ctl
,
tunnel
,
utils
class
iterRoutes
(
object
):
_waiting
=
True
def
__new__
(
cls
,
control_socket
,
network
):
self
=
object
.
__new__
(
cls
)
c
=
ctl
.
Babel
(
control_socket
,
self
,
network
)
c
.
request_dump
()
while
self
.
_waiting
:
args
=
{},
{},
()
c
.
select
(
*
args
)
utils
.
select
(
*
args
)
return
(
prefix
for
neigh_routes
in
c
.
neighbours
.
itervalues
()
for
prefix
in
neigh_routes
[
1
]
if
prefix
)
def
babel_dump
(
self
):
self
.
_waiting
=
False
def
cmd_update
(
db
,
config
):
s
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
...
...
@@ -36,7 +16,7 @@ def cmd_update(db, config):
p
=
dict
(
q
(
"SELECT prefix, mode FROM ip"
))
peers
=
set
()
now
=
int
(
time
.
time
())
for
prefix
in
iterRoutes
(
config
.
control_socket
,
network
):
for
prefix
in
ctl
.
iterRoutes
(
config
.
control_socket
,
network
):
if
prefix
in
p
:
q
(
"UPDATE ip SET last=? WHERE prefix=?"
,
(
now
,
prefix
))
if
not
p
[
prefix
]:
...
...
re6st/ctl.py
View file @
834959b9
...
...
@@ -297,3 +297,24 @@ class Babel(object):
def
handle_set_cost_multiplier
(
self
,
flags
):
pass
class
iterRoutes
(
object
):
_waiting
=
True
def
__new__
(
cls
,
control_socket
,
network
):
self
=
object
.
__new__
(
cls
)
c
=
Babel
(
control_socket
,
self
,
network
)
c
.
request_dump
()
while
self
.
_waiting
:
args
=
{},
{},
()
c
.
select
(
*
args
)
utils
.
select
(
*
args
)
return
(
prefix
for
neigh_routes
in
c
.
neighbours
.
itervalues
()
for
prefix
in
neigh_routes
[
1
]
if
prefix
)
def
babel_dump
(
self
):
self
.
_waiting
=
False
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