Awesome
<div align="center"> <i>A poker library, server, client, and TUI.</i> </div>🃟 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:
-
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
-
-
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. -
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, subsequentssh
commands will result in the user being greeted by the poker TUI. Users also no longer have to specify theSendEnv
option in subsequentssh
commands:ssh -i ~/.ssh/poker_id_rsa -p $port $username@$host
-
(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
-
Delete a user:
docker exec poker ./delete_user $username
-
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.md
s 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
- @Ilikemath642 for inspiring me to work on a poker game
- @zachstruck for teaching me a lot about Rust
- @Mac-Genius for TUI feedback
- @shazow for inspiring me with
ssh-chat