mirror of https://github.com/jumpserver/jumpserver
fix(jlog, websocket url) 修复ws使用 ws协议还是wss协议
1. 不再需要浏览器判断什么协议,需要在jumpserver.conf注明 ref #63pull/97/head
parent
a88d8ca410
commit
a8eb9f3e79
|
@ -824,7 +824,6 @@ def main():
|
|||
except IndexError, e:
|
||||
color_print(e)
|
||||
time.sleep(5)
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.http import HttpResponseNotFound
|
|||
from jlog.log_api import renderTemplate
|
||||
|
||||
from jlog.models import Log, ExecLog, FileLog
|
||||
from jumpserver.settings import WEB_SOCKET_HOST
|
||||
from jumpserver.settings import WEB_SOCKET_URL
|
||||
|
||||
|
||||
@require_role('admin')
|
||||
|
@ -66,8 +66,8 @@ def log_list(request, offset):
|
|||
|
||||
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
|
||||
|
||||
web_monitor_uri = '%s/monitor' % WEB_SOCKET_HOST
|
||||
web_kill_uri = '/kill'
|
||||
web_monitor_url = '%s/monitor' % WEB_SOCKET_URL
|
||||
web_kill_url = '/kill'
|
||||
session_id = request.session.session_key
|
||||
return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[base]
|
||||
url = http://192.168.244.129
|
||||
websocket_url = ws://192.168.244.129
|
||||
key = 88aaaf7ffe3c6c04
|
||||
log = debug
|
||||
|
||||
|
@ -10,14 +11,11 @@ user = jumpserver
|
|||
password = mysql234
|
||||
database = jumpserver
|
||||
|
||||
[websocket]
|
||||
web_socket_host = 192.168.244.129:3000
|
||||
|
||||
[mail]
|
||||
mail_enable = 1
|
||||
email_host = smtp.qq.com
|
||||
email_port = 25
|
||||
email_host_user = xxxxxxxx@qq.com
|
||||
email_host_password = xxxxxx
|
||||
email_use_tls = False
|
||||
email_use_tls = True
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ SSH_KEY_DIR = os.path.join(BASE_DIR, 'keys/role_keys')
|
|||
KEY = config.get('base', 'key')
|
||||
URL = config.get('base', 'url')
|
||||
LOG_LEVEL = config.get('base', 'log')
|
||||
WEB_SOCKET_HOST = config.get('websocket', 'web_socket_host')
|
||||
WEB_SOCKET_URL = config.get('base', 'websocket_url')
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
||||
|
|
|
@ -356,8 +356,7 @@ def web_terminal(request):
|
|||
if asset:
|
||||
print asset
|
||||
hostname = asset.hostname
|
||||
# web_terminal_uri = '%s/ws/terminal?id=%s&role=%s' % (WEB_SOCKET_HOST, asset_id, role_name)
|
||||
web_terminal_uri = '/ws/terminal?id=%s&role=%s' % (asset_id, role_name)
|
||||
web_terminal_url = '%s/ws/terminal?id=%s&role=%s' % (WEB_SOCKET_URL, asset_id, role_name)
|
||||
return render_to_response('jlog/web_terminal.html', locals())
|
||||
|
||||
|
||||
|
|
|
@ -136,13 +136,8 @@
|
|||
{# })#}
|
||||
{# });#}
|
||||
function init(obj){
|
||||
var protocol = "ws://";
|
||||
if (window.location.protocol == 'https:') {
|
||||
protocol = 'wss://';
|
||||
}
|
||||
|
||||
var file_path = obj.attr('file_path');
|
||||
var wsUri = protocol + '{{ web_monitor_uri }}';
|
||||
var wsUri = '{{ web_monitor_url }}';
|
||||
var socket = new WebSocket(wsUri + '?file_path=' + file_path);
|
||||
|
||||
var term = new Terminal({
|
||||
|
@ -211,7 +206,7 @@
|
|||
function cut(num, login_type){
|
||||
console.log(login_type);
|
||||
if (login_type=='web'){
|
||||
var g_url = '{{ web_kill_uri }}' + '?id=' + num;
|
||||
var g_url = '{{ web_kill_url }}' + '?id=' + num;
|
||||
} else {
|
||||
var g_url = "{% url 'log_kill' %}?id=" + num;
|
||||
}
|
||||
|
|
|
@ -43,12 +43,7 @@
|
|||
}
|
||||
|
||||
WSSHClient.prototype.connect = function(options) {
|
||||
var protocol = "ws://";
|
||||
if (window.location.protocol == 'https:') {
|
||||
protocol = 'wss://';
|
||||
}
|
||||
|
||||
var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '{{ web_terminal_uri }}';
|
||||
var endpoint = '{{ web_terminal_url }}';
|
||||
|
||||
if (window.WebSocket) {
|
||||
this._connection = new WebSocket(endpoint);
|
||||
|
|
Loading…
Reference in New Issue