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