utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 12 Imported by: 270

Documentation

Index

Constants

View Source
const (
	UNKNOWN_IP_ADDR = "-"
)

Variables

View Source
var CopyBufPool = sync.Pool{
	New: func() interface{} {
		return make([]byte, 4096)
	},
}

Functions

func AddMissingPort

func AddMissingPort(addr string, isTLS bool) string

func Assert

func Assert(guard bool, text string)

func CaseInsensitiveCompare

func CaseInsensitiveCompare(a, b []byte) bool

func CleanPath

func CleanPath(p string) string

CleanPath is the URL version of path.Clean, it returns a canonical URL path for p, eliminating . and .. elements.

The following rules are applied iteratively until no further processing can be done:

  1. Replace multiple slashes with a single slash.
  2. Eliminate each . path name element (the current directory).
  3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
  4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.

If the result of this process is an empty string, "/" is returned

func CopyBuffer

func CopyBuffer(dst network.Writer, src io.Reader, buf []byte) (written int64, err error)

func CopyZeroAlloc

func CopyZeroAlloc(w network.Writer, r io.Reader) (int64, error)

func IsTrueString

func IsTrueString(str string) bool

func LocalIP

func LocalIP() string

LocalIP returns host's ip

func NameOfFunction

func NameOfFunction(f interface{}) string

func NextLine

func NextLine(b []byte) ([]byte, []byte, error)

func NormalizeHeaderKey

func NormalizeHeaderKey(b []byte, disableNormalizing bool)

func ParseChunkSize

func ParseChunkSize(r network.Reader) (int, error)

func SkipCRLF

func SkipCRLF(reader network.Reader) error

func TLSRecordHeaderLooksLikeHTTP

func TLSRecordHeaderLooksLikeHTTP(hdr [5]byte) bool

TLSRecordHeaderLooksLikeHTTP reports whether a TLS record header looks like it might've been a misdirected plaintext HTTP request.

Types

type H

type H map[string]interface{}

H is a shortcut for map[string]interface{}

Jump to

Keyboard shortcuts

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