chat

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: EUPL-1.2 Imports: 8 Imported by: 0

README

chat

latest version last commit top language licence

An end-to-end encrypted chat application. I wrote this to learn about end-to-end encryption and networking. Don't use this. It does run however.

Installation

Run go get -u github.com/patrickmcnamara/chat/....

Usage

Run chat-client, assuming your $GOPATH and $PATH are set up correctly, to run the client. Or run chat-server to run a server instead.

Client configuration

The config files are located in:

  • Unix systems, $XDG_CONFIG_HOME if non-empty, else $HOME/.config.
  • Darwin, $HOME/Library/Application Support.
  • Windows, %AppData%.
  • Plan 9, $home/lib.

There are three config files with this directory:

  • the config file just contains the server and port of the chat server.
  • the contacts file is a JSON mapping from a contact name to a 32-length byte array of the contact's public key.
  • the profile file contains a public and private key pair and is automatically be generated.

There are examples of each of these in the misc/example-config-files directory.

Server configuration

There is no configuration for the server. It uses port 6969. You might need to allow through your firewall or NAT setup.

Miscellaneous

To talk to someone with the client you must first select the contact using /msg CONTACT_NAME. Use quotes if the name contains a space.

Licence

This project is licenced under the European Union Public Licence v1.2.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSuchUser results when a message is sent to an offline or
	// non-existent user.
	ErrNoSuchUser = errors.New("no such user found")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Dial(address string) error
	Send(msg Message) error
	Recv() (Message, error)
	Close()
}

Client is a chat client that connects to chat server for a user.

func NewClient

func NewClient(u User) Client

NewClient creates a new chat client for the given user.

type Message

type Message struct {
	To   [32]byte `json:"to"`
	From [32]byte `json:"from"`
	Msg  []byte   `json:"msg"`
}

Message represents a message sent from one user to another. 'To' is the public key of the user the message is for and 'From' is the public key of the user sending the message.

type Server

type Server interface {
	ListenAndServe(address string) error
	Close()
}

Server is a chat server that routes messages between chat clients.

func NewServer

func NewServer() Server

NewServer creates a new chat server.

type User

type User struct {
	PublicKey  [32]byte `json:"publicKey"`
	PrivateKey [32]byte `json:"privateKey"`
}

User is a user of a chat server that connects through a chat client. It represents the public and private key pair used in end to end encryption. The public keys' of users are used as addresses when messaging.

func NewUser

func NewUser() User

NewUser creates a new user with a new X25519 key pair.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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