mirror of https://github.com/tp4a/teleport
temp.
parent
67c321dfa6
commit
a98df86d19
|
@ -68,6 +68,8 @@ class RpcHandler(TPBaseJsonHandler):
|
||||||
return self.write_json(0, data=x)
|
return self.write_json(0, data=x)
|
||||||
elif authid < 0:
|
elif authid < 0:
|
||||||
x = web_session().taken('tmp-auth-info-{}'.format(authid), None)
|
x = web_session().taken('tmp-auth-info-{}'.format(authid), None)
|
||||||
|
log.d("[rpc] get_auth_info(): ", x)
|
||||||
|
log.d("\n")
|
||||||
return self.write_json(0, data=x)
|
return self.write_json(0, data=x)
|
||||||
else:
|
else:
|
||||||
return self.write_json(-1, message='invalid auth id.')
|
return self.write_json(-1, message='invalid auth id.')
|
||||||
|
|
|
@ -7,222 +7,222 @@ var g_current_version = "";
|
||||||
var g_host_name = window.location.hostname;
|
var g_host_name = window.location.hostname;
|
||||||
|
|
||||||
var error_process = function (ret, func_success, func_error) {
|
var error_process = function (ret, func_success, func_error) {
|
||||||
var code = ret.code;
|
var code = ret.code;
|
||||||
if (code === TPE_OK) {
|
if (code === TPE_OK) {
|
||||||
func_success(ret);
|
func_success(ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code === TPE_START_CLIENT) {
|
if (code === TPE_START_CLIENT) {
|
||||||
func_error(TPE_START_CLIENT, '启动本地客户端进程失败,请检查命令行是否正确:' + ret.path);
|
func_error(TPE_START_CLIENT, '启动本地客户端进程失败,请检查命令行是否正确:' + ret.path);
|
||||||
console.log('启动本地进程失败,命令行:', ret.path);
|
console.log('启动本地进程失败,命令行:', ret.path);
|
||||||
} else if (code === TPE_JSON_FORMAT || code === TPE_PARAM) {
|
} else if (code === TPE_JSON_FORMAT || code === TPE_PARAM) {
|
||||||
func_error(TPE_START_CLIENT, "启动本地客户端进程失败:启动参数错误!");
|
func_error(TPE_START_CLIENT, "启动本地客户端进程失败:启动参数错误!");
|
||||||
} else if (code === TPE_OLD_ASSIST) {
|
} else if (code === TPE_OLD_ASSIST) {
|
||||||
func_error(TPE_OLD_ASSIST, '助手版本太低,请下载最新版本!');
|
func_error(TPE_OLD_ASSIST, '助手版本太低,请下载最新版本!');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
func_error(TPE_START_CLIENT, '启动本地客户端失败,错误代码:' + ret.code);
|
func_error(TPE_START_CLIENT, '启动本地客户端失败,错误代码:' + ret.code);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var teleport_init = function (last_version, req_version, func_success, func_error) {
|
var teleport_init = function (last_version, req_version, func_success, func_error) {
|
||||||
|
|
||||||
g_req_version = req_version;
|
g_req_version = req_version;
|
||||||
g_last_version = last_version;
|
g_last_version = last_version;
|
||||||
var data = {};
|
var data = {};
|
||||||
var args_ = encodeURIComponent(JSON.stringify(data));
|
var args_ = encodeURIComponent(JSON.stringify(data));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
url: 'http://127.0.0.1:50022/ts_get_version/' + args_,
|
url: 'http://127.0.0.1:50022/ts_get_version/' + args_,
|
||||||
jsonp: 'callback',
|
jsonp: 'callback',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
g_current_version = ret.version;
|
g_current_version = ret.version;
|
||||||
if (version_compare()) {
|
if (version_compare()) {
|
||||||
error_process(ret, func_success, func_error);
|
error_process(ret, func_success, func_error);
|
||||||
} else {
|
} else {
|
||||||
func_error(ret, TPE_OLD_ASSIST, '助手版本太低,请<a style="color:#aaaaff;" target="_blank" href="http://teleport.eomsoft.net/download">下载最新版本</a>!');
|
func_error(ret, TPE_OLD_ASSIST, '助手版本太低,请<a style="color:#aaaaff;" target="_blank" href="http://teleport.eomsoft.net/download">下载最新版本</a>!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
func_error({}, TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
func_error({}, TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var version_compare = function () {
|
var version_compare = function () {
|
||||||
var cur_version = parseInt(g_current_version.split(".")[2]);
|
var cur_version = parseInt(g_current_version.split(".")[2]);
|
||||||
var req_version = parseInt(g_req_version.split(".")[2]);
|
var req_version = parseInt(g_req_version.split(".")[2]);
|
||||||
return cur_version >= req_version;
|
return cur_version >= req_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
var to_teleport = function (url, args, func_success, func_error) {
|
var to_teleport = function (url, args, func_success, func_error) {
|
||||||
var auth_id = args['auth_id'];
|
var auth_id = args['auth_id'];
|
||||||
// 开始Ajax调用
|
// 开始Ajax调用
|
||||||
var args_ = JSON.stringify({auth_id: auth_id});
|
var args_ = JSON.stringify({auth_id: auth_id});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
timeout: 6000,
|
timeout: 6000,
|
||||||
//data: {_xsrf: get_cookie('_xsrf'), args: args_},
|
//data: {_xsrf: get_cookie('_xsrf'), args: args_},
|
||||||
data: {args: args_},
|
data: {args: args_},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
if (ret.code === 0) {
|
if (ret.code === 0) {
|
||||||
var session_id = ret.data.session_id;
|
var session_id = ret.data.session_id;
|
||||||
var data = {
|
var data = {
|
||||||
server_ip: g_host_name, //args.server_ip,
|
server_ip: g_host_name, //args.server_ip,
|
||||||
server_port: parseInt(args.server_port),
|
server_port: parseInt(args.server_port),
|
||||||
host_ip: args.host_ip,
|
host_ip: args.host_ip,
|
||||||
size: parseInt(args.size),
|
size: parseInt(args.size),
|
||||||
console: args.console,
|
console: args.console,
|
||||||
session_id: session_id,
|
session_id: session_id,
|
||||||
pro_type: parseInt(args.pro_type),
|
pro_type: parseInt(args.pro_type),
|
||||||
pro_sub: parseInt(args.pro_sub)
|
pro_sub: parseInt(args.pro_sub)
|
||||||
};
|
};
|
||||||
var args_ = encodeURIComponent(JSON.stringify(data));
|
var args_ = encodeURIComponent(JSON.stringify(data));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
url: 'http://127.0.0.1:50022/ts_op/' + args_,
|
url: 'http://127.0.0.1:50022/ts_op/' + args_,
|
||||||
jsonp: 'callback',
|
jsonp: 'callback',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
error_process(ret, func_success, func_error);
|
error_process(ret, func_success, func_error);
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
func_error(TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
func_error(TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
func_error(TPE_NO_CORE_SERVER, '远程连接请求失败,可能teleport核心服务尚未启动!');
|
func_error(TPE_NO_CORE_SERVER, '远程连接请求失败,可能teleport核心服务尚未启动!' + ret.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
func_error(TPE_NETWORK, '远程网络通讯失败!');
|
func_error(TPE_NETWORK, '远程网络通讯失败!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var to_admin_teleport = function (url, args, func_success, func_error) {
|
var to_admin_teleport = function (url, args, func_success, func_error) {
|
||||||
var host_auth_id = args['host_auth_id'];
|
var host_auth_id = args['host_auth_id'];
|
||||||
// 开始Ajax调用
|
// 开始Ajax调用
|
||||||
var args_ = JSON.stringify({host_auth_id: host_auth_id});
|
var args_ = JSON.stringify({host_auth_id: host_auth_id});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
timeout: 6000,
|
timeout: 6000,
|
||||||
//data: {_xsrf: get_cookie('_xsrf'), args: args_},
|
//data: {_xsrf: get_cookie('_xsrf'), args: args_},
|
||||||
data: {args: args_},
|
data: {args: args_},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
if (ret.code === 0) {
|
if (ret.code === 0) {
|
||||||
var session_id = ret.data.session_id;
|
var session_id = ret.data.session_id;
|
||||||
var data = {
|
var data = {
|
||||||
server_ip: g_host_name,
|
server_ip: g_host_name,
|
||||||
server_port: parseInt(args.server_port),
|
server_port: parseInt(args.server_port),
|
||||||
host_ip: args.host_ip,
|
host_ip: args.host_ip,
|
||||||
size: parseInt(args.size),
|
size: parseInt(args.size),
|
||||||
console: args.console,
|
console: args.console,
|
||||||
session_id: session_id,
|
session_id: session_id,
|
||||||
pro_type: parseInt(args.pro_type),
|
pro_type: parseInt(args.pro_type),
|
||||||
pro_sub: parseInt(args.pro_sub)
|
pro_sub: parseInt(args.pro_sub)
|
||||||
};
|
};
|
||||||
var args_ = encodeURIComponent(JSON.stringify(data));
|
var args_ = encodeURIComponent(JSON.stringify(data));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
url: 'http://127.0.0.1:50022/ts_op/' + args_,
|
url: 'http://127.0.0.1:50022/ts_op/' + args_,
|
||||||
jsonp: 'callback',
|
jsonp: 'callback',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
error_process(ret, func_success, func_error);
|
error_process(ret, func_success, func_error);
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
func_error(TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
func_error(TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
func_error(TPE_NO_CORE_SERVER, '远程连接请求失败,可能teleport核心服务尚未启动!');
|
func_error(TPE_NO_CORE_SERVER, '远程连接请求失败,可能teleport核心服务尚未启动!' + ret.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
func_error(TPE_NETWORK, '远程网络通讯失败!');
|
func_error(TPE_NETWORK, '远程网络通讯失败!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var to_admin_fast_teleport = function (url, args, func_success, func_error) {
|
var to_admin_fast_teleport = function (url, args, func_success, func_error) {
|
||||||
// 开始Ajax调用
|
// 开始Ajax调用
|
||||||
var args_ = JSON.stringify(args);
|
var args_ = JSON.stringify(args);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
timeout: 6000,
|
timeout: 6000,
|
||||||
//data: {_xsrf: get_cookie('_xsrf'), args: args_},
|
//data: {_xsrf: get_cookie('_xsrf'), args: args_},
|
||||||
data: {args: args_},
|
data: {args: args_},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
if (ret.code === 0) {
|
if (ret.code === 0) {
|
||||||
var session_id = ret.data.session_id;
|
var session_id = ret.data.session_id;
|
||||||
var data = {
|
var data = {
|
||||||
server_ip: g_host_name,
|
server_ip: g_host_name,
|
||||||
server_port: parseInt(args.server_port),
|
server_port: parseInt(args.server_port),
|
||||||
host_ip: args.host_ip,
|
host_ip: args.host_ip,
|
||||||
size: parseInt(args.size),
|
size: parseInt(args.size),
|
||||||
session_id: session_id,
|
session_id: session_id,
|
||||||
pro_type: parseInt(args.protocol),
|
pro_type: parseInt(args.protocol),
|
||||||
pro_sub: parseInt(args.protocol_sub)
|
pro_sub: parseInt(args.protocol_sub)
|
||||||
};
|
};
|
||||||
var args_ = encodeURIComponent(JSON.stringify(data));
|
var args_ = encodeURIComponent(JSON.stringify(data));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
url: 'http://127.0.0.1:50022/ts_op/' + args_,
|
url: 'http://127.0.0.1:50022/ts_op/' + args_,
|
||||||
jsonp: 'callback',
|
jsonp: 'callback',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
error_process(ret, func_success, func_error);
|
error_process(ret, func_success, func_error);
|
||||||
},
|
},
|
||||||
error: function (jqXhr, _error, _e) {
|
error: function (jqXhr, _error, _e) {
|
||||||
console.log('jqXhr', jqXhr);
|
console.log('jqXhr', jqXhr);
|
||||||
console.log('error', _error);
|
console.log('error', _error);
|
||||||
console.log('e', _e);
|
console.log('e', _e);
|
||||||
|
|
||||||
console.log('state:', jqXhr.state());
|
console.log('state:', jqXhr.state());
|
||||||
func_error(TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
func_error(TPE_NO_ASSIST, '无法连接到teleport助手,可能尚未启动!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
func_error(TPE_NO_CORE_SERVER, '远程连接请求失败,可能teleport核心服务尚未启动!');
|
func_error(TPE_NO_CORE_SERVER, '远程连接请求失败,可能teleport核心服务尚未启动!' + ret.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
func_error(TPE_NETWORK, '远程网络通讯失败!');
|
func_error(TPE_NETWORK, '远程网络通讯失败!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var start_rdp_replay = function (args, func_success, func_error) {
|
var start_rdp_replay = function (args, func_success, func_error) {
|
||||||
var args_ = encodeURIComponent(JSON.stringify(args));
|
var args_ = encodeURIComponent(JSON.stringify(args));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
timeout: 6000,
|
timeout: 6000,
|
||||||
url: 'http://127.0.0.1:50022/ts_rdp_play/' + args_,
|
url: 'http://127.0.0.1:50022/ts_rdp_play/' + args_,
|
||||||
jsonp: 'callback',
|
jsonp: 'callback',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
if (ret.code === TPE_OK) {
|
if (ret.code === TPE_OK) {
|
||||||
error_process(ret, func_success, func_error);
|
error_process(ret, func_success, func_error);
|
||||||
} else {
|
} else {
|
||||||
func_error(ret.code, '查看录像失败!');
|
func_error(ret.code, '查看录像失败!');
|
||||||
}
|
}
|
||||||
console.log('ret', ret);
|
console.log('ret', ret);
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
func_error(TPE_NETWORK, '与助手的络通讯失败!');
|
func_error(TPE_NETWORK, '与助手的络通讯失败!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue