Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
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
Kirill Smelkov
shrapnel
Commits
94ac9f9a
Commit
94ac9f9a
authored
May 09, 2013
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
__init__(): pass in a 'new channel class'
msg_channel_open(): construct a new channel class & send confirm
parent
0ab9647a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
coro/ssh/connection/connect.py
coro/ssh/connection/connect.py
+30
-1
No files found.
coro/ssh/connection/connect.py
View file @
94ac9f9a
...
@@ -32,6 +32,7 @@ __version__ = '$Revision: #1 $'
...
@@ -32,6 +32,7 @@ __version__ = '$Revision: #1 $'
from
coro.ssh.transport
import
SSH_Service
from
coro.ssh.transport
import
SSH_Service
from
coro.ssh.util
import
packet
as
ssh_packet
from
coro.ssh.util
import
packet
as
ssh_packet
from
coro.ssh.util
import
debug
as
ssh_debug
from
coro.ssh.util
import
debug
as
ssh_debug
from
coro.ssh.connection.channel
import
Channel
from
constants
import
*
from
constants
import
*
class
Connection_Service
(
SSH_Service
):
class
Connection_Service
(
SSH_Service
):
...
@@ -47,10 +48,11 @@ class Connection_Service(SSH_Service):
...
@@ -47,10 +48,11 @@ class Connection_Service(SSH_Service):
# The key is the remote channel ID, the value is a Remote_Channel object.
# The key is the remote channel ID, the value is a Remote_Channel object.
remote_channels
=
None
remote_channels
=
None
def
__init__
(
self
,
transport
):
def
__init__
(
self
,
transport
,
new_channel_class
=
None
):
self
.
transport
=
transport
self
.
transport
=
transport
self
.
local_channels
=
{}
self
.
local_channels
=
{}
self
.
remote_channels
=
{}
self
.
remote_channels
=
{}
self
.
new_channel_class
=
new_channel_class
callbacks
=
{
SSH_MSG_GLOBAL_REQUEST
:
self
.
msg_global_request
,
callbacks
=
{
SSH_MSG_GLOBAL_REQUEST
:
self
.
msg_global_request
,
SSH_MSG_CHANNEL_WINDOW_ADJUST
:
self
.
msg_channel_window_adjust
,
SSH_MSG_CHANNEL_WINDOW_ADJUST
:
self
.
msg_channel_window_adjust
,
...
@@ -63,6 +65,8 @@ class Connection_Service(SSH_Service):
...
@@ -63,6 +65,8 @@ class Connection_Service(SSH_Service):
SSH_MSG_CHANNEL_FAILURE
:
self
.
msg_channel_failure
,
SSH_MSG_CHANNEL_FAILURE
:
self
.
msg_channel_failure
,
SSH_MSG_CHANNEL_OPEN_CONFIRMATION
:
self
.
msg_channel_open_confirmation
,
SSH_MSG_CHANNEL_OPEN_CONFIRMATION
:
self
.
msg_channel_open_confirmation
,
SSH_MSG_CHANNEL_OPEN_FAILURE
:
self
.
msg_channel_open_failure
,
SSH_MSG_CHANNEL_OPEN_FAILURE
:
self
.
msg_channel_open_failure
,
# server side
SSH_MSG_CHANNEL_OPEN
:
self
.
msg_channel_open
,
}
}
self
.
transport
.
register_callbacks
(
'ssh-connection'
,
callbacks
)
self
.
transport
.
register_callbacks
(
'ssh-connection'
,
callbacks
)
...
@@ -167,3 +171,28 @@ class Connection_Service(SSH_Service):
...
@@ -167,3 +171,28 @@ class Connection_Service(SSH_Service):
channel
=
self
.
local_channels
[
channel_id
]
channel
=
self
.
local_channels
[
channel_id
]
# XXX: Assert that the channel is not already open?
# XXX: Assert that the channel is not already open?
channel
.
channel_open_failure
(
reason_code
,
reason_text
,
language
)
channel
.
channel_open_failure
(
reason_code
,
reason_text
,
language
)
# --------------------------------------------------------------------------------
# server side
# --------------------------------------------------------------------------------
def
msg_channel_open
(
self
,
pkt
):
_
,
channel_type
,
remote_id
,
initial_window
,
max_packet_size
=
ssh_packet
.
unpack_payload
(
SSH_MSG_CHANNEL_OPEN_PAYLOAD
,
pkt
)
channel
=
self
.
new_channel_class
(
self
)
self
.
register_channel
(
channel
)
channel
.
remote_channel
.
closed
=
0
self
.
transport
.
send
(
SSH_MSG_CHANNEL_OPEN_CONFIRMATION_PAYLOAD
,
(
SSH_MSG_CHANNEL_OPEN_CONFIRMATION
,
remote_id
,
channel
.
channel_id
,
initial_window
,
max_packet_size
,
)
)
self
.
transport
.
debug
.
write
(
ssh_debug
.
DEBUG_1
,
'channel %i open confirmation sender_channel=%i window_size=%i max_packet_size=%i'
,
(
remote_id
,
channel
.
channel_id
,
initial_window
,
max_packet_size
)
)
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