bingo

package module
v0.0.0-...-28399dc Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2015 License: MIT Imports: 26 Imported by: 0

README

bingo

A pastebin-like written in Go where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using AES.

Build

bingo is written in go so it compiles easily through go install github.com/reenjii/bingo/cmd/bingo.

Assets (templates, scripts, styles, conf) are managed by Grunt. Install Grunt and run grunt to build assets in the dist directory.

Run

The server uses a json configuration file (defaults to /etc/bingo.json). The configuration path can be set in the command line: $GOPATH/bin/bingo -conf /path/to/my/bingo.json. An example configuration file is deployed in dist/conf folder by grunt.

The configuration file contains the path of the views and the assets (static folder). You must set these paths to make data in dist/views and in dist/static available to the server.

Example

$> $GOPATH/bin/bingo                                                                                                                                                                                                              [1]
INFO  2015/12/03 11:35:06.064178 Bingo initialization
INFO  2015/12/03 11:35:06.064682 Templates initialization
INFO  2015/12/03 11:35:06.064820 Views are in  /tmp/bingo/dist/views/*.html
INFO  2015/12/03 11:35:06.064880 Loading template /tmp/bingo/dist/views/paste.html
INFO  2015/12/03 11:35:06.065444 Create folder /tmp/bingo/data
INFO  2015/12/03 11:35:06.065530 Build paste index...
INFO  2015/12/03 11:35:06.065634 Paste index built with 0 entries
INFO  2015/12/03 11:35:06.065697 Start clean daemon with a 3600 seconds threshold
INFO  2015/12/03 11:35:06.065823 Listening on :1337

Documentation

Overview

Package bingo is a pastebin-like where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using AES.

Index

Constants

View Source
const (
	ERROR = 1 << iota
	WARN
	INFO
	TRACE
)

Variables

View Source
var Loggers struct {
	Error *log.Logger
	Warn  *log.Logger
	Info  *log.Logger
	Trace *log.Logger
}

Functions

func Serve

func Serve(file string)

Types

type Avatar

type Avatar struct {
	X int
	Y int
}

func (*Avatar) Avatar

func (avatar *Avatar) Avatar(data string) string

Creates an Avatar from input data. Returns a png image encoded as a base64 string.

type ByExpire

type ByExpire []indexEntry

ByExpire implements sort.Interface for []indexEntry based on the expire field.

func (ByExpire) Len

func (a ByExpire) Len() int

func (ByExpire) Less

func (a ByExpire) Less(i, j int) bool

func (ByExpire) Swap

func (a ByExpire) Swap(i, j int)

type Comment

type Comment struct {
	Id        string    `json:"id"`
	Author    string    `json:"author"`
	Avatar    string    `json:"avatar"`
	Data      string    `json:"data"`
	Postdate  time.Time `json:"postdate"`
	Highlight bool      `json:"highlight"`
	Parent    string    `json:"parent"`
}

A comment.

  • Id: comment id
  • Author: comment author (encrypted)
  • Avatar: author avatar
  • Data: comment (encrypted) data
  • Postdate: comment creation date
  • Highlight: whether to enable syntax highlighting
  • Parent: parent comment, if any

type CommentsByDate

type CommentsByDate []Comment

CommentsByDate implements sort.Interface for []Comment based on the Postdate field.

func (CommentsByDate) Len

func (a CommentsByDate) Len() int

func (CommentsByDate) Less

func (a CommentsByDate) Less(i, j int) bool

func (CommentsByDate) Swap

func (a CommentsByDate) Swap(i, j int)

type Conf

type Conf struct {
	Root           string `json:"root"`
	Views          string `json:"views"`
	Static         string `json:"static"`
	Log            string `json:"log"`
	Stdout         bool   `json:"stdout"`
	Verbosity      int    `json:"verbosity"`
	Port           int    `json:"port"`
	Depth          int    `json:"depth"`
	FloodThreshold int    `json:"floodThreshold"`
	CleanThreshold int    `json:"cleanThreshold"`
}

Application configuration.

  • Root: data folder path
  • Views: html templates folder
  • Static: static assets (js, css) folder
  • Log: log file
  • Stdout: when a log file is given, iset to true to still log on stdout
  • Verbosity: log verbosity mask
  • Port: webapp port
  • Depth: number of subfolders in data hierarchy (the more, the more folders, the fewer files per folder)
  • FloodThreshold: min delay (in seconds) between two posts for a single user
  • CleanThreshold: delete expired pasted from database once in that many seconds

type Dbm

type Dbm struct {
	// contains filtered or unexported fields
}

Deterministic byte machine.

func NewDbm

func NewDbm(data string) *Dbm

Create a new Deterministic Byte Machine.

type ErrorResponse

type ErrorResponse struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

Error response.

  • Code: error code
  • Error: error message

type Paste

type Paste struct {
	Id         string    `json:"id"`
	Data       string    `json:"data"`
	Expire     time.Time `json:"expire"`
	Postdate   time.Time `json:"postdate"`
	Burn       bool      `json:"burn"`
	Highlight  bool      `json:"highlight"`
	Discussion bool      `json:"discussion"`
	Comments   []Comment `json:"comments"`
}

A paste.

  • Id: paste id
  • Data: paste (encrypted) data
  • Expire: paste expiration date
  • Postdate: paste creation date
  • Burn: whether this paste must be deleted once read
  • Highlight: whether to enable syntax highlighting
  • Discussion: whether discussions are enabled
  • Comments: paste comments

type Postdata

type Postdata struct {
	Data       string `json:"data"`
	Author     string `json:"author"`
	Expire     int    `json:"expire"`
	Burn       bool   `json:"burn"`
	Highlight  bool   `json:"highlight"`
	Discussion bool   `json:"discussion"`
	Paste      string `json="paste"`
	Parent     string `json="parent"`
	Comment    bool   `json="comment"`
}

Postdata contains the json data sent by the client.

  • Data: paste (encrypted) data
  • Author: author (encrypted)
  • Expire: expiration date
  • Burn: whether this paste must be deleted once read
  • Highlight: whether to enable syntax highlighting
  • Discussion: whether discussions are enabled
  • Paste: parent paste, if any (for comments)
  • Parent: parent comment, if any (for comments)
  • Comments: whether this is a comment (true) or a regular paste (false)

type Postresponse

type Postresponse struct {
	Id       string    `json:"id"`
	Postdate time.Time `json:"postdate"`
	Expire   time.Time `json:"expire"`
	Delete   string    `json:"delete"`
	Avatar   string    `json:"avatar"`
}

Postresponse contains the json response sent to the client.

  • Id: paste id
  • Postdate: paste creation date
  • Expire: expiration date
  • Delete: delete token
  • Avatar: author's avatar (comments only)

type TemplateData

type TemplateData struct {
	Paste   Paste
	JPaste  string
	Deleted bool
	Code    int
}

Holds template data.

  • Paste: paste object
  • JPaste: marshaled paste
  • Deleted: true if the paste has been deleted
  • Code: error code

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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