Commit 7fa80ef3 authored by liuzheng712's avatar liuzheng712

feat: update

BREAKING CHANGE: g
parent 5f5a24b1
#!/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
import paramiko
app = Flask(__name__, template_folder='dist')
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):
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):
self.chan.send(message)
def on_host(self, 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):
pass
......@@ -40,14 +65,14 @@ def asset_groups_assets():
"id": 1,
"name": "Default",
"comment": "Default asset group",
"assets": [
"assets_granted": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system": "windows",
"system_users": [
"system": "linux",
"system_users_granted": [
{
"id": 1,
"name": "web",
......@@ -64,7 +89,7 @@ def asset_groups_assets():
"ip": "123.57.183.135",
"port": 8022,
"system": "linux",
"system_users": [
"assets_granted": [
{
"id": 1,
"name": "web",
......@@ -81,13 +106,13 @@ def asset_groups_assets():
"id": 4,
"name": "java",
"comment": "",
"assets": [
"assets_granted": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
"system_users_granted": [
{
"id": 1,
"name": "web",
......@@ -104,13 +129,13 @@ def asset_groups_assets():
"id": 3,
"name": "数据库",
"comment": "",
"assets": [
"assets_granted": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
"system_users_granted": [
{
"id": 1,
"name": "web",
......@@ -127,13 +152,13 @@ def asset_groups_assets():
"id": 2,
"name": "运维组",
"comment": "",
"assets": [
"assets_granted": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
"system_users_granted": [
{
"id": 1,
"name": "web",
......
......@@ -4546,6 +4546,11 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"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": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz",
......@@ -5303,7 +5308,7 @@
"is-my-json-valid": {
"version": "2.16.1",
"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,
"requires": {
"generate-function": "2.0.0",
......@@ -6425,6 +6430,15 @@
"integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=",
"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": {
"version": "1.2.17",
"resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz",
......
......@@ -36,6 +36,7 @@
"jquery-sparkline": "^2.4.0",
"jvectormap": "1.2.2",
"layui-layer": "git+https://github.com/jumpserver/layer.git",
"materialize-css": "^0.100.2",
"metismenu": "^2.5.0",
"ng2-charts": "^1.5.0",
"ng2-cookies": "^1.0.12",
......
......@@ -124,9 +124,6 @@ export class CleftbarComponent implements OnInit {
if (username === '') {
return;
}
jQuery('app-ssh').show();
jQuery('app-rdp').hide();
this._term.TerminalConnect(host, username);
if (host.system === 'linux') {
jQuery('app-ssh').show();
jQuery('app-rdp').hide();
......
......@@ -49,7 +49,7 @@ export class SshComponent implements OnInit {
}
TerminalConnect(host, username) {
console.log(host,username);
console.log(host, username);
const socket = io.connect('/ssh');
let cols = '80';
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