Simple & Encrypted Chat
MIT License
It's a simple chat system using a PUB/SUB single channel and GPG encryption. Any message sent from a client ( publisher ) is routed to each other client ( subscriber ) on demand.
All messages are encrypted using GPG and the public key of the recipient. The encrypted message is then sent to the server and routed to the recipient. The recipient then decrypts the message using their private key.
ββββββββββ ββββββββββ
Message ββββββΊ Client β β Client βββDecryptβββΊ
βββββ¬βββββ ββββββ²ββββ
β β
β ββββββββββ β
ββEncryptββββΊ Server βββββββββ
ββββββββββ
You need to have some environment variables set up. You can do this by creating a .env
file in the root of the project. See the example:
PORT=
HOST=
PUBLIC_KEY_FILE=
PRIVATE_KEY_FILE=
PASSPHRASE=
Variable | Description | Default |
---|---|---|
START_MODE | The mode to start the application | server |
PORT | The port the server will listen on. | 12345 |
HOST | The host the server will listen on. | localhost |
PUBLIC_KEY_FILE | The path to the public key file. | |
PRIVATE_KEY_FILE | The path to the private key file. | |
PASSPHRASE | The passphrase for the private key. |
To separate the server from the client, you can use the START_MODE
variable. This can be set to either server
or client
. If it is set to server
, the server will start. If it is set to client
, the client will start.
Note: You should escape any special characters for the
PASSPHRASE
.
Download the latest release from the releases page based on your operating system and architecture.
Server:
START_MODE=server ./go-chat-linux-amd64
Client:
Configure your .env
file and then run the following command:
START_MODE=client ./go-chat-linux-amd64
Note: For MacOS, you should allow the application to run. You can do this by going to
System Preferences > Security & Privacy > General
and then clickOpen Anyway
.
I think we don't need a Docker image for the Client. But if you want to run the Server in a Docker container, you can use the published image.
docker run -it hatamiarash7/go-chat-server
Use PORT
and HOST
environment variables to configure the server.
docker run -it -e PORT=1234 -e HOST=0.0.0.0 hatamiarash7/go-chat-server
Note: Default
PORT
is12345
and defaultHOST
is0.0.0.0
for Docker.
To build the application from source, run the build
target:
make build
First, you should build you need to start the server. You can do this by running the following command:
make server
Then, you can run any number of clients. You can do this by running the following command:
make client
Note that you should set required environment variables before running the client.
Don't be shy and reach out to us if you want to contribute π
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
Each project may have many problems. Contributing to the better development of this project by reporting them. π