client-cli | ||
server | ||
.gitignore | ||
LICENSE | ||
README.md |
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
in your home directory 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). You should be able to send and recieve messages! If that isn't working, make sure your .chookpen.profile is in your system home 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
Usage
http://(address:port)/api/createAccount/username:{(username)}token:{(password-hash)}
Successful response
Success
Unsuccessful responses
Username already exists
- Choose a new username
No username
- Add a username
No token
- Add a token
Send a message
Usage
http://(address:port)/api/send/username:{(username)}token:{(password-hash)}message:{(message to send)}
Successful response
Success
Unsuccessful responses
Unknown account
- Either you don't have an account or your username is wrong
Invalid token
- Password is wrong
No data provided
- Add a message
Get messages
Usage
http://(address:port)/api/syncmessages/username:{(username)}token:{(password-hash)}
Successful response
A successful response should contain everything in chatHistory
in the directory you run the server in.
Unsuccessful responses
Unknown account
- Either you don't have an account or your username is wrong
Invalid token
- Password is wrong
Websockets
Chookpen supports websockets for live updating of messages. You can establish a websocket connection with the URL ws://(server):(port)/api/websocket/
. Send a login request to the websocket: username:{(username)}password:{(password)}
. If your username and password are correct, you should start recieving messages. Send a message: username:{(username)}password:{(password)}message:{(message)}
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 :/
The port for the server is 7070.