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
560b6de4
Commit
560b6de4
authored
Dec 15, 2017
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: on host
parent
7fe48e88
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
httpd.py
coco/httpd.py
+16
-3
No files found.
coco/httpd.py
View file @
560b6de4
...
...
@@ -12,7 +12,7 @@ from flask import Flask, send_from_directory, render_template, request, jsonify
# Todo: Remove for future
from
jms.models
import
User
from
.models
import
Request
,
Client
,
WSProxy
from
.
interactive
import
Interactive
Server
from
.
forward
import
Proxy
Server
__version__
=
'0.4.0'
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
...
...
@@ -55,7 +55,7 @@ class SSHws(Namespace, BaseWebSocketHandler):
self
.
ssh
=
paramiko
.
SSHClient
()
self
.
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
self
.
ssh
.
connect
(
"127.0.0.1"
,
22
,
"liuzheng"
,
"liuzheng"
)
self
.
chan
=
self
.
ssh
.
invoke_shell
(
term
=
'xterm'
,
width
=
self
.
cols
,
height
=
self
.
r
a
ws
)
self
.
chan
=
self
.
ssh
.
invoke_shell
(
term
=
'xterm'
,
width
=
self
.
cols
,
height
=
self
.
r
o
ws
)
self
.
socketio
.
start_background_task
(
self
.
send_data
)
# self.chan.settimeout(0.1)
...
...
@@ -68,7 +68,9 @@ class SSHws(Namespace, BaseWebSocketHandler):
self
.
cols
=
int
(
request
.
cookies
.
get
(
'cols'
,
80
))
self
.
rows
=
int
(
request
.
cookies
.
get
(
'rows'
,
24
))
self
.
prepare
(
request
)
InteractiveServer
(
self
.
app
,
self
.
client
)
.
interact_async
()
self
.
forwarder
=
ProxyServer
(
self
.
app
,
self
.
client
)
# InteractiveServer(self.app, self.client).interact_async()
def
on_data
(
self
,
message
):
# self.chan.send(message)
...
...
@@ -82,6 +84,17 @@ class SSHws(Namespace, BaseWebSocketHandler):
def
on_host
(
self
,
message
):
# 此处获取主机的信息
print
(
message
)
uuid
=
message
.
get
(
'uuid'
,
None
)
username
=
message
.
get
(
'username'
,
None
)
system_user
=
None
if
uuid
and
username
:
self
.
asset
=
self
.
app
.
service
.
get_asset
(
uuid
)
for
i
in
self
.
asset
.
system_users_granted
:
if
i
.
username
==
username
:
system_user
=
username
if
system_user
:
self
.
forwarder
.
proxy
(
self
.
asset
,
system_user
)
def
on_resize
(
self
,
message
):
self
.
request
.
meta
[
'width'
]
=
message
.
get
(
'cols'
,
80
)
...
...
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