Skip to content

theOGognf/private_poker

Repository files navigation

TUI

A poker library, server, client, and TUI.

🃟 pri♦ate_p♡ker 🃏︎

  • Wanting to play poker but only have a computer and no playing cards?
  • Having a slow day at work and in need of something to pass the time with your coworkers?
  • Managing an entirely legal gambling ring and in need of a secure, private, and easy-to-use solution for running poker games?

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:

  • The server is ephemeral and more isolated from the host system
  • Client binaries don't need to be distributed to users
  • Users are managed by the container's user space
  • Server connections are managed by ssh

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:

  • For the host, run the server binary:

    RUST_LOG=info cargo run --bin pp_server -r -- --bind $host
  • For users, run the client binary:

    cargo run --bin pp_client -r -- $username --connect $host

From crates.io:

  • For the host, install and run the server:

    cargo install pp_server
    RUST_LOG=info pp_server --bind $host
  • For users, install and run the client:

    cargo install pp_client
    pp_client $username --connect $host

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:

  • Server orchestration or scaling
  • Persistent storage or backups of game data
  • UIs beyond the TUI

Acknowledgements

About

A poker library, server, client, and TUI.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages