heff

package
v0.0.0-...-edf45a4 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const Src = `` /* 311955-byte string literal not displayed */

Src is A. A. Milne's "Once on a Time" as transcribed by Project Gutenberg.

Variables

View Source
var DefaultHoneypot = NewHoneypot(DefaultMarkovMap, 100*1<<10)

DefaultHoneypot is an http.HandlerFunc that serves random HTML from the DefaultMarkovMap, 100KB at a time.

View Source
var DefaultMarkovMap = MakeMarkovMap(strings.NewReader(Src))

DefaultMarkovMap is a Markov chain based on Src.

Functions

func NewHoneypot

func NewHoneypot(mm MarkovMap, buffsize int) http.HandlerFunc

NewHoneypot creates an http.HandlerFunc from a MarkovMap

func ScanHTML

func ScanHTML(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanHTML is a basic split function for a Scanner that returns each space-separated word of text or HTML tag, with surrounding spaces deleted. It will never return an empty string. The definition of space is set by unicode.IsSpace.

Types

type MarkovMap

type MarkovMap map[tokenPair][]string

MarkovMap is a map that acts as a Markov chain generator.

func MakeMarkovMap

func MakeMarkovMap(r io.Reader) MarkovMap

MakeMarkovMap makes an empty MakeMarkov and fills it with r.

func (MarkovMap) Add

func (mm MarkovMap) Add(w1, w2, w3 string)

Add adds a three token sequence to the map.

func (MarkovMap) Fill

func (mm MarkovMap) Fill(r io.Reader)

Fill adds all the tokens in r to a MarkovMap

func (MarkovMap) Get

func (mm MarkovMap) Get(w1, w2 string) string

Get pseudo-randomly chooses a possible suffix to w1 and w2.

func (MarkovMap) Read

func (mm MarkovMap) Read(p []byte) (n int, err error)

Read fills p with data from calling Get on the MarkovMap.

Jump to

Keyboard shortcuts

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