p2p-chat is controlled entirely from the terminal. You start and manage sessions through top-level subcommands passed toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Project516/p2p-chat/llms.txt
Use this file to discover all available pages before exploring further.
go run ., and once a session is active you interact using slash commands typed directly into the chat prompt.
Top-level subcommands
These commands are passed as the first argument togo run . and control how p2p-chat establishes a connection.
listen <address>
listen <address>
Binds a TCP listener on the given address and waits for exactly one incoming connection. The process blocks until a peer connects.Parameters
Expected outputOnce a peer connects:Error casesIf you omit the address argument, p2p-chat prints an error and a default address message, then starts a listener on
| Parameter | Required | Description |
|---|---|---|
address | Yes | The host:port to listen on. Example: localhost:5555, 0.0.0.0:9000. |
localhost:5555. However, the code immediately proceeds to read the missing args[2], which causes a runtime panic. Always pass the address explicitly.The listener accepts exactly one connection. After that connection closes, the process exits. To start another session, run
listen again.connect <address>
connect <address>
Dials the host listening at the given address and establishes a TCP connection. After the connection succeeds, both sides perform a key exchange before the chat session begins.Parameters
Expected outputError casesIf the host is not reachable or no listener is running at the address, the Go runtime will print a dial error and the process exits.
| Parameter | Required | Description |
|---|---|---|
address | Yes | The host:port of the peer running listen. Example: localhost:5555. |
version
version
Reads the version string from Expected outputThe version value reflects whatever is written in
assets/version.txt at runtime and prints it to the terminal. This command does not start a connection.assets/version.txt at the time you run the command. The current version is 1.0.0.No arguments or unknown subcommand
No arguments or unknown subcommand
If you run No connection is attempted.
go run . with no arguments, or with an unrecognized subcommand, p2p-chat prints a usage line and exits.In-chat slash commands
Once a session is active (afterlisten accepts a connection or connect succeeds), you can type the following slash commands at the prompt. Commands prefixed with a / are intercepted locally before any text is sent to the peer.
/nick <nickname>
/nick <nickname>
Changes your display name. All subsequent messages you send appear to the other peer as Parameters
What the peer seesIf your current nick is The broadcast format is:Error cases
<nickname>> <text>. The name change is also broadcast to the peer as an alert.| Parameter | Required | Description |
|---|---|---|
nickname | Yes | The new display name. Must be non-empty. |
friend and you run /nick alice, the peer sees:- If you type
/nickwith no name (empty argument), p2p-chat prints an error locally and does not change the display name. - If the command string is too short to parse a name, the same local error is shown and nothing is sent to the peer.
The nickname change alert is sent over the encrypted connection. The peer sees it as a system message, not as a regular chat line.
/quit
/quit
Sends a leave notice to the peer and then exits the program. The peer receives a system message indicating you have left.What the peer seesNo parameters. Anything typed after
/quit is ignored./help
/help
Prints the help menu to your local terminal. Nothing is sent to the peer.The help output lists the available slash commands and their descriptions. It is printed only on your side of the connection.No parameters.
/version
/version
Reads Expected outputNo parameters.
assets/version.txt and prints the version string to your local terminal. Nothing is sent to the peer.The in-chat
/version command outputs p2p version: (without -chat), while the top-level go run . version subcommand outputs p2p-chat version:. Both read from the same assets/version.txt file.Plain text messages
Any input that does not begin with/ is treated as a chat message. The message is encrypted and sent to the peer, where it appears formatted as:
Messages are encrypted before leaving your machine using NaCl box (XSalsa20-Poly1305). The peer decrypts them on receipt. See the encryption reference for details.
uint16 length header used by the transport layer.
Shell script shortcuts
The repository includes three shell scripts that wrap common command-line invocations:| Script | Equivalent command |
|---|---|
host.sh | go run . listen localhost:5555 |
connect.sh | go run . connect localhost:5555 |
run.sh | go fmt ./... && go vet ./... && go run . |