Commit b2a6c3d1 authored by liuzheng712's avatar liuzheng712

Merge branch 'master' of bitbucket.org:liuzheng712/webterminal

parents 3e7a1d76 8db91b37
#!/usr/bin/env python3
from flask import Flask, send_from_directory, render_template, jsonify
from flask_socketio import SocketIO, Namespace, emit
app = Flask(__name__, template_folder='dist')
class SSHws(Namespace):
def on_connect(self):
pass
def on_data(self, message):
print(message)
def on_disconnect(self):
pass
@app.route('/luna/<path:path>')
def send_js(path):
return send_from_directory('dist', path)
@app.route('/')
@app.route('/luna/')
def index():
return render_template('index.html')
@app.route('/api/perms/v1/user/my/asset-groups-assets/')
def asset_groups_assets():
assets = [
{
"id": 0,
"name": "ungrouped",
"assets": []
},
{
"id": 1,
"name": "Default",
"comment": "Default asset group",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system": "windows",
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": True
}
]
},
{
"id": 4,
"hostname": "testserver123",
"ip": "123.57.183.135",
"port": 8022,
"system": "linux",
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": True
}
]
}
]
},
{
"id": 4,
"name": "java",
"comment": "",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": True
}
]
}
]
},
{
"id": 3,
"name": "数据库",
"comment": "",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": True
}
]
}
]
},
{
"id": 2,
"name": "运维组",
"comment": "",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": True
}
]
}
]
}
]
return jsonify(assets)
if __name__ == '__main__':
socketio = SocketIO(app)
socketio.on_namespace(SSHws('/ssh'))
socketio.run(app)
......@@ -724,6 +724,11 @@
"integrity": "sha1-NhIfhFwFeBct5Bmpfb6x0W7DRUI=",
"dev": true
},
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
......@@ -2627,42 +2632,50 @@
}
},
"engine.io-client": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.1.tgz",
"integrity": "sha1-QVqYUrrbFPoAj6PvHjFgjbZ2EyU=",
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.4.tgz",
"integrity": "sha1-T88TcLRxY70s6b4nM5ckMDUNTqE=",
"requires": {
"component-emitter": "1.2.1",
"component-inherit": "0.0.3",
"debug": "2.6.8",
"debug": "2.6.9",
"engine.io-parser": "2.1.1",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"parsejson": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"ws": "2.3.1",
"xmlhttprequest-ssl": "1.5.3",
"ws": "3.3.2",
"xmlhttprequest-ssl": "1.5.4",
"yeast": "0.1.2"
},
"dependencies": {
"safe-buffer": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz",
"integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c="
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"ultron": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz",
"integrity": "sha1-sHoualQagV/Go0zNRTO67DB8qGQ="
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",
"integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og=="
},
"ws": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-2.3.1.tgz",
"integrity": "sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-3.3.2.tgz",
"integrity": "sha512-t+WGpsNxhMR4v6EClXS8r8km5ZljKJzyGhJf7goJz9k5Ye3+b5Bvno5rjqPuIBn5mnn5GBb7o8IrIWHxX1qOLQ==",
"requires": {
"safe-buffer": "5.0.1",
"ultron": "1.1.0"
"async-limiter": "1.0.0",
"safe-buffer": "5.1.1",
"ultron": "1.1.1"
}
},
"xmlhttprequest-ssl": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.4.tgz",
"integrity": "sha1-BPVgkVcks4kIhxXMDteBPpZ3v1c="
}
}
},
......@@ -5278,7 +5291,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": "sha512-ochPsqWS1WXj8ZnMIV0vnNXooaMhp7cyL4FMSIPKTtnV0Ha/T19G2b9kkhcNsabV9bxYkze7/aLZJb/bYuFduQ==",
"integrity": "sha1-WoRnd+LCYg0eaRBOXToDsfYIjxE=",
"dev": true,
"requires": {
"generate-function": "2.0.0",
......@@ -10666,6 +10679,7 @@
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/parsejson/-/parsejson-0.0.3.tgz",
"integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=",
"dev": true,
"requires": {
"better-assert": "1.0.2"
}
......@@ -11805,30 +11819,6 @@
"integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=",
"dev": true
},
"pty.js": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/pty.js/-/pty.js-0.3.1.tgz",
"integrity": "sha1-gfW+0zLW5eeraFaI0boDc0ENUbU=",
"dev": true,
"requires": {
"extend": "1.2.1",
"nan": "2.3.5"
},
"dependencies": {
"extend": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz",
"integrity": "sha1-oPX9bPyDpf5J72mNYOyKYk3UV2w=",
"dev": true
},
"nan": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.3.5.tgz",
"integrity": "sha1-gioNwmYpDOTNOhIoLKPn42Rmigg=",
"dev": true
}
}
},
"public-encrypt": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz",
......@@ -12354,8 +12344,7 @@
"safe-buffer": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
"dev": true
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
},
"sass-graph": {
"version": "2.2.4",
......@@ -12702,7 +12691,7 @@
"engine.io": "3.1.0",
"object-assign": "4.1.1",
"socket.io-adapter": "1.1.1",
"socket.io-client": "2.0.3",
"socket.io-client": "2.0.4",
"socket.io-parser": "3.1.2"
}
},
......@@ -12712,16 +12701,16 @@
"integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs="
},
"socket.io-client": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.3.tgz",
"integrity": "sha1-bK9K/5+FsZ/ZG2zhPWmttWT4hzs=",
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.4.tgz",
"integrity": "sha1-CRilUkBtxeVAs4Dc2Xr8SmQzL44=",
"requires": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
"debug": "2.6.8",
"engine.io-client": "3.1.1",
"engine.io-client": "3.1.4",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
......@@ -14666,7 +14655,8 @@
"xmlhttprequest-ssl": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz",
"integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0="
"integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0=",
"dev": true
},
"xtend": {
"version": "4.0.1",
......
......@@ -45,6 +45,7 @@
"roboto-fontface": "^0.8.0",
"rxjs": "^5.4.2",
"socket.io": "^2.0.3",
"socket.io-client": "^2.0.4",
"ssh-keygen": "^0.4.1",
"tether": "^1.4.0",
"xterm": "^2.9.2",
......@@ -68,7 +69,6 @@
"karma-jasmine-html-reporter": "^0.2.2",
"node-sass": "^4.7.2",
"protractor": "~5.1.2",
"pty.js": "^0.3.1",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
......
{
"/api": {
"target": "http://localhost:3000",
"target": "http://localhost:5000",
"secure": false
},
"/socket.io/": {
"target": "http://127.0.0.1:3000",
"target": "http://127.0.0.1:5000",
"secure": false
},
"/rdp/socket.io/": {
......
......@@ -124,11 +124,11 @@ export class CleftbarComponent implements OnInit {
if (username === '') {
return;
}
if (host.type === 'ssh') {
if (host.system === 'linux') {
jQuery('app-ssh').show();
jQuery('app-rdp').hide();
this._term.TerminalConnect(host, username);
} else {
} else if (host.system === 'windows') {
jQuery('app-ssh').hide();
jQuery('app-rdp').show();
this._rdp.Connect(host, username);
......
......@@ -49,7 +49,7 @@ export class SshComponent implements OnInit {
}
TerminalConnect(host, username) {
const socket = io.connect();
const socket = io.connect('/ssh');
let cols = '80';
let rows = '24';
if (Cookie.get('cols')) {
......@@ -98,8 +98,7 @@ export class SshComponent implements OnInit {
NavList.List[id].Term.term.write('\x1b[31mWelcome to Jumpserver!\x1b[m\r\n');
socket.on('connect', function () {
socket.emit('login', 'root');
socket.emit('machine', host.uuid);
socket.emit('host', {'uuid': host.uuid, 'user': username});
NavList.List[id].Term.term.on('data', function (data) {
socket.emit('data', data);
......@@ -111,7 +110,7 @@ export class SshComponent implements OnInit {
});
socket.on('disconnect', function () {
this.TerminalDisconnect(id);
this.TerminalDisconnect(NavList.List[id]);
// TermStore.term[id]["term"].destroy();
// TermStore.term[id]["connected"] = false;
});
......@@ -123,10 +122,10 @@ export class SshComponent implements OnInit {
let cols = 80;
if (Cookie.get('rows')) {
rows = parseInt(Cookie.get('rows'));
rows = parseInt(Cookie.get('rows'), 10);
}
if (Cookie.get('cols')) {
cols = parseInt(Cookie.get('cols'));
cols = parseInt(Cookie.get('cols'), 10);
}
if (col < 80) {
col = 80;
......@@ -138,7 +137,7 @@ export class SshComponent implements OnInit {
} else {
for (let _i = 0; _i < NavList.List.length; _i++) {
if (NavList.List[_i].connected) {
NavList.List[_i].Term.socket.emit('resize', [col, row]);
NavList.List[_i].Term.socket.emit('resize', {'cols': col, 'rows': row});
NavList.List[_i].Term.term.resize(col, row);
}
}
......
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