theOGognf / private_poker

A poker library, server, client, and TUI.
Apache License 2.0
61 stars 1 forks source link
docker poker ssh tui

TUI

A poker library, server, client, and TUI.

🃟 pri♦ate_p♡ker 🃏︎

If you answered "yes" to any of these rhetorical questions, then this project is for you! Host and manage a poker game from the comfort of your computer with pri♦ate_p♡ker (or pp for short)! Get started with any of the following artifacts:

Poker over ssh

One can host a server within a Docker container for the following benefits:

Host and manage poker over ssh with the following commands:

  1. Run the container (two options):

    • From source:

      docker build -t poker .
      docker run -d --name poker -p $port:22 --rm poker
    • From the official Docker image:

      docker run -d --name poker -p $port:22 --rm ognf/poker:latest
  2. Create a user:

    docker exec poker ./create_user $username

    This creates a user in the container's user space and adds the user to a group that enables the user to send their own public ssh key to the server.

  3. Users can then create an ssh key pair and copy their public key to the server:

    ssh-keygen -q -t rsa -b 4096 -N "" -f ~/.ssh/poker_id_rsa
    export PUBLIC_KEY="$(cat ~/.ssh/poker_id_rsa.pub)"
    ssh -i ~/.ssh/poker_id_rsa -o SendEnv=PUBLIC_KEY -p $port $username@$host

    If congratulated with a Success message, subsequent ssh commands will result in the user being greeted by the poker TUI. Users also no longer have to specify the SendEnv option in subsequent ssh commands:

    ssh -i ~/.ssh/poker_id_rsa -p $port $username@$host
  4. (Optionally) Create a tmux session in the container for managing poker bots:

    docker exec poker tmux new-session -d -s bots ./pp_bots

    You can reattach to the session to manage the bots with a TUI:

    docker exec -it poker tmux attach -t bots
  5. Delete a user:

    docker exec poker ./delete_user $username
  6. Stop the server:

    docker stop poker

Poker without Docker

The poker over ssh Docker image is < 40MB, but requires some additional user management on the host's part. If you're playing a poker game in a local or private network, and all your users are familiar with cargo, it's less work to just use the poker binaries directly rather than using Docker and ssh.

From source:

From crates.io:

Project structure

See each subdirectory's docs or README.mds for more specific info.

.
├── pp_admin        # Scripts and configs for managing the server within Docker
├── pp_bots         # Bots binary source
├── pp_client       # Client binary source
├── pp_server       # Server binary source
└── private_poker   # Library that the client and server use

Non-goals

I use this project to learn Rust and to play poker with friends and family. I'm probably disinterested in anything related to this project that doesn't contribute to those goals. Specifically, the following features are omitted from this project and left as an exercise for forkers:

Acknowledgements