utils

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 321

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

AddMissingPort adds a port to a host if it is missing. A literal IPv6 address in hostport must be enclosed in square brackets, as in "[::1]:80", "[::1%lo0]:80".

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 FilterContentType added in v0.7.0

func FilterContentType(content string) string

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 NewNetAddr added in v0.3.0

func NewNetAddr(network, address string) net.Addr

NewNetAddr creates a new NetAddr object with the network and address provided.

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

SkipCRLF will only skip the next CRLF("\r\n"), otherwise, error will be returned.

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{}

type NetAddr added in v0.3.0

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

NetAddr implements the net.Addr interface.

func (*NetAddr) Network added in v0.3.0

func (na *NetAddr) Network() string

Network implements the net.Addr interface.

func (*NetAddr) String added in v0.3.0

func (na *NetAddr) String() string

String implements the net.Addr interface.

Jump to

Keyboard shortcuts

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