Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
bb1031b6
Commit
bb1031b6
authored
Mar 25, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改 request type handle
parent
7a3ef527
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
41 deletions
+27
-41
interface.py
coco/interface.py
+25
-35
models.py
coco/models.py
+1
-1
sshd.py
coco/sshd.py
+1
-5
No files found.
coco/interface.py
View file @
bb1031b6
...
@@ -91,30 +91,31 @@ class SSHInterface(paramiko.ServerInterface):
...
@@ -91,30 +91,31 @@ class SSHInterface(paramiko.ServerInterface):
def
check_channel_direct_tcpip_request
(
self
,
chanid
,
origin
,
destination
):
def
check_channel_direct_tcpip_request
(
self
,
chanid
,
origin
,
destination
):
logger
.
debug
(
"Check channel direct tcpip request:
%
d
%
s
%
s"
%
logger
.
debug
(
"Check channel direct tcpip request:
%
d
%
s
%
s"
%
(
chanid
,
origin
,
destination
))
(
chanid
,
origin
,
destination
))
self
.
request
.
type
=
'direct-tcpip'
self
.
request
.
type
.
append
(
'direct-tcpip'
)
self
.
request
.
meta
=
{
self
.
request
.
meta
.
update
(
{
'chanid'
:
chanid
,
'origin'
:
origin
,
'chanid'
:
chanid
,
'origin'
:
origin
,
'destination'
:
destination
,
'destination'
:
destination
,
}
}
)
self
.
event
.
set
()
self
.
event
.
set
()
return
0
return
0
def
check_channel_env_request
(
self
,
channel
,
name
,
value
):
def
check_channel_env_request
(
self
,
channel
,
name
,
value
):
logger
.
debug
(
"Check channel env request:
%
s,
%
s,
%
s"
%
logger
.
debug
(
"Check channel env request:
%
s,
%
s,
%
s"
%
(
channel
,
name
,
value
))
(
channel
,
name
,
value
))
self
.
request
.
type
.
append
(
'env'
)
return
False
return
False
def
check_channel_exec_request
(
self
,
channel
,
command
):
def
check_channel_exec_request
(
self
,
channel
,
command
):
logger
.
debug
(
"Check channel exec request: `
%
s`"
%
command
)
logger
.
debug
(
"Check channel exec request: `
%
s`"
%
command
)
self
.
request
.
type
=
'exec'
self
.
request
.
type
.
append
(
'exec'
)
self
.
request
.
meta
=
{
'channel'
:
channel
,
'command'
:
command
}
self
.
request
.
meta
.
update
({
'channel'
:
channel
.
get_id
(),
'command'
:
command
})
self
.
event
.
set
()
self
.
event
.
set
()
return
False
return
False
def
check_channel_forward_agent_request
(
self
,
channel
):
def
check_channel_forward_agent_request
(
self
,
channel
):
logger
.
debug
(
"Check channel forward agent request:
%
s"
%
channel
)
logger
.
debug
(
"Check channel forward agent request:
%
s"
%
channel
)
self
.
request
.
type
=
"forward-agent"
self
.
request
.
type
.
append
(
"forward-agent"
)
self
.
request
.
meta
[
'channel'
]
=
channel
.
get_id
(
)
self
.
request
.
meta
.
update
({
'channel'
:
channel
.
get_id
()}
)
self
.
event
.
set
()
self
.
event
.
set
()
return
False
return
False
...
@@ -123,12 +124,12 @@ class SSHInterface(paramiko.ServerInterface):
...
@@ -123,12 +124,12 @@ class SSHInterface(paramiko.ServerInterface):
pixelwidth
,
pixelheight
,
modes
):
pixelwidth
,
pixelheight
,
modes
):
logger
.
info
(
"Check channel pty request:
%
s
%
s
%
s
%
s
%
s"
%
logger
.
info
(
"Check channel pty request:
%
s
%
s
%
s
%
s
%
s"
%
(
term
,
width
,
height
,
pixelwidth
,
pixelheight
))
(
term
,
width
,
height
,
pixelwidth
,
pixelheight
))
self
.
request
.
type
=
'pty'
self
.
request
.
type
.
append
(
'pty'
)
self
.
request
.
meta
=
{
self
.
request
.
meta
.
update
(
{
'channel'
:
channel
,
'term'
:
term
,
'width'
:
width
,
'channel'
:
channel
,
'term'
:
term
,
'width'
:
width
,
'height'
:
height
,
'pixelwidth'
:
pixelwidth
,
'height'
:
height
,
'pixelwidth'
:
pixelwidth
,
'pixelheight'
:
pixelheight
,
'pixelheight'
:
pixelheight
,
}
}
)
self
.
event
.
set
()
self
.
event
.
set
()
return
True
return
True
...
@@ -143,17 +144,19 @@ class SSHInterface(paramiko.ServerInterface):
...
@@ -143,17 +144,19 @@ class SSHInterface(paramiko.ServerInterface):
def
check_channel_subsystem_request
(
self
,
channel
,
name
):
def
check_channel_subsystem_request
(
self
,
channel
,
name
):
logger
.
info
(
"Check channel subsystem request:
%
s
%
s"
%
(
channel
,
name
))
logger
.
info
(
"Check channel subsystem request:
%
s
%
s"
%
(
channel
,
name
))
self
.
request
.
type
=
'subsystem'
self
.
request
.
type
.
append
(
'subsystem'
)
self
.
request
.
meta
=
{
'channel'
:
channel
,
'name'
:
name
}
self
.
request
.
meta
.
update
({
'channel'
:
channel
.
get_id
(),
'name'
:
name
})
self
.
event
.
set
()
self
.
event
.
set
()
return
False
return
False
def
check_channel_window_change_request
(
self
,
channel
,
width
,
height
,
def
check_channel_window_change_request
(
self
,
channel
,
width
,
height
,
pixelwidth
,
pixelheight
):
pixelwidth
,
pixelheight
):
self
.
request
.
meta
[
'width'
]
=
width
self
.
request
.
meta
.
update
({
self
.
request
.
meta
[
'height'
]
=
height
'width'
:
width
,
self
.
request
.
meta
[
'pixelwidth'
]
=
pixelwidth
'height'
:
height
,
self
.
request
.
meta
[
'pixelheight'
]
=
pixelheight
'pixelwidth'
:
pixelwidth
,
'pixelheight'
:
pixelheight
,
})
self
.
request
.
change_size_event
.
set
()
self
.
request
.
change_size_event
.
set
()
return
True
return
True
...
@@ -162,19 +165,19 @@ class SSHInterface(paramiko.ServerInterface):
...
@@ -162,19 +165,19 @@ class SSHInterface(paramiko.ServerInterface):
logger
.
info
(
"Check channel x11 request
%
s
%
s
%
s
%
s
%
s"
%
logger
.
info
(
"Check channel x11 request
%
s
%
s
%
s
%
s
%
s"
%
(
channel
,
single_connection
,
auth_protocol
,
(
channel
,
single_connection
,
auth_protocol
,
auth_cookie
,
screen_number
))
auth_cookie
,
screen_number
))
self
.
request
.
type
=
'x11'
self
.
request
.
type
.
append
(
'x11'
)
self
.
request
.
meta
=
{
self
.
request
.
meta
.
update
(
{
'channel'
:
channel
,
'single_connection'
:
single_connection
,
'channel'
:
channel
.
get_id
()
,
'single_connection'
:
single_connection
,
'auth_protocol'
:
auth_protocol
,
'auth_cookie'
:
auth_cookie
,
'auth_protocol'
:
auth_protocol
,
'auth_cookie'
:
auth_cookie
,
'screen_number'
:
screen_number
,
'screen_number'
:
screen_number
,
}
}
)
self
.
event
.
set
()
self
.
event
.
set
()
return
False
return
False
def
check_port_forward_request
(
self
,
address
,
port
):
def
check_port_forward_request
(
self
,
address
,
port
):
logger
.
info
(
"Check channel port forward request:
%
s
%
s"
%
(
address
,
port
))
logger
.
info
(
"Check channel port forward request:
%
s
%
s"
%
(
address
,
port
))
self
.
request
.
type
=
'port-forward'
self
.
request
.
type
.
append
(
'port-forward'
)
self
.
request
.
meta
=
{
'address'
:
address
,
'port'
:
port
}
self
.
request
.
meta
.
update
({
'address'
:
address
,
'port'
:
port
})
self
.
event
.
set
()
self
.
event
.
set
()
return
False
return
False
...
@@ -185,16 +188,3 @@ class SSHInterface(paramiko.ServerInterface):
...
@@ -185,16 +188,3 @@ class SSHInterface(paramiko.ServerInterface):
# print("GC: SSH interface gc")
# print("GC: SSH interface gc")
coco/models.py
View file @
bb1031b6
...
@@ -13,7 +13,7 @@ logger = utils.get_logger(__file__)
...
@@ -13,7 +13,7 @@ logger = utils.get_logger(__file__)
class
Request
:
class
Request
:
def
__init__
(
self
,
addr
):
def
__init__
(
self
,
addr
):
self
.
type
=
""
self
.
type
=
[]
self
.
meta
=
{
"width"
:
80
,
"height"
:
24
}
self
.
meta
=
{
"width"
:
80
,
"height"
:
24
}
self
.
user
=
None
self
.
user
=
None
self
.
addr
=
addr
self
.
addr
=
addr
...
...
coco/sshd.py
View file @
bb1031b6
...
@@ -97,13 +97,9 @@ class SSHServer:
...
@@ -97,13 +97,9 @@ class SSHServer:
def
dispatch
(
self
,
client
):
def
dispatch
(
self
,
client
):
request_type
=
client
.
request
.
type
request_type
=
client
.
request
.
type
if
request_type
==
'pty'
or
request_type
==
'x11'
:
if
'pty'
in
request_type
:
logger
.
info
(
"Request type `pty`, dispatch to interactive mode"
)
logger
.
info
(
"Request type `pty`, dispatch to interactive mode"
)
InteractiveServer
(
self
.
app
,
client
)
.
interact
()
InteractiveServer
(
self
.
app
,
client
)
.
interact
()
elif
request_type
==
'exec'
:
pass
elif
request_type
==
'subsystem'
:
pass
else
:
else
:
client
.
send
(
"Not support request type:
%
s"
%
request_type
)
client
.
send
(
"Not support request type:
%
s"
%
request_type
)
...
...
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