Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gdsoumya/distributed_chat
A simple modular distributed chat system with channels, it can be integrated and used as a data transport mechanism for any system.
https://github.com/gdsoumya/distributed_chat
chat-application distributed-systems e2e-encryption privacy transport-stream
Last synced: 23 days ago
JSON representation
A simple modular distributed chat system with channels, it can be integrated and used as a data transport mechanism for any system.
- Host: GitHub
- URL: https://github.com/gdsoumya/distributed_chat
- Owner: gdsoumya
- Created: 2020-04-25T05:45:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-27T01:46:28.000Z (over 2 years ago)
- Last Synced: 2024-09-14T03:55:30.287Z (about 2 months ago)
- Topics: chat-application, distributed-systems, e2e-encryption, privacy, transport-stream
- Language: TypeScript
- Homepage:
- Size: 2.43 MB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Distributed Chat
[![darkchat](https://circleci.com/gh/gdsoumya/distributed_chat.svg?style=svg)](https://app.circleci.com/projects/project-dashboard/github/gdsoumya)
A simple Distributed Chat system with E22 encryption for DMs.
In less than 300 lines total a distributed chat client with channels, a server that can manually peer with other servers and use rudimentary peer discovery to auto-connect with more peers. All clients connected to a specific channel can communicate even if they are connected to different servers, as long as the servers are peered together.There are 3 types of Servers :
1. **CLI-SERVER** : Only clients using CLI-CLient can connect to this server.
2. **WEBSOCK-SERVER** : Only Browser clients or WEBSOCK-Client can connect to this server.
3. **FULL-SERVER**: Any of the above clients can connect to this server.Even if the servers are of different types they can be peered together ensuring that clients of any type can communicate with clients of any other type, eg : client on browser communicating with cli-clients or websock-clients and vice-versa.
A server can communicate with the network even if it is behind a NAT or Firewall, other peers may not be able to discover a server behind a NAT but as long as the server is peered to a public node/server all local clients connected to it will be able to communicate throughout the network.
**No data is stored on the servers all messages recieved are propagated and forgotten. (Currently the messages are logged in Server prompt for debugging purposes but nothing is stored in the memory)**
## TRY IT OUT
To try this out follow the steps, our test node can be used to try out the system.
SERVER : capetown.arcology.nyc
WEBSOCK-CLIENT/WEB CLIENT PORT : 8546
CLI-CLIENT PORT : 8545
PEER PORT : 30303### INTIAL SETUP
```
git clone https://github.com/gdsoumya/distributed_chat.git
cd distributed_chat
npm install
```### SERVER SETUP
Depending on the requirement one can start up either a cli-server, websoc-server or a full-server, to start a server use the following command :
**1. CLI-SERVER**
```
node scripts/cliServer.js
```- ip : IP used by server to listen
- port1 : Port used for cli-client connections
- port2 : Port used for peer connections**2. WEBSOCK-SERVER**
```
node scripts/websockServer.js
```- ip : IP used by server to listen
- port1 : Port used for websock-client or browser connections
- port2 : Port used for peer connections**3. FULL-SERVER**
```
node scripts/fullServer.js
```- ip : IP used by server to listen
- port1 : Port used for cli-client connections
- port2 : Port used for websock-client or browser connections
- port3 : Port used for peer connections#### PEER CONNECTION
To connect to the peer-network, a server will need to peer with at least one server which is already connected to the network. To connect to a peer use the following command in the Server CLI Promt:
```
> connect
```- peer-ip : IP of Peer Server
- peer-port : Port used by peer server for peer connections (`port2` in case of cli and websock servers and `port3` for full servers)#### PEER LIST
To view all connected peers use the following command in the Server CLI Promt:
```
> peers
```### CLIENT SETUP
There are 2 clients : cli-client and websock-client each used for a different type of server. Both use the same command for connecting to the server :
```
node scripts/Client.js
```- type : Type of client - cli or websock
- server-ip : IP of Server to connect
- server-port : Port used by server for client connections#### CLIENT CONNECT
To make a successful connection to a node/server you need to verify your identity (Key-Pair ownership), start the connection using
```bash
> connect
```The server will send a random string that you need to sign and send back to the server for verification
```bash
#server responsse
> VERIFY : ""
```Sign the random string inbetween the quotes
```bash
> sign
>
```Transfer the signature to the server for verification
```bash
verify
```If the verification is successfull the connection will be established else a **MALFORMED ERROR** error will be thrown.
#### CLIENT CHANNEL COMMUNICATION
After succesful connection to the server the client can join any no. of channels using the command :
```bash
> join
```- channel-name : Name of channel to join
After a client has joined, it can send/recieve messages on that particular channel, to send messages use the CLI Prompt.
eg.
```bash
> this is a message from the client
> user@ - message from channel to client
```
#### CLIENT DIRECT COMMUNICATIONThe user can also send direct messages using the known publickey of another user :
```bash
private hello world
```