Unverified Commit b9bc53d1 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #260 from jumpserver/dev

Dev
parents 7e654cd6 6dfb4cb0
......@@ -7,6 +7,10 @@ It's implement a ssh server and a web terminal server,
User can connect them except jumpserver openssh server and connect.py
pre version.
# Warning
Coco has been replace by [koko](https://github.com/jumpserver/koko.git)
From v1.5.2, coco will be stop update
## Install
......
......@@ -377,6 +377,7 @@ defaults = {
'UPLOAD_FAILED_REPLAY_ON_START': True,
'REUSE_CONNECTION': True,
'FORCE_REMOVE_FOLDER': False,
'TELNET_TTYPE': 'XTERM-256COLOR',
}
......
......@@ -300,10 +300,16 @@ class TelnetConnection:
logger.info(msg)
return None, msg
if data.startswith(telnetlib.IAC):
self.option_negotiate(data)
# 将数据以 \r\n 进行分割
_data_list = data.split(b'\r\n')
for _data in _data_list:
if not _data:
continue
if _data.startswith(telnetlib.IAC):
self.option_negotiate(_data)
else:
result = self.login_auth(data)
result = self.login_auth(_data)
if result:
msg = 'Successful asset connection.<{}>/<{}>/<{}>.'.format(
self.client.user, self.system_user.username,
......@@ -338,7 +344,8 @@ class TelnetConnection:
elif x == telnetlib.DO + telnetlib.TTYPE:
new_data_list.append(telnetlib.WILL + telnetlib.TTYPE)
elif x == telnetlib.SB + telnetlib.TTYPE + b'\x01':
new_data_list.append(telnetlib.SB + telnetlib.TTYPE + b'\x00' + b'XTERM-256COLOR')
terminal_type = bytes(config.TELNET_TTYPE, encoding='utf-8')
new_data_list.append(telnetlib.SB + telnetlib.TTYPE + b'\x00' + terminal_type)
elif telnetlib.DO in x:
new_data_list.append(x.replace(telnetlib.DO, telnetlib.WONT))
elif telnetlib.WILL in x:
......
......@@ -72,13 +72,22 @@ class ProxyNamespace(BaseNamespace):
client.chan = ws_proxy
self.emit('room', {'room': client_id, 'secret': secret})
join_room(client_id)
if not asset_id or not system_user_id:
msg = "Not asset id or system user id found".format(
asset_id, system_user_id
)
logger.error(msg)
return
asset = app_service.get_asset(asset_id)
system_user = app_service.get_system_user(system_user_id)
if not asset or not system_user:
msg = "No asset or system user found {} {}: {} {}".format(
asset_id, system_user_id, asset, system_user
)
logger.error(msg)
return
forwarder = ProxyServer(client, asset, system_user)
......
......@@ -99,12 +99,11 @@ class SSHServer:
t.start()
transport.close()
except paramiko.SSHException as e:
logger.warning("SSH negotiation failed: {}".format(e))
logger.debug("SSH negotiation failed: {}".format(e))
except EOFError as e:
logger.warning("Handle connection EOF Error: {}".format(e))
logger.debug("Handle connection EOF Error: {}".format(e))
except Exception as e:
logger.error("Unexpect error occur on handle connection: {}".format(e))
logger.error(e, exc_info=True)
finally:
Connection.remove_connection(connection.id)
sock.close()
......
......@@ -63,3 +63,6 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>
# 是否强制删除文件夹:(default false)
# FORCE_REMOVE_FOLDER: false
# Telnet连接协商使用的终端类型
# TELNET_TTYPE: XTERM-256COLOR
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