Commit 7fa80ef3 authored by liuzheng712's avatar liuzheng712

feat: update

BREAKING CHANGE: g
parent 5f5a24b1
#!/usr/bin/env python3 #!/usr/bin/env python3
from flask import Flask, send_from_directory, render_template, jsonify 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
import paramiko
app = Flask(__name__, template_folder='dist') app = Flask(__name__, template_folder='dist')
class SSHws(Namespace): class SSHws(Namespace):
def ssh_with_password(self):
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.raws)
self.socketio.start_background_task(self.send_data)
# self.chan.settimeout(0.1)
def send_data(self):
while True:
data = self.chan.recv(2048).decode('utf-8', 'replace')
self.emit('data', data)
def on_connect(self): def on_connect(self):
pass self.cols = int(request.cookies.get('cols', 80))
self.raws = int(request.cookies.get('raws', 24))
self.ssh_with_password()
def on_data(self, message): def on_data(self, message):
self.chan.send(message)
def on_host(self, message):
print(message) print(message)
def on_resize(self, message):
print(message)
self.cols = message.get('cols', 80)
self.rows = message.get('rows', 24)
self.chan.resize_pty(width=self.cols, height=self.rows, width_pixels=1, height_pixels=1)
def on_disconnect(self): def on_disconnect(self):
pass pass
...@@ -40,14 +65,14 @@ def asset_groups_assets(): ...@@ -40,14 +65,14 @@ def asset_groups_assets():
"id": 1, "id": 1,
"name": "Default", "name": "Default",
"comment": "Default asset group", "comment": "Default asset group",
"assets": [ "assets_granted": [
{ {
"id": 2, "id": 2,
"hostname": "192.168.1.6", "hostname": "192.168.1.6",
"ip": "192.168.2.6", "ip": "192.168.2.6",
"port": 22, "port": 22,
"system": "windows", "system": "linux",
"system_users": [ "system_users_granted": [
{ {
"id": 1, "id": 1,
"name": "web", "name": "web",
...@@ -64,7 +89,7 @@ def asset_groups_assets(): ...@@ -64,7 +89,7 @@ def asset_groups_assets():
"ip": "123.57.183.135", "ip": "123.57.183.135",
"port": 8022, "port": 8022,
"system": "linux", "system": "linux",
"system_users": [ "assets_granted": [
{ {
"id": 1, "id": 1,
"name": "web", "name": "web",
...@@ -81,13 +106,13 @@ def asset_groups_assets(): ...@@ -81,13 +106,13 @@ def asset_groups_assets():
"id": 4, "id": 4,
"name": "java", "name": "java",
"comment": "", "comment": "",
"assets": [ "assets_granted": [
{ {
"id": 2, "id": 2,
"hostname": "192.168.1.6", "hostname": "192.168.1.6",
"ip": "192.168.2.6", "ip": "192.168.2.6",
"port": 22, "port": 22,
"system_users": [ "system_users_granted": [
{ {
"id": 1, "id": 1,
"name": "web", "name": "web",
...@@ -104,13 +129,13 @@ def asset_groups_assets(): ...@@ -104,13 +129,13 @@ def asset_groups_assets():
"id": 3, "id": 3,
"name": "数据库", "name": "数据库",
"comment": "", "comment": "",
"assets": [ "assets_granted": [
{ {
"id": 2, "id": 2,
"hostname": "192.168.1.6", "hostname": "192.168.1.6",
"ip": "192.168.2.6", "ip": "192.168.2.6",
"port": 22, "port": 22,
"system_users": [ "system_users_granted": [
{ {
"id": 1, "id": 1,
"name": "web", "name": "web",
...@@ -127,13 +152,13 @@ def asset_groups_assets(): ...@@ -127,13 +152,13 @@ def asset_groups_assets():
"id": 2, "id": 2,
"name": "运维组", "name": "运维组",
"comment": "", "comment": "",
"assets": [ "assets_granted": [
{ {
"id": 2, "id": 2,
"hostname": "192.168.1.6", "hostname": "192.168.1.6",
"ip": "192.168.2.6", "ip": "192.168.2.6",
"port": 22, "port": 22,
"system_users": [ "system_users_granted": [
{ {
"id": 1, "id": 1,
"name": "web", "name": "web",
......
...@@ -4546,6 +4546,11 @@ ...@@ -4546,6 +4546,11 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
}, },
"hammerjs": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz",
"integrity": "sha1-BO93hiz/K7edMPdpIJWTAiK/YPE="
},
"handle-thing": { "handle-thing": {
"version": "1.2.5", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz", "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz",
...@@ -5303,7 +5308,7 @@ ...@@ -5303,7 +5308,7 @@
"is-my-json-valid": { "is-my-json-valid": {
"version": "2.16.1", "version": "2.16.1",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz", "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz",
"integrity": "sha1-WoRnd+LCYg0eaRBOXToDsfYIjxE=", "integrity": "sha512-ochPsqWS1WXj8ZnMIV0vnNXooaMhp7cyL4FMSIPKTtnV0Ha/T19G2b9kkhcNsabV9bxYkze7/aLZJb/bYuFduQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"generate-function": "2.0.0", "generate-function": "2.0.0",
...@@ -6425,6 +6430,15 @@ ...@@ -6425,6 +6430,15 @@
"integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=",
"dev": true "dev": true
}, },
"materialize-css": {
"version": "0.100.2",
"resolved": "https://registry.npmjs.org/materialize-css/-/materialize-css-0.100.2.tgz",
"integrity": "sha512-Bf4YeoJCIdk4dlpnmVX+DIOJBbqOKwfBPD+tT5bxwXNFMLk649CGbldqtnctkkfMp+fGgSAsdYu9lo1ZolZqgA==",
"requires": {
"hammerjs": "2.0.8",
"jquery": "3.2.1"
}
},
"math-expression-evaluator": { "math-expression-evaluator": {
"version": "1.2.17", "version": "1.2.17",
"resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz", "resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz",
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
"jquery-sparkline": "^2.4.0", "jquery-sparkline": "^2.4.0",
"jvectormap": "1.2.2", "jvectormap": "1.2.2",
"layui-layer": "git+https://github.com/jumpserver/layer.git", "layui-layer": "git+https://github.com/jumpserver/layer.git",
"materialize-css": "^0.100.2",
"metismenu": "^2.5.0", "metismenu": "^2.5.0",
"ng2-charts": "^1.5.0", "ng2-charts": "^1.5.0",
"ng2-cookies": "^1.0.12", "ng2-cookies": "^1.0.12",
......
...@@ -124,9 +124,6 @@ export class CleftbarComponent implements OnInit { ...@@ -124,9 +124,6 @@ export class CleftbarComponent implements OnInit {
if (username === '') { if (username === '') {
return; return;
} }
jQuery('app-ssh').show();
jQuery('app-rdp').hide();
this._term.TerminalConnect(host, username);
if (host.system === 'linux') { if (host.system === 'linux') {
jQuery('app-ssh').show(); jQuery('app-ssh').show();
jQuery('app-rdp').hide(); jQuery('app-rdp').hide();
......
...@@ -49,7 +49,7 @@ export class SshComponent implements OnInit { ...@@ -49,7 +49,7 @@ export class SshComponent implements OnInit {
} }
TerminalConnect(host, username) { TerminalConnect(host, username) {
console.log(host,username); console.log(host, username);
const socket = io.connect('/ssh'); const socket = io.connect('/ssh');
let cols = '80'; let cols = '80';
let rows = '24'; let rows = '24';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment