added pty terminal support to the client side
This commit is contained in:
21
xterm.html
21
xterm.html
@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Terminal</title>
|
||||
<link rel="stylesheet" href="/_ssh/xterm.css" />
|
||||
<link rel="stylesheet" href="xterm.css" />
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
@ -86,8 +86,8 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
<script src="/_ssh/xterm.js"></script>
|
||||
<script src="/_ssh/xterm-addon-fit.js"></script>
|
||||
<script src="xterm.js"></script>
|
||||
<script src="xterm-addon-fit.js"></script>
|
||||
|
||||
<script>
|
||||
const conn_id = '{{ .ConnId }}';
|
||||
@ -133,7 +133,10 @@ window.onload = function(event) {
|
||||
|
||||
let fetch_session_info = async function() {
|
||||
let url = window.location.protocol + '//' + window.location.host;
|
||||
url += `/_ssh/server-conns/${conn_id}/routes/${route_id}`;
|
||||
let pathname = window.location.pathname;
|
||||
pathname = pathname.replace(/\/$/, '');
|
||||
pathname = pathname.substring(0, pathname.lastIndexOf('/'));
|
||||
url += pathname + `/server-conns/${conn_id}/routes/${route_id}`;
|
||||
|
||||
try {
|
||||
const resp = await fetch(url);
|
||||
@ -169,9 +172,13 @@ window.onload = function(event) {
|
||||
const username = username_field.value.trim();
|
||||
const password = password_field.value.trim();
|
||||
|
||||
let prefix = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||
let url = prefix + window.location.host+ `/_ssh-ws/${conn_id}/${route_id}`;
|
||||
const socket = new WebSocket(url)
|
||||
const prefix = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||
let pathname = window.location.pathname;
|
||||
pathname = pathname.replace(/\/$/, '');
|
||||
pathname = pathname.substring(0, pathname.lastIndexOf('/'));
|
||||
let url = prefix + window.location.host + pathname + `/ws/${conn_id}/${route_id}`;
|
||||
|
||||
const socket = new WebSocket(url);
|
||||
socket.binaryType = 'arraybuffer';
|
||||
|
||||
set_terminal_status('Connecting...', '');
|
||||
|
Reference in New Issue
Block a user