Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
wsssh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
wsssh
Commits
22069c66
Commit
22069c66
authored
Sep 22, 2025
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add polling flag to prevent concurrent requests in long polling
parent
0d39f09f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
26 deletions
+35
-26
assets.o
wssshd2/assets.o
+0
-0
terminal_page.h
wssshd2/html_pages/terminal_page.h
+4
-4
image_data.h
wssshd2/image_data.h
+2
-2
terminal.html
wssshd2/templates/terminal.html
+4
-2
terminal.html~
wssshd2/templates/terminal.html~
+25
-18
web.o
wssshd2/web.o
+0
-0
wssshd
wssshd2/wssshd
+0
-0
No files found.
wssshd2/assets.o
View file @
22069c66
No preview for this file type
wssshd2/html_pages/terminal_page.h
View file @
22069c66
...
...
@@ -484,17 +484,17 @@ static const char *terminal_page_html =
" term.write(data);
\n
"
" }
\n
"
" }
\n
"
" // Schedule next poll
\n
"
" // Schedule next poll
immediately for long polling
\n
"
" if (pollInterval) {
\n
"
" pollInterval = setTimeout(pollData,
30
0);
\n
"
" pollInterval = setTimeout(pollData,
5
0);
\n
"
" }
\n
"
" }
\n
"
" })
\n
"
" .catch(error => {
\n
"
" console.error('Polling error:', error);
\n
"
" // Continue polling even on error
\n
"
" // Continue polling even on error
, but with delay
\n
"
" if (pollInterval) {
\n
"
" pollInterval = setTimeout(pollData,
3
00);
\n
"
" pollInterval = setTimeout(pollData,
10
00);
\n
"
" }
\n
"
" });
\n
"
"}
\n
"
...
...
wssshd2/image_data.h
View file @
22069c66
...
...
@@ -7,8 +7,8 @@ unsigned char image_jpg[] = {
0x30
,
0x00
,
0x00
,
0xea
,
0x60
,
0x00
,
0x00
,
0x3a
,
0x98
,
0x00
,
0x00
,
0x17
,
0x70
,
0x9c
,
0xba
,
0x51
,
0x3c
,
0x00
,
0x00
,
0x00
,
0x06
,
0x62
,
0x4b
,
0x47
,
0x44
,
0x00
,
0xff
,
0x00
,
0xff
,
0x00
,
0xff
,
0xa0
,
0xbd
,
0xa7
,
0x93
,
0x00
,
0x00
,
0x00
,
0x07
,
0x74
,
0x49
,
0x4d
,
0x45
,
0x07
,
0xe9
,
0x09
,
0x16
,
0x
0f
,
0x
2d
,
0x23
,
0x0c
,
0xec
,
0xe6
,
0x78
,
0x00
,
0x00
,
0x05
,
0xd4
,
0x7a
,
0x54
,
0x00
,
0x00
,
0x07
,
0x74
,
0x49
,
0x4d
,
0x45
,
0x07
,
0xe9
,
0x09
,
0x16
,
0x
10
,
0x
06
,
0x26
,
0x1d
,
0x8c
,
0x0b
,
0xd3
,
0x00
,
0x00
,
0x05
,
0xd4
,
0x7a
,
0x54
,
0x58
,
0x74
,
0x52
,
0x61
,
0x77
,
0x20
,
0x70
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x74
,
0x79
,
0x70
,
0x65
,
0x20
,
0x61
,
0x70
,
0x70
,
0x31
,
0x00
,
0x00
,
0x48
,
0x89
,
0x85
,
0x96
,
0x59
,
0x92
,
0xdc
,
0x38
,
0x10
,
0x43
,
0xff
,
...
...
wssshd2/templates/terminal.html
View file @
22069c66
...
...
@@ -119,6 +119,7 @@ let fitAddon = null;
let
connected
=
false
;
let
requestId
=
null
;
let
pollInterval
=
null
;
let
polling
=
false
;
console
.
log
(
'Terminal page loaded, adding event listeners'
);
document
.
getElementById
(
'connectBtn'
).
addEventListener
(
'click'
,
connect
);
...
...
@@ -426,7 +427,8 @@ function disconnect() {
}
function
pollData
()
{
if
(
!
requestId
)
return
;
if
(
!
requestId
||
polling
)
return
;
polling
=
true
;
fetch
(
'/terminal/%s/xterm/data?request_id='
+
encodeURIComponent
(
requestId
))
.
then
(
response
=>
{
if
(
response
.
status
!==
200
)
{
...
...
@@ -462,7 +464,7 @@ function pollData() {
}
// Schedule next poll immediately for long polling
if
(
pollInterval
)
{
pollInterval
=
setTimeout
(
pollData
,
0
);
pollInterval
=
setTimeout
(
pollData
,
5
0
);
}
}
})
...
...
wssshd2/templates/terminal.html~
View file @
22069c66
...
...
@@ -354,9 +354,9 @@ function connect() {
console
.
log
(
'Launching command:'
,
data
.
command
);
}
term
.
write
(
'Connected successfully!
\
r
\
n'
);
setTimeout
(()
=>
{
pollInterval
=
setInterval
(
pollData
,
200
);
},
200
);
pollInterval
=
setInterval
(
pollData
,
500
);
// Poll immediately to get any buffered output
pollData
(
);
}
else
{
term
.
write
(
'Error: '
+
(
data
.
error
||
'Unknown error'
)
+
'
\
r
\
n'
);
disconnect
();
...
...
@@ -402,7 +402,7 @@ function disconnect() {
document
.
getElementById
(
'sshUsername'
).
disabled
=
false
;
if
(
pollInterval
)
{
clear
Interval
(
pollInterval
);
clear
Timeout
(
pollInterval
);
pollInterval
=
null
;
}
...
...
@@ -443,27 +443,34 @@ function pollData() {
console
.
log
(
'Poll data received:'
,
data
);
if
(
data
.
ended
!==
undefined
)
{
console
.
log
(
'Session ended, reloading page'
);
clearInterval
(
pollInterval
);
pollInterval
=
null
;
if
(
pollInterval
)
{
clearTimeout
(
pollInterval
);
pollInterval
=
null
;
}
location
.
reload
();
}
else
if
(
data
)
{
console
.
log
(
'Received data:'
,
data
.
byteLength
||
data
.
length
,
'bytes/characters'
);
// Write data to terminal
if
(
data
.
byteLength
!==
undefined
)
{
// Binary data
term
.
write
(
new
Uint8Array
(
data
));
}
else
{
// Text data
term
.
write
(
data
);
}
else
{
if
(
data
)
{
console
.
log
(
'Received data:'
,
data
.
byteLength
||
data
.
length
,
'bytes/characters'
);
// Write data to terminal
if
(
data
.
byteLength
!==
undefined
)
{
// Binary data
term
.
write
(
new
Uint8Array
(
data
));
}
else
{
// Text data
term
.
write
(
data
);
}
}
// Schedule next poll immediately for long polling
if
(
pollInterval
)
{
pollInterval
=
setTimeout
(
pollData
,
0
);
}
}
})
.
catch
(
error
=>
{
console
.
error
(
'Polling error:'
,
error
);
//
Stop polling on error
//
Continue polling even on error, but with delay
if
(
pollInterval
)
{
clearInterval
(
pollInterval
);
pollInterval
=
null
;
pollInterval
=
setTimeout
(
pollData
,
1000
);
}
});
}
...
...
wssshd2/web.o
View file @
22069c66
No preview for this file type
wssshd2/wssshd
View file @
22069c66
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment