go-chat

command module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 8 Imported by: 0

README ΒΆ

Go Chat

Release version Project language Release License Image size

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.

How-to

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 β”œβ”€β”€β”€β”€β”€β”€β”€β”˜
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Configure

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.

Usage

Binaries

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 click Open Anyway.

Docker

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 is 12345 and default HOST is 0.0.0.0 for Docker.

Build from source

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.


Support πŸ’›

Donate with Bitcoin Donate with Ethereum

ko-fi

Contributing 🀝

Don't be shy and reach out to us if you want to contribute πŸ˜‰

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Issues

Each project may have many problems. Contributing to the better development of this project by reporting them. πŸ‘

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL