dtp

package
v8.0.0-rc0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ByteMask = 0x8000000000000000
View Source
const ReadBlockSize = 32
View Source
const XDtpCcHdrStr = `X-Dtp-Cc`
View Source
const XDtpHdrStr = `X-Dtp`

Variables

View Source
var Buf3Cache []byte
View Source
var Buf3Mutex sync.Mutex
View Source
var GlobalConfig = NewConfig()
View Source
var GlobalForwarderFuncs = map[string]NewForwardFunc{}
View Source
var GlobalGeneratorFuncs = map[string]NewGeneratorFunc{}
View Source
var GlobalHandlerFuncs = map[string]HandlerFunc{}
View Source
var TexMutex sync.Mutex
View Source
var Texture []byte
View Source
var TextureCache []byte
View Source
var TextureCap int

Functions

func BinStamp

func BinStamp(w http.ResponseWriter, r *http.Request, reqdat map[string]string)

func ConfigHandler

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

handle api configuration endpoint

func DebugLog

func DebugLog(s string)

func DebugLogf

func DebugLogf(format string, args ...interface{})

func EvalNumber

func EvalNumber(numStr string, randSeed int64) int64

func Hijack

func Hijack(w http.ResponseWriter, r *http.Request, reqdat map[string]string)

func Logger

func Logger(alog *log.Logger, next http.Handler) http.Handler

func NewSeekPosFor

func NewSeekPosFor(
	off int64,
	whence int,
	posold int64,
	size int64,
) (int64, error)

func ProcessHeaders

func ProcessHeaders(w http.ResponseWriter, r *http.Request, reqdat map[string]string) bool

func ReadBlock

func ReadBlock(
	pbuf []byte,
	at int64,
	max int64,
	blk_size int64,
	blk_gen func(ct int64) []byte,
) (n int, err error)

func TextStamp

func TextStamp(w http.ResponseWriter, r *http.Request, reqdat map[string]string)

Types

type BinFastGen

type BinFastGen struct {
	Size       int64
	Pos        int64
	Rnd        int64
	Blockbytes int64
}

func (*BinFastGen) ContentType

func (bs *BinFastGen) ContentType() string

func (*BinFastGen) Read

func (bs *BinFastGen) Read(bufout []byte) (n int, err error)

func (*BinFastGen) Seek

func (bs *BinFastGen) Seek(off int64, whence int) (int64, error)

type BinGen

type BinGen struct {
	Size     int64
	Pos      int64
	Seed     int64
	Rnd      int64
	BufCache []byte
}

func (*BinGen) ContentType

func (bs *BinGen) ContentType() string

func (*BinGen) Read

func (bs *BinGen) Read(p []byte) (n int, err error)

func (*BinGen) Seek

func (s *BinGen) Seek(off int64, whence int) (int64, error)

type BinStampSeeker

type BinStampSeeker struct {
	Size int64
	Pos  int64
	Seed int64
	Rnd  int64
}

func (*BinStampSeeker) Read

func (s *BinStampSeeker) Read(p []byte) (n int, err error)

func (*BinStampSeeker) Seek

func (s *BinStampSeeker) Seek(off int64, whence int) (int64, error)

type Config

type Config struct {
	Debug         bool          `json:"debug"`
	EnablePprof   bool          `json:"enable_pprof"`
	Log           Log           `json:"log"`
	Timeout       Timeout       `json:"timeout"`
	StallDuration time.Duration `json:"stall_duration"`
}

func NewConfig

func NewConfig() Config

type DTPHandler

type DTPHandler struct{}

func NewDTPHandler

func NewDTPHandler() DTPHandler

func (DTPHandler) ServeHTTP

func (h DTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DelayForward

type DelayForward struct {
	Generator Generator
	Latency   time.Duration // per request latency
	FirstTime bool
}

func (*DelayForward) ContentType

func (ss *DelayForward) ContentType() string

func (*DelayForward) Read

func (ss *DelayForward) Read(bufout []byte) (bytes int, err error)

func (*DelayForward) Seek

func (ss *DelayForward) Seek(off int64, whence int) (int64, error)

type Evaluable

type Evaluable interface {
	Evaluate(stack []Number, rnd *rand.Rand) (pop int, push []Number)
}

func LexNumberStr

func LexNumberStr(s string) (ops []Evaluable)

type EvtForward

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

func (*EvtForward) ContentType

func (ss *EvtForward) ContentType() string

func (*EvtForward) Read

func (ss *EvtForward) Read(bufout []byte) (n int, err error)

func (*EvtForward) Seek

func (ss *EvtForward) Seek(off int64, whence int) (int64, error)

type Gen3sGen

type Gen3sGen struct {
	Size int64
	Pos  int64
}

func (*Gen3sGen) ContentType

func (s *Gen3sGen) ContentType() string

func (*Gen3sGen) Read

func (s *Gen3sGen) Read(p []byte) (n int, err error)

func (*Gen3sGen) Seek

func (s *Gen3sGen) Seek(off int64, whence int) (int64, error)

type Generator

type Generator interface {
	ContentType() string
	io.ReadSeeker
}

This is for content generation

func NewBinFastGen

func NewBinFastGen(reqdat map[string]string, lastmod int64) Generator

func NewBinGen

func NewBinGen(reqdat map[string]string, lastmod int64) Generator

func NewDelayForwardGen

func NewDelayForwardGen(
	w http.ResponseWriter,
	r *http.Request,
	gen Generator,
	reqdat map[string]string, updated int64,
) Generator

func NewEvtForwardGen

func NewEvtForwardGen(w http.ResponseWriter, r *http.Request, gen Generator, reqdat map[string]string, updated int64) Generator

func NewGen3sGen

func NewGen3sGen(reqdat map[string]string, lastmod int64) Generator

func NewTexGen

func NewTexGen(reqdat map[string]string, latmod int64) Generator

func NewTxtGen

func NewTxtGen(reqdat map[string]string, lastmod int64) Generator

type HandlerFunc

type HandlerFunc func(
	http.ResponseWriter,
	*http.Request,
	map[string]string,
)

No content generation

type Literal

type Literal int64

func (Literal) Evaluate

func (n Literal) Evaluate(stack []Number, rnd *rand.Rand) (pop int, push []Number)

type Log

type Log struct {
	Access          bool   `json:"access"`
	Path            string `json:"path"`
	RequestHeaders  bool   `json:"request_headers"`
	ResponseHeaders bool   `json:"response_headers"`
}

type LogRecorder

type LogRecorder struct {
	http.ResponseWriter

	Status       int
	HeaderBytes  int64
	ContentBytes int64
}

func (*LogRecorder) Write

func (rec *LogRecorder) Write(bytes []byte) (int, error)

func (*LogRecorder) WriteHeader

func (rec *LogRecorder) WriteHeader(code int)

type NewForwardFunc

type NewForwardFunc func(
	http.ResponseWriter,
	*http.Request,
	Generator,
	map[string]string,
	int64,
) Generator

type NewGeneratorFunc

type NewGeneratorFunc func(
	map[string]string,
	int64,
) Generator

type Number

type Number struct {
	Value    int64
	Weight   int64
	Sentinel bool
}

func (Number) String

func (n Number) String() string

type Operator

type Operator byte

func (Operator) Evaluate

func (o Operator) Evaluate(stack []Number, rnd *rand.Rand) (pop int, push []Number)

func (Operator) String

func (o Operator) String() string

type RangeBE

type RangeBE struct {
	Begin int64
	End   int64
}

func (*RangeBE) Contains

func (rng *RangeBE) Contains(val int64) bool

type TexGen

type TexGen struct {
	Size int64
	Pos  int64
	Rnd  int64
}

func (*TexGen) ContentType

func (s *TexGen) ContentType() string

func (*TexGen) Read

func (s *TexGen) Read(pbuf []byte) (n int, err error)

func (*TexGen) Seek

func (s *TexGen) Seek(off int64, whence int) (int64, error)

type TextStampSeeker

type TextStampSeeker struct {
	Size int64
	Pos  int64
	Seed int64
	Rnd  int64
}

func (*TextStampSeeker) Read

func (s *TextStampSeeker) Read(p []byte) (n int, err error)

func (*TextStampSeeker) Seek

func (s *TextStampSeeker) Seek(off int64, whence int) (int64, error)

type Timeout

type Timeout struct {
	Read  time.Duration `json:"read"`
	Write time.Duration `json:"write"`
	Idle  time.Duration `json:"idle"`
}

type TxtGen

type TxtGen struct {
	Size int64
	Pos  int64
	Seed int64
	Rnd  int64
}

func (*TxtGen) ContentType

func (s *TxtGen) ContentType() string

func (*TxtGen) Read

func (s *TxtGen) Read(p []byte) (n int, err error)

func (*TxtGen) Seek

func (s *TxtGen) Seek(off int64, whence int) (int64, error)

Jump to

Keyboard shortcuts

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