Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

F1xw/p2p-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

P2P-Chat

P2P-Chat is a python based peer-to-peer chat client with a command line interface.

For your information:

As this project was only for demonstation purposes as part of my paper on p2p, I will no longer work on p2p-chat.
You may fork this repository to work on it yourself.

Peer-to-peer vs. Client/Server

A regular client/server based chat:

         /<----\      /<----\
Client A        Server       Client B
         \---->/      \---->/

A peer-to-peer based chat:

         /<----\
Client A        Client B
         \---->/

As you can see, there is no third-party server involved when using peer-to-peer. All the messages you send and receive are private. They're only seen by your client and the client you are connected to.

#f03c15 WARNING: Nothing this client sends or receives is encrypted. Do only use it when connected to a private network.

Installation

To install P2P-Chat simply download this repo.

git clone https://github.com/F1xw/p2p-chat
cd ./p2p-chat

Requirements

P2P-Chat uses several python module. Make sure the package manager pip is installed, so that p2p-chat can automatically install all required modules.

For Windows users:

npyscreen uses the curses library which might not be pre-installed on windows. Download the corresponding version for your installation from here and install it with pip.

Usage

Run /run.py to start the client.

python run.py

You will be greeted with a slick, nostalgic CLI.

Try resizing your terminal if the app chrashes instantly.


To use p2p-chat follow these steps:

  1. Set your nickname with /nickname
  2. Connect to a peer with /connect

You are now able to send messages to the connected peer by typing them in and pressing enter. Take a look at all the other commands down below.

Commands

P2P-Chat uses commands to setup and connect. Try /help to get a list of all available commands.

Connect to a peer

Use /connect [host] [port] to connect to a peer. The client will try to connect for 5 seconds. You will have to set your nickname before connecting using /nick

Example:

/connect office-pc.local 3333

Disconnect

Use /disconnect to close the current connection.

Example:

/disconnect

Nickname

Use /nick [nickname] to set your nickname. Updating your nickname while a connection is active will send your new name to the connected peer.

Example:

/nick flowei

Quit

Use /quit to quit the app.

Example:

/quit

Port

Use /port to change the port your server runs on.

Example:

/port 3456

Connectback

Use /connectback to connect to a peer without having to enter their hostname and port. This command is only available if your server receives a connection while your client is not connected.

Example:

/connectback

Clear

Use /clear to clear the chat.

Example:

/clear

Eval

Use /eval [python code] to execute python code within the app itself. The output will be relayed to the chat feed.

Example:

# Print the nickname of the connected peer
/eval print(self.peer)
# Generate a system message
/eval self.sysMsg("Hello from /eval!")
# Forcefully exit the app
/eval exit()

Status

Use /status to get the current status of server and client.

Example:

/status

Log

Use /log to log all messages sent and received during your session to a file.

Example:

/log

Help

Use /help to get a list of all available commands.

Example:

/help