mirror of
https://github.com/YuzuZensai/TrollSSH.git
synced 2026-09-13 21:09:07 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c533d29f7
|
||
|
|
267b6a89b8
|
||
|
|
286c28bfcf
|
@@ -25,7 +25,7 @@ Generate a frame set from a video through container image
|
||||
|
||||
```sh
|
||||
docker run --rm -v ./video.mp4:/home/app/video.mp4 -v ./frames:/home/app/frames \
|
||||
ghcr.io/yuzuzensai/trollssh:latest trollssh --generate --video video.mp4
|
||||
ghcr.io/yuzuzensai/trollssh:v1.0.1 trollssh --generate --video video.mp4
|
||||
```
|
||||
|
||||
This writes `frames/<name>.tsf`, a simple container of color JPEG frames plus
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
services:
|
||||
trollssh:
|
||||
image: ghcr.io/yuzuzensai/trollssh:latest
|
||||
image: ghcr.io/yuzuzensai/trollssh:v1.0.1
|
||||
container_name: trollssh
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
|
||||
+21
-3
@@ -13,7 +13,14 @@ import (
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
const clearScreen = "\x1b[2J\x1b[0f"
|
||||
const (
|
||||
clearScreen = "\x1b[2J\x1b[0f"
|
||||
hideCursor = "\x1b[?25l"
|
||||
showCursor = "\x1b[?25h"
|
||||
syncStart = "\x1b[?2026h"
|
||||
syncEnd = "\x1b[?2026l"
|
||||
homeCursor = "\x1b[H"
|
||||
)
|
||||
|
||||
type ConnectionTracker struct {
|
||||
mu sync.Mutex
|
||||
@@ -383,6 +390,8 @@ func (s *Server) playVideo(
|
||||
w, h := size.get()
|
||||
logDebug(fmt.Sprintf("Terminal size %dx%d for %s", w, h, ip))
|
||||
|
||||
defer func() { _, _ = channel.Write([]byte(showCursor)) }()
|
||||
|
||||
if s.fakeLogin != nil {
|
||||
_, _ = channel.Write([]byte(clearScreen))
|
||||
_, _ = channel.Write([]byte(*s.fakeLogin))
|
||||
@@ -435,6 +444,8 @@ func (s *Server) playVideo(
|
||||
return
|
||||
}
|
||||
|
||||
_, _ = channel.Write([]byte(hideCursor))
|
||||
|
||||
frameInterval := func() time.Duration {
|
||||
return time.Duration(float64(time.Second) / current.data.FPS)
|
||||
}
|
||||
@@ -444,6 +455,7 @@ func (s *Server) playVideo(
|
||||
|
||||
currentFrame := 0
|
||||
loopCount := 0
|
||||
lastW, lastH := 0, 0
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -457,6 +469,7 @@ func (s *Server) playVideo(
|
||||
setIndex = (setIndex + delta + len(s.sets)) % len(s.sets)
|
||||
current = s.sets[setIndex]
|
||||
currentFrame = 0
|
||||
lastW, lastH = 0, 0
|
||||
logDebug(fmt.Sprintf("%s switched to %q", ip, current.data.Name))
|
||||
ticker.Reset(frameInterval())
|
||||
|
||||
@@ -469,7 +482,12 @@ func (s *Server) playVideo(
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := channel.Write([]byte(clearScreen + ascii)); err != nil {
|
||||
prefix := homeCursor
|
||||
if w != lastW || h != lastH {
|
||||
prefix = clearScreen
|
||||
lastW, lastH = w, h
|
||||
}
|
||||
if _, err := channel.Write([]byte(syncStart + prefix + ascii + syncEnd)); err != nil {
|
||||
closeSession()
|
||||
return
|
||||
}
|
||||
@@ -482,7 +500,7 @@ func (s *Server) playVideo(
|
||||
currentFrame = 0
|
||||
loopCount++
|
||||
if config.MaxLoop > 0 && loopCount >= config.MaxLoop {
|
||||
_, _ = channel.Write([]byte(clearScreen))
|
||||
_, _ = channel.Write([]byte(showCursor + clearScreen))
|
||||
if s.goodbye != nil {
|
||||
_, _ = channel.Write([]byte(*s.goodbye))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user