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
40d4e496
Commit
40d4e496
authored
Apr 08, 2015
by
Julien Muchembled
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backward compatibility for Python 2.6
parent
2fb63515
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
re6st/cache.py
re6st/cache.py
+11
-3
re6st/registry.py
re6st/registry.py
+4
-2
re6stnet
re6stnet
+1
-1
No files found.
re6st/cache.py
View file @
40d4e496
...
@@ -27,7 +27,7 @@ class Cache(object):
...
@@ -27,7 +27,7 @@ class Cache(object):
q
(
"CREATE INDEX volatile.stat_try ON stat(try)"
)
q
(
"CREATE INDEX volatile.stat_try ON stat(try)"
)
q
(
"INSERT INTO volatile.stat (peer) SELECT prefix FROM peer"
)
q
(
"INSERT INTO volatile.stat (peer) SELECT prefix FROM peer"
)
self
.
_db
.
commit
()
self
.
_db
.
commit
()
self
.
_loadConfig
(
q
(
"SELECT * FROM config"
))
self
.
_loadConfig
(
self
.
_selectConfig
(
q
))
try
:
try
:
cert
.
verifyVersion
(
self
.
version
)
cert
.
verifyVersion
(
self
.
version
)
except
(
AttributeError
,
x509
.
VerifyError
):
except
(
AttributeError
,
x509
.
VerifyError
):
...
@@ -63,6 +63,11 @@ class Cache(object):
...
@@ -63,6 +63,11 @@ class Cache(object):
"value"
)
"value"
)
return
db
return
db
@
staticmethod
def
_selectConfig
(
execute
):
# BBB: blob
return
((
k
,
str
(
v
)
if
type
(
v
)
is
buffer
else
v
)
for
k
,
v
in
execute
(
"SELECT * FROM config"
))
def
_loadConfig
(
self
,
config
):
def
_loadConfig
(
self
,
config
):
cls
=
self
.
__class__
cls
=
self
.
__class__
logging
.
debug
(
"Loading network parameters:"
)
logging
.
debug
(
"Loading network parameters:"
)
...
@@ -98,7 +103,7 @@ class Cache(object):
...
@@ -98,7 +103,7 @@ class Cache(object):
old
=
{}
old
=
{}
with
self
.
_db
as
db
:
with
self
.
_db
as
db
:
remove
=
[]
remove
=
[]
for
k
,
v
in
db
.
execute
(
"SELECT * FROM config"
):
for
k
,
v
in
self
.
_selectConfig
(
db
.
execute
):
if
k
in
config
:
if
k
in
config
:
old
[
k
]
=
v
old
[
k
]
=
v
continue
continue
...
@@ -109,8 +114,11 @@ class Cache(object):
...
@@ -109,8 +114,11 @@ class Cache(object):
remove
.
append
(
k
)
remove
.
append
(
k
)
db
.
execute
(
"DELETE FROM config WHERE name in ('%s')"
db
.
execute
(
"DELETE FROM config WHERE name in ('%s')"
%
"','"
.
join
(
remove
))
%
"','"
.
join
(
remove
))
# BBB: Use buffer because of http://bugs.python.org/issue13676
# on Python 2.6
db
.
executemany
(
"INSERT OR REPLACE INTO config VALUES(?,?)"
,
db
.
executemany
(
"INSERT OR REPLACE INTO config VALUES(?,?)"
,
config
.
iteritems
())
((
k
,
buffer
(
v
)
if
k
in
base64
else
v
)
for
k
,
v
in
config
.
iteritems
()))
self
.
_loadConfig
(
config
.
iteritems
())
self
.
_loadConfig
(
config
.
iteritems
())
return
[
k
for
k
,
v
in
config
.
iteritems
()
return
[
k
for
k
,
v
in
config
.
iteritems
()
if
k
not
in
old
or
old
[
k
]
!=
v
]
if
k
not
in
old
or
old
[
k
]
!=
v
]
...
...
re6st/registry.py
View file @
40d4e496
...
@@ -61,7 +61,7 @@ class RegistryServer(object):
...
@@ -61,7 +61,7 @@ class RegistryServer(object):
"name TEXT PRIMARY KEY NOT NULL"
,
"name TEXT PRIMARY KEY NOT NULL"
,
"value"
)
"value"
)
self
.
prefix
=
self
.
getConfig
(
"prefix"
,
None
)
self
.
prefix
=
self
.
getConfig
(
"prefix"
,
None
)
self
.
version
=
s
elf
.
getConfig
(
"version"
,
"
\
0
"
)
self
.
version
=
s
tr
(
self
.
getConfig
(
"version"
,
"
\
0
"
))
# BBB: blob
utils
.
sqliteCreateTable
(
self
.
db
,
"token"
,
utils
.
sqliteCreateTable
(
self
.
db
,
"token"
,
"token TEXT PRIMARY KEY NOT NULL"
,
"token TEXT PRIMARY KEY NOT NULL"
,
"email TEXT NOT NULL"
,
"email TEXT NOT NULL"
,
...
@@ -129,7 +129,9 @@ class RegistryServer(object):
...
@@ -129,7 +129,9 @@ class RegistryServer(object):
if
config
!=
self
.
getConfig
(
'last_config'
,
None
):
if
config
!=
self
.
getConfig
(
'last_config'
,
None
):
self
.
version
=
self
.
encodeVersion
(
self
.
version
=
self
.
encodeVersion
(
1
+
self
.
decodeVersion
(
self
.
version
))
1
+
self
.
decodeVersion
(
self
.
version
))
self
.
setConfig
(
'version'
,
self
.
version
)
# BBB: Use buffer because of http://bugs.python.org/issue13676
# on Python 2.6
self
.
setConfig
(
'version'
,
buffer
(
self
.
version
))
self
.
setConfig
(
'last_config'
,
config
)
self
.
setConfig
(
'last_config'
,
config
)
self
.
sendto
(
self
.
prefix
,
0
)
self
.
sendto
(
self
.
prefix
,
0
)
kw
[
''
]
=
'version'
,
kw
[
''
]
=
'version'
,
...
...
re6stnet
View file @
40d4e496
...
@@ -273,7 +273,7 @@ def main():
...
@@ -273,7 +273,7 @@ def main():
ipv4
=
getattr
(
cache
,
'ipv4'
,
None
)
ipv4
=
getattr
(
cache
,
'ipv4'
,
None
)
if
ipv4
:
if
ipv4
:
serial
=
int
(
cert
.
cert
.
get_subject
().
serialNumber
)
serial
=
int
(
cert
.
cert
.
get_subject
().
serialNumber
)
if
serial
.
bit_length
()
<=
cache
.
ipv4_sublen
<=
16
:
if
cache
.
ipv4_sublen
<=
16
and
serial
<
1
<<
cache
.
ipv4_sublen
:
dot4
=
lambda
x
:
socket
.
inet_ntoa
(
struct
.
pack
(
'!I'
,
x
))
dot4
=
lambda
x
:
socket
.
inet_ntoa
(
struct
.
pack
(
'!I'
,
x
))
ip4
(
'route'
,
'unreachable'
,
ipv4
,
'proto'
,
'static'
)
ip4
(
'route'
,
'unreachable'
,
ipv4
,
'proto'
,
'static'
)
ipv4
,
n
=
ipv4
.
split
(
'/'
)
ipv4
,
n
=
ipv4
.
split
(
'/'
)
...
...
Julien Muchembled
@jm
mentioned in commit
889fde3b
·
Dec 27, 2019
mentioned in commit
889fde3b
mentioned in commit 889fde3b4f34dff0e2d10c46c7ae17e6b44dab20
Toggle commit list
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