Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
de0f8c24
Commit
de0f8c24
authored
Sep 22, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish example
parent
f946a4bf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
server.py
server.py
+21
-2
No files found.
server.py
View file @
de0f8c24
...
...
@@ -116,22 +116,41 @@ class SSHServer:
if
not
service
.
event
.
is_set
():
print
(
'*** Client never asked for a shell.'
)
return
server_data
=
[]
input_mode
=
True
while
True
:
r
,
w
,
e
=
select
.
select
([
server_chan
,
chan
],
[],
[])
if
chan
in
r
:
recv_data
=
chan
.
recv
(
1024
)
.
decode
(
'utf8'
)
print
(
"From client: "
+
repr
(
recv_data
))
#
print("From client: " + repr(recv_data))
if
len
(
recv_data
)
==
0
:
break
server_chan
.
send
(
recv_data
)
if
server_chan
in
r
:
recv_data
=
server_chan
.
recv
(
1024
)
.
decode
(
'utf8'
)
print
(
"From server: "
+
repr
(
recv_data
))
#
print("From server: " + repr(recv_data))
if
len
(
recv_data
)
==
0
:
break
chan
.
send
(
recv_data
)
if
len
(
recv_data
)
>
20
:
server_data
.
append
(
'...'
)
else
:
server_data
.
append
(
recv_data
)
try
:
if
repr
(
server_data
[
-
2
])
==
u'
\r\n
'
:
result
=
server_data
.
pop
()
server_data
.
pop
()
command
=
''
.
join
(
server_data
)
server_data
=
[]
print
(
">>> Command:
%
s"
%
command
)
print
(
result
)
except
IndexError
:
pass
print
(
server_data
)
except
Exception
as
e
:
print
(
'*** Caught exception: '
+
str
(
e
.
__class__
)
+
': '
+
str
(
e
))
...
...
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