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
8d07244c
Commit
8d07244c
authored
Jul 11, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed ip from cert in vifibnet.py
parent
bf262697
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
vifibnet.py
vifibnet.py
+8
-6
No files found.
vifibnet.py
View file @
8d07244c
#!/usr/bin/env python
import
argparse
,
errno
,
os
,
select
,
sqlite3
,
subprocess
,
sys
,
time
,
xmlrpclib
import
argparse
,
errno
,
math
,
os
,
select
,
sqlite3
,
subprocess
,
sys
,
time
,
xmlrpclib
from
OpenSSL
import
crypto
import
traceback
import
upnpigd
...
...
@@ -56,8 +56,9 @@ class PeersDB:
log
.
log
(
'Updating peers database : unusing peer '
+
str
(
id
),
5
)
self
.
db
.
execute
(
"UPDATE peers SET used = 0 WHERE id = ?"
,
(
id
,))
def
ipFromPrefix
(
prefix
):
tmp
=
hex
(
int
(
prefix
,
2
))[
2
:]
def
ipFromPrefix
(
prefix
,
prefix_len
):
tmp
=
hex
(
int
(
prefix
))[
2
:]
tmp
=
tmp
.
rjust
(
int
((
math
.
ceil
(
float
(
prefix_len
)
/
4
))),
'0'
)
ip
=
VIFIB_NET
for
i
in
xrange
(
0
,
len
(
tmp
),
4
):
ip
+=
tmp
[
i
:
i
+
4
]
+
':'
...
...
@@ -113,6 +114,7 @@ def getConfig():
_
(
'--cert'
,
required
=
True
,
help
=
'Path to the certificate file'
)
# Temporary args - to be removed
# Can be removed, should ip be a global variable ?
_
(
'--ip'
,
required
=
True
,
help
=
'IPv6 of the server'
)
# Openvpn options
...
...
@@ -123,8 +125,8 @@ def getConfig():
with
open
(
config
.
cert
,
'r'
)
as
f
:
cert
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
f
.
read
())
subject
=
cert
.
get_subject
()
prefix
,
_
=
subject
.
serialNumber
.
split
(
'/'
)
ip
=
ipFromPrefix
(
prefix
)
prefix
,
prefix_len
=
subject
.
serialNumber
.
split
(
'/'
)
ip
=
ipFromPrefix
(
prefix
,
int
(
prefix_len
)
)
print
ip
log
.
log
(
'Intranet ip : %s'
%
(
ip
,),
4
)
if
config
.
openvpn_args
[
0
]
==
"--"
:
...
...
@@ -198,7 +200,7 @@ def main():
# Get arguments
getConfig
()
log
.
verbose
=
config
.
verbose
# TODO:
get proto to
use ?
# TODO:
how do we decide which protocol we
use ?
(
externalIp
,
externalPort
)
=
upnpigd
.
GetExternalInfo
(
1194
)
# Setup database
...
...
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