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
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
nexedi
re6stnet
Commits
7c638d8d
Commit
7c638d8d
authored
Aug 16, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A peer now only advertise itself to 3 other peers at evry refresh
parent
f44fb44c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
re6st/tunnel.py
re6st/tunnel.py
+9
-2
No files found.
re6st/tunnel.py
View file @
7c638d8d
import
os
,
traceback
,
time
,
subprocess
,
logging
import
os
,
traceback
,
time
,
subprocess
,
logging
import
socket
import
socket
import
sets
import
random
import
plib
import
plib
import
utils
import
utils
...
@@ -125,13 +127,15 @@ class TunnelManager:
...
@@ -125,13 +127,15 @@ class TunnelManager:
def
_countRoutes
(
self
):
def
_countRoutes
(
self
):
logging
.
debug
(
'Starting to count the routes on each interface...'
)
logging
.
debug
(
'Starting to count the routes on each interface...'
)
self
.
_peer_db
.
clear_blacklist
(
0
)
self
.
_peer_db
.
clear_blacklist
(
0
)
possiblePeers
=
sets
.
Set
([])
for
iface
in
self
.
_iface_to_prefix
.
keys
():
for
iface
in
self
.
_iface_to_prefix
.
keys
():
self
.
_connection_dict
[
self
.
_iface_to_prefix
[
iface
]].
routes
=
0
self
.
_connection_dict
[
self
.
_iface_to_prefix
[
iface
]].
routes
=
0
for
line
in
open
(
'/proc/net/ipv6_route'
):
for
line
in
open
(
'/proc/net/ipv6_route'
):
line
=
line
.
split
()
line
=
line
.
split
()
ip
=
bin
(
int
(
line
[
0
],
16
))[
2
:].
rjust
(
128
,
'0'
)
ip
=
bin
(
int
(
line
[
0
],
16
))[
2
:].
rjust
(
128
,
'0'
)
if
ip
.
startswith
(
self
.
_network
):
if
(
ip
.
startswith
(
self
.
_network
)
and
not
ip
.
startswith
(
self
.
_network
+
self
.
_prefix
)):
iface
=
line
[
-
1
]
iface
=
line
[
-
1
]
subnet_size
=
int
(
line
[
1
],
16
)
subnet_size
=
int
(
line
[
1
],
16
)
logging
.
trace
(
'Route on iface %s detected to %s/%s'
logging
.
trace
(
'Route on iface %s detected to %s/%s'
...
@@ -143,7 +147,10 @@ class TunnelManager:
...
@@ -143,7 +147,10 @@ class TunnelManager:
logging
.
debug
(
'A route to %s has been discovered on the LAN'
logging
.
debug
(
'A route to %s has been discovered on the LAN'
%
(
hex
(
int
(
prefix
),
2
)[
2
:]))
%
(
hex
(
int
(
prefix
),
2
)[
2
:]))
self
.
_peer_db
.
blacklist
(
prefix
,
0
)
self
.
_peer_db
.
blacklist
(
prefix
,
0
)
self
.
_notifyPeer
(
line
[
0
])
possiblePeers
.
add
(
line
[
0
])
for
ip
in
random
.
sample
(
possiblePeers
,
min
(
3
,
len
(
possiblePeers
))):
self
.
_notifyPeer
(
ip
)
logging
.
debug
(
"Routes have been counted"
)
logging
.
debug
(
"Routes have been counted"
)
for
p
in
self
.
_connection_dict
.
keys
():
for
p
in
self
.
_connection_dict
.
keys
():
...
...
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