chookchat/README.md
2024-10-20 16:05:21 +11:00

51 lines
3.3 KiB
Markdown

# Chookpen - A simple messaging service
## What is Chookpen?
Chookpen is a simple messaging service which allows users to talk to each other through text chat. In it's current state it has very low security and has many bugs, so please don't use this in production yet.
## How does Chookpen work?
Chookpen works by having a client and a server. The client sends a request to the server, which includes a username, hashed password and message contents. The server returns that request with previous messages.
## How do I get started?
First, you'll need to install Gradle and Java version 17 or later. These instructions vary depending on your OS, so look those up.
Next, clone the repository with `git clone https://git.maxwellj.xyz/max/chookpen`. Change to the `server` directory. Create the files `chatHistory` and `userDatabase`. Next, open a terminal and `gradle run`. Once the server starts, you can now send requests to the server! Using a web browser or `curl`, whichever is preferable, make a request to `http://localhost:8000/api/createAccount/username:{(pick a username)}token:{(pick a token)}`. If all works, you should have created an account!
Once you've created an account through the API, you can send requests using your token and username. You can send a request to see the chat history like this: `http://localhost:8000/api/username:{(your username)}token:{(your password)}`. If you'd like to send a message, it's like this: `http://localhost:8000/api/username:{(your username)}token:{(your password)}message:{(a message)}`.
If you don't want all the hassle of sending requests, you can use the experimental CLI client. Open a new terminal, and cd to `client-cli`. Run `gradle installDist`, and wait for it to build. Cd to build/install. Make a file called `.chookpen.profile` and add the following information, styled like a Unix /etc/passwd (colons in between items):
`username:password:server:port:0`
NOTE: When creating your account with this method, use the MD5 hash of your password. If you're unsure of what it is, just fill in all your details in .chookpen.profile and run the program. The server will tell you the hash the CLI created.
Once you're set up, run the CLI program in bin. Use the .bat if you're on Windows (yucky). If you want to send a message, add that as your argument. You should see all the messages! If that isn't working, make sure your .chookpen.profile is in your current directory.
## How can I make my own client?
Chookpen is very simple in how it works at present. There's only one chat on each server, and messages are sent as plaintext (unless you put your server behind a reverse proxy like Caddy). You can send a request to create an account, get messages or send a message.
### Brief API documentation for the server
**Create account**
`http://(address:port)/api/createAccount/username:{(username)}token:{(password-hash)}`
**Send a message**
`http://(address:port)/api/username:{(username)}token:{(password-hash)}message:{(message to send)}`
**Get messages**
`http://(address:port)/api/username:{(username)}token:{(password-hash)}`
## Some handy tips and tricks
Chookpen Server **does not support HTTPS!** You can put Chookpen Server behind a reverse proxy and that will sort that out for you.
Chookpen Server and CLI client are both in an alpha stage, keep this in mind before doing ANYTHING with it!
Chookpen Server is not ready for production :/