mirror of
https://github.com/ghndrx/shellmate.git
synced 2026-02-10 06:45:02 +00:00
fix: encode strings to bytes for binary SSH + use port 22
This commit is contained in:
@@ -24,7 +24,7 @@ RUN useradd -m shellmate && \
|
||||
USER shellmate
|
||||
RUN ssh-keygen -t ed25519 -f /etc/shellmate/ssh_host_key -N ""
|
||||
|
||||
EXPOSE 2222
|
||||
EXPOSE 22
|
||||
|
||||
ENV STOCKFISH_PATH=/usr/games/stockfish
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ services:
|
||||
shellmate:
|
||||
build: .
|
||||
ports:
|
||||
- "2222:2222"
|
||||
- "22:22"
|
||||
environment:
|
||||
- SHELLMATE_SSH_PORT=2222
|
||||
- SHELLMATE_SSH_PORT=22
|
||||
- SHELLMATE_REDIS_URL=redis://redis:6379
|
||||
- SHELLMATE_DATABASE_URL=postgresql://shellmate:shellmate@postgres:5432/shellmate
|
||||
- STOCKFISH_PATH=/usr/games/stockfish
|
||||
@@ -13,7 +13,7 @@ services:
|
||||
- postgres
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-z", "localhost", "2222"]
|
||||
test: ["CMD", "nc", "-z", "localhost", "22"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
@@ -90,6 +90,9 @@ async def run_simple_menu(process, username: str, mode: str, width: int, height:
|
||||
def __init__(self, proc):
|
||||
self._proc = proc
|
||||
def write(self, data):
|
||||
# Encode string to bytes for binary mode SSH
|
||||
if isinstance(data, str):
|
||||
data = data.encode('utf-8')
|
||||
self._proc.stdout.write(data)
|
||||
def flush(self):
|
||||
pass
|
||||
@@ -250,10 +253,10 @@ async def run_chess_game(process, console, username: str, opponent: str) -> None
|
||||
elif char == '\x7f' or char == '\b': # Backspace
|
||||
if move_buffer:
|
||||
move_buffer = move_buffer[:-1]
|
||||
process.stdout.write('\b \b')
|
||||
process.stdout.write(b'\b \b')
|
||||
elif char.isprintable():
|
||||
move_buffer += char
|
||||
process.stdout.write(char)
|
||||
process.stdout.write(char.encode('utf-8'))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Game input error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user