diff --git a/Dockerfile b/Dockerfile index e0f6f9a..eb269cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 958239e..9e14dc7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/src/shellmate/ssh/server.py b/src/shellmate/ssh/server.py index 0997180..6c48948 100644 --- a/src/shellmate/ssh/server.py +++ b/src/shellmate/ssh/server.py @@ -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}")