server

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERootCAFailed = errors.New("failed to add Root CAs to certificate pool")
)
View Source
var MaxFileSize int64 = 1 << 24 // 16 MB

Du to the use of bytes.Reader max file size will be limited to 2^32 and practically to a much lower user defined value. This helps prevent heap memory exhaustion.

Functions

func CheckDir

func CheckDir(path string) error

func CheckFile

func CheckFile(path, name string) error

func FindAndReplace

func FindAndReplace(buf []byte, w io.Writer, fn func(string) string)

func FindTemplates

func FindTemplates(buf []byte) (locs []int)

func IsCached

func IsCached(f http.File) bool

func NewTLSConfig

func NewTLSConfig(c TLSConfig) (*tls.Config, error)

func ReplaceTemplates

func ReplaceTemplates(src []byte, w io.Writer, locs []int, fn func(string) string)

func SetDelims

func SetDelims(start, end string)

func SetMaxReplace

func SetMaxReplace(size int)

func TLSVersion

func TLSVersion(v int) uint16

func TLSVersionString

func TLSVersionString(v uint16) string

Types

type AccessLog

type AccessLog struct {
	Time          time.Time `json:"time"`
	RemoteAddr    string    `json:"remote_addr"`
	Host          string    `json:"host"`
	Request       string    `json:"request"`
	RequestMethod string    `json:"request_method"`
	Referrer      string    `json:"referrer"`
	UserAgent     string    `json:"user_agent"`
	SslProtocol   string    `json:"ssl_protocol"`
	SslCipher     string    `json:"ssl_cipher"`
	Status        int       `json:"status"`
	BodyBytesSent int       `json:"body_bytes_sent"`
	ContentType   string    `json:"content_type"`
	RequestId     string    `json:"request_id"`
	RequestTime   float64   `json:"request_time"`
}

type CacheConfig

type CacheConfig struct {
	Enable  bool
	Expires time.Duration
	Control string
	Rules   []CacheRule
}

type CacheRule

type CacheRule struct {
	Filename string
	Regexp   *regexp.Regexp
	Ignore   bool
	NoCache  bool
	Expires  time.Duration
	Control  string
}

type CachedFile

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

func NewCachedBuffer added in v1.2.4

func NewCachedBuffer(name string, buf []byte) (*CachedFile, error)

func NewCachedFile

func NewCachedFile(f http.File) (*CachedFile, error)

func (*CachedFile) Close

func (f *CachedFile) Close() error

func (*CachedFile) Read

func (f *CachedFile) Read(p []byte) (n int, err error)

func (*CachedFile) Readdir

func (f *CachedFile) Readdir(count int) ([]os.FileInfo, error)

func (*CachedFile) ReplaceTemplates

func (f *CachedFile) ReplaceTemplates()

func (*CachedFile) Seek

func (f *CachedFile) Seek(offset int64, whence int) (int64, error)

func (*CachedFile) Stat

func (f *CachedFile) Stat() (os.FileInfo, error)

type CachedFileInfo

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

func NewCachedFileInfo

func NewCachedFileInfo(fi os.FileInfo) *CachedFileInfo

func (*CachedFileInfo) IsDir

func (i *CachedFileInfo) IsDir() bool

func (*CachedFileInfo) ModTime

func (i *CachedFileInfo) ModTime() time.Time

func (*CachedFileInfo) Mode

func (i *CachedFileInfo) Mode() os.FileMode

func (*CachedFileInfo) Name

func (i *CachedFileInfo) Name() string

func (*CachedFileInfo) Size

func (i *CachedFileInfo) Size() int64

func (*CachedFileInfo) Sys

func (i *CachedFileInfo) Sys() interface{}

type SPAServer

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

func NewSPAServer

func NewSPAServer() (*SPAServer, error)

func (*SPAServer) Address

func (s *SPAServer) Address() string

func (*SPAServer) ServeHTTP

func (s *SPAServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*SPAServer) TLS

func (s *SPAServer) TLS() *tls.Config

func (*SPAServer) TryFile

func (s *SPAServer) TryFile(r *http.Request, name string) (http.File, string, error)

func (*SPAServer) WriteHeaders

func (s *SPAServer) WriteHeaders(w http.ResponseWriter, r *http.Request, f http.File, start time.Time)

type ServerConfig

type ServerConfig struct {
	Addr   string
	Port   int
	Scheme string
	Host   string
	Root   string
	Base   string
	Index  string
	CspLog string
	Cache  CacheConfig
	Tpl    TemplateConfig
}

type TLSConfig

type TLSConfig struct {
	ServerName         string   `json:"server_name"`
	AllowInsecureCerts bool     `json:"disable_tls"`
	TLSMinVersion      int      `json:"tls_min_version"`
	TLSMaxVersion      int      `json:"tls_max_version"`
	RootCaCerts        []string `json:"tls_ca"`
	RootCaCertsFile    string   `json:"tls_ca_file"`
	Cert               []string `json:"tls_cert"`
	CertFile           string   `json:"tls_cert_file"`
	Key                []string `json:"tls_key"`
	KeyFile            string   `json:"tls_key_file"`
}

func (TLSConfig) Check

func (cfg TLSConfig) Check() error

type TemplateConfig

type TemplateConfig struct {
	Enable     bool
	Match      *regexp.Regexp
	Left       string
	Right      string
	MaxSize    int64
	MaxReplace int
}

Jump to

Keyboard shortcuts

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