Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
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
luna
Commits
e46c26bb
Commit
e46c26bb
authored
Dec 18, 2017
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: room support, but todo the front-end support
parent
a54b61e2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
mock.py
mock.py
+15
-4
ssh.component.ts
src/app/ControlPage/control/ssh/ssh.component.ts
+3
-0
No files found.
mock.py
View file @
e46c26bb
#!/usr/bin/env python3
from
flask
import
Flask
,
send_from_directory
,
render_template
,
request
,
jsonify
from
flask_socketio
import
SocketIO
,
Namespace
,
emit
from
flask_socketio
import
SocketIO
,
Namespace
,
emit
,
join_room
,
leave_room
import
paramiko
import
uuid
app
=
Flask
(
__name__
,
template_folder
=
'dist'
)
...
...
@@ -19,18 +20,21 @@ class SSHws(Namespace):
def
send_data
(
self
):
while
True
:
data
=
self
.
chan
.
recv
(
2048
)
.
decode
(
'utf-8'
,
'replace'
)
self
.
emit
(
'data'
,
data
)
self
.
emit
(
event
=
'data'
,
data
=
data
,
room
=
self
.
room
)
def
on_connect
(
self
):
self
.
cols
=
int
(
request
.
cookies
.
get
(
'cols'
,
80
))
self
.
rows
=
int
(
request
.
cookies
.
get
(
'rows'
,
24
))
self
.
ssh_with_password
()
def
on_data
(
self
,
message
):
self
.
chan
.
send
(
message
)
def
on_host
(
self
,
message
):
print
(
message
)
self
.
room
=
str
(
uuid
.
uuid4
())
self
.
emit
(
'room'
,
self
.
room
)
join_room
(
self
.
room
)
self
.
ssh_with_password
()
print
(
message
,
self
.
room
)
def
on_resize
(
self
,
message
):
print
(
message
)
...
...
@@ -41,6 +45,13 @@ class SSHws(Namespace):
def
on_disconnect
(
self
):
pass
def
on_join
(
self
,
room
):
join_room
(
room
)
self
.
room
=
room
def
on_leave
(
self
):
leave_room
(
self
.
room
)
@app.route
(
'/luna/<path:path>'
)
def
send_js
(
path
):
...
...
src/app/ControlPage/control/ssh/ssh.component.ts
View file @
e46c26bb
...
...
@@ -104,6 +104,9 @@ export class SshComponent implements OnInit {
NavList
.
List
[
id
].
Term
.
term
.
on
(
'data'
,
function
(
data
)
{
socket
.
emit
(
'data'
,
data
);
});
socket
.
on
(
'join'
,
function
(
room
)
{
socket
.
email
(
'room'
,
room
);
});
socket
.
on
(
'data'
,
function
(
data
)
{
...
...
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