<commit_before># p2p-messenger
A peer-to-peer messaging service

Compile with `make`

Start by running a server with `java Server port`

Then run any number of clients with the command `java Client server-ip server-port chat-name username`, with these arguments:

* `server-ip` is the IP address of the server
* `server-port` is the `port` from the server command
* `chat-name` identifies which chat to join (can be any string but will determine which clients talk to each other)
* `username` identifies a user when the other clients print out messages sent from this client

Then start typing in the clients' standard inputs. Each line will be distributed to everyone else in the chat.

To send files, type:
	/sendfile /path/to/file.txt

The path above can be either relative to current working directory, or absolute.

## TODO

* KEEPALIVE messages between clients and with server to detect clients disconnecting.
* Requesting of old messages, so a new peer can download all previously sent messages
    * Possibly the available messages should be sent in response to a "Business Card"
* Send files
* Resend packets like "HAVE" and "UNCHOKE" after a timeout if there is no response (possibly have a timeout on unchoke slots as well)
* Print out messages in chronological order.
* Make a UI for displaying Chat Transcript separate from input and in order, and for choosing file for attachment and for downloading files to given path.

### Possible additional features

* End-to-end Cryptography
* Passwords
* Tit-for-tat: selective unchoking strategy
* UDP punching: for breaking through NAT<commit_msg>Edited README<commit_after># p2p-messenger
A peer-to-peer messaging service

p2p-messenger is a groupchat application that allows users to message each other without having to talk to a central server after the initial connection occurs. It sends messages in a distributed manner, sending out each message in pieces and allowing recipients to download different pieces from other members of the chat. This reduces the number of copies the sender must deliver by distributing the load over the whole group.

## Installation

`git clone https://github.com/vtsah/p2p-messenger`
Compile with `make`

## Running the application

Start by running a server with `java Server port`

Then run any number of clients with the command `java Client server-ip server-port chat-name username`, with these arguments:

* `server-ip` is the IP address of the server (you can run a client on the same machine as the server using localhost)
* `server-port` is the `port` from the server command
* `chat-name` identifies which chat to join (can be any string but will determine which clients talk to each other)
* `username` identifies a user when the other clients print out messages sent from this client

Then start typing in the clients' standard inputs. Each line will be distributed to everyone else in the chat.

To send files, type:
`/sendfile /path/to/file.txt`

The path above can be either relative to current working directory, or absolute.
{'fraction_non_alphanumeric': 0.051070840197693576, 'fraction_numerical': 0.0013179571663920922, 'mean_word_length': 4.52, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5115007', 'n_tokens_mistral': 769, 'n_tokens_neox': 740, 'n_words': 450}