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
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
Boris Kocherov
re6stnet
Commits
f2363823
Commit
f2363823
authored
Jul 27, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New --console option
parent
f3d45f8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
0 deletions
+87
-0
re6st/cli/node.py
re6st/cli/node.py
+18
-0
re6st/debug.py
re6st/debug.py
+69
-0
No files found.
re6st/cli/node.py
View file @
f2363823
...
@@ -56,6 +56,11 @@ def getConfig():
...
@@ -56,6 +56,11 @@ def getConfig():
help
=
"Exit after configuration parsing. Status code is the"
help
=
"Exit after configuration parsing. Status code is the"
" result of the given Python expression. For example:
\
n
"
" result of the given Python expression. For example:
\
n
"
" main_interface != 'eth0'"
)
" main_interface != 'eth0'"
)
_
(
'--console'
,
metavar
=
'SOCK'
,
help
=
"Socket path to Python console that can be used to inspect or"
" patch this process. Use:
\
n
"
" socat - UNIX:<SOCK>
\
n
"
"to access it."
)
_
=
parser
.
add_argument_group
(
'routing'
).
add_argument
_
=
parser
.
add_argument_group
(
'routing'
).
add_argument
_
(
'-B'
,
dest
=
'babel_args'
,
metavar
=
'ARG'
,
action
=
'append'
,
default
=
[],
_
(
'-B'
,
dest
=
'babel_args'
,
metavar
=
'ARG'
,
action
=
'append'
,
default
=
[],
...
@@ -389,10 +394,23 @@ def main():
...
@@ -389,10 +394,23 @@ def main():
tunnel_manager
.
killAll
)
tunnel_manager
.
killAll
)
except
AttributeError
:
except
AttributeError
:
pass
pass
if
config
.
console
:
from
re6st.debug
import
Console
def
console
(
socket
,
frame
=
sys
.
_getframe
()):
try
:
import
pdb
;
pdb
.
Pdb
(
stdin
=
socket
,
stdout
=
socket
).
set_trace
()
frame
.
f_locals
# main() locals
finally
:
socket
.
close
()
console
=
Console
(
config
.
console
,
console
)
cleanup
.
append
(
console
.
close
)
# main loop
# main loop
exit
.
release
()
exit
.
release
()
select_list
=
[
forwarder
.
select
]
if
forwarder
else
[]
select_list
=
[
forwarder
.
select
]
if
forwarder
else
[]
if
config
.
console
:
select_list
.
append
(
console
.
select
)
select_list
+=
tunnel_manager
.
select
,
utils
.
select
select_list
+=
tunnel_manager
.
select
,
utils
.
select
while
True
:
while
True
:
args
=
R
.
copy
(),
{},
[]
args
=
R
.
copy
(),
{},
[]
...
...
re6st/debug.py
0 → 100644
View file @
f2363823
import
errno
,
os
,
socket
,
stat
,
threading
class
Socket
(
object
):
def
__init__
(
self
,
socket
):
# In case that the default timeout is not None.
socket
.
settimeout
(
None
)
self
.
_socket
=
socket
self
.
_buf
=
''
def
close
(
self
):
self
.
_socket
.
close
()
def
write
(
self
,
data
):
self
.
_socket
.
send
(
data
)
def
readline
(
self
):
recv
=
self
.
_socket
.
recv
data
=
self
.
_buf
while
True
:
i
=
1
+
data
.
find
(
'
\
n
'
)
if
i
:
self
.
_buf
=
data
[
i
:]
return
data
[:
i
]
d
=
recv
(
4096
)
data
+=
d
if
not
d
:
self
.
_buf
=
''
return
data
def
flush
(
self
):
pass
def
closed
(
self
):
self
.
_socket
.
setblocking
(
0
)
try
:
self
.
_socket
.
recv
(
0
)
return
True
except
socket
.
error
,
(
err
,
_
):
if
err
!=
errno
.
EAGAIN
:
raise
self
.
_socket
.
setblocking
(
1
)
return
False
class
Console
(
object
):
def
__init__
(
self
,
path
,
pdb
):
self
.
path
=
path
s
=
socket
.
socket
(
socket
.
AF_UNIX
)
try
:
self
.
close
()
except
OSError
,
e
:
if
e
.
errno
!=
errno
.
ENOENT
:
raise
s
.
bind
(
path
)
s
.
listen
(
5
)
def
accept
():
t
=
threading
.
Thread
(
target
=
pdb
,
args
=
(
Socket
(
s
.
accept
()[
0
]),))
t
.
daemon
=
True
t
.
start
()
def
select
(
r
,
w
,
t
):
r
[
s
]
=
accept
self
.
select
=
select
def
close
(
self
):
if
stat
.
S_ISSOCK
(
os
.
lstat
(
self
.
path
).
st_mode
):
os
.
remove
(
self
.
path
)
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