ufo

package module
v0.0.0-...-d998b06 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: BSD-2-Clause Imports: 15 Imported by: 0

README

UFO

The server component of the PARANOIA project

Building

$ cd cmd/ufo && go install

Running

Running the binary exposes the api on port 8080

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthDenied = errors.New("Auth denied")

ErrAuthDenied is returned when a user has failed a verification challenge

View Source
var ErrBadUUID = errors.New("bad UUID")

ErrBadUUID is returned when a user sends a malfromed UUID to the server.

View Source
var ErrGroupExists = errors.New("Group Exists")

ErrGroupExists is returned when a user tries to create a group with an existing UUID

View Source
var ErrKeyExists = errors.New("Key already exist")

ErrKeyExists is returned on registration when a someone has already registered with that key

View Source
var ErrKeyNotExist = errors.New("Key doesnt exist")

ErrKeyNotExist is returned when a user tries to verify with a key that is not registered

View Source
var ErrNoSuchUUID = errors.New("No such UUID")

Functions

func ChallengeHandler

func ChallengeHandler(w http.ResponseWriter, r *http.Request)

ChallengeHandler is the endpoint for challenge requests it accepts a json marshalled ChallengeIn struct and returns a marshalled ChallengeOut on success.

func EncodePublicRSA

func EncodePublicRSA(pubkey *rsa.PublicKey) (string, error)

EncodePublicRSA key takes a PublicKey struct and encodes it to a PKIX PEM encoded string

func ListHandler

func ListHandler(w http.ResponseWriter, r *http.Request)

ListHandler is the endpoint for users to query what groups they are a part of. It accepts a ListIn struct and returns a ListOut struct.

func LogHandler

func LogHandler(w http.ResponseWriter, r *http.Request)

LogHandler is the debug page for viewing errors

func MakeConvoHandler

func MakeConvoHandler(w http.ResponseWriter, r *http.Request)

MakeConvoHandler is the endpoint for creation of conversations, it accepts a json marshalled GroupIn struct and returns a marshalled GroupOut struct on success.

func ParsePublicRSA

func ParsePublicRSA(public string) (*rsa.PublicKey, error)

ParsePublicRSA parses a PKIX PEM encoded RSA key

func ReadHandler

func ReadHandler(w http.ResponseWriter, r *http.Request)

ReadHandler is the endpoint for requesting messages from the server. It accepts a marshalled ReadIn struct and returns a marshalled ReadOut struct on success.

func RegisterInHandler

func RegisterInHandler(w http.ResponseWriter, r *http.Request)

RegisterInHandler is the endpoint for registration requests it accepts a marshalled RegisterIn struct and returns a 200 status code on success.

func UFO

func UFO(w http.ResponseWriter, r *http.Request)

UFO is a http.HandlerFunc that routes all of ufo's HTTP endpoints.

func WriteHandler

func WriteHandler(w http.ResponseWriter, r *http.Request)

WriteHandler is the endpoint for writing messages to a group. It accepts a WriteIn struct and returns a 200 status code on success with a body of "OK"

Types

type ChallengeIn

type ChallengeIn struct {
	FingerPrint //User's public key fingerprint
}

ChallengeIn is the JSON object for users to request a challenge

type ChallengeOut

type ChallengeOut struct {
	UUID string //Plain text UUID that user must sign
}

ChallengeOut is the JSON object for challenge reuqest responses.

type Event

type Event struct {
	Description string
	Error       error
}

Event is a log event

func (*Event) String

func (e *Event) String() string

type FingerPrint

type FingerPrint string

FingerPrint is a SHA256 hash of PEM encoded public key */

type Group

type Group struct {
	UUID    string        //UUID of group
	Members []FingerPrint //Public keys of the members in that group
}

Group represents a group chat, identified by UUID

type GroupIn

type GroupIn struct {
	Group
	SignedFingerPrint
}

GroupIn is the JSON object for conversation create requests

type GroupOut

type GroupOut struct {
	Error, UUID string
}

GroupOut is the JSON object response for conversation create requests.

type ListIn

type ListIn struct {
	SignedFingerPrint
}

ListIn is the JSON object for users to list what groups they are in.

type ListOut

type ListOut struct {
	GroupUUIDs []string
}

ListOut is the JSON object response for list requests.

type Msg

type Msg struct {
	From    FingerPrint //Sender's public key
	Content string      //Content of message
}

Msg is a single message from or to a client

type ReadIn

type ReadIn struct {
	SignedFingerPrint
	GroupID string
}

ReadIn is the JSON object for users to request their messages.

type ReadOut

type ReadOut struct {
	Msgs []Msg
	Err  error
}

ReadOut is the JSON object response for read requests.

type Reciept

type Reciept struct {
	User FingerPrint
	Room string
}

Reciept is a mark in to the message array for a conversation such that we only send new "unread" messages

type RegisterIn

type RegisterIn struct {
	Public string //Pem enoded public key
	Sig    Sig    //Signature of the contents of Public
}

RegisterIn is the JSON object for user registration.

type Sig

type Sig string

Sig is a base64 encoded PKCS1v15 signature

type SignedFingerPrint

type SignedFingerPrint struct {
	FingerPrint         //Public key of user they claim to be
	SignedChallenge Sig //Signature of sha256 encoded UUID challenge
}

SignedFingerPrint is used to verify the authenticity of a user.

type WriteIn

type WriteIn struct {
	SignedFingerPrint
	GroupID string
	Content string
}

WriteIn is the JSON object for write requests.

Directories

Path Synopsis
cmd
ufo

Jump to

Keyboard shortcuts

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