utils

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPool          = errors.New("empty pool")
	ErrInvalidPoolAddress = errors.New("invalid address")
)

Functions

func FD

func FD(c net.Conn) int

FD getting file descriptor

func RandomPort

func RandomPort(host string) (string, error)

RandomPort getting random port

Types

type Configer

type Configer interface {
	Get(name string) List
}

Configer ...

type List

type List []string

List ...

func (List) Pool

func (v List) Pool() (*url.URL, error)

Pool ...

type Pool

type Pool struct {
	Items map[string]List `yaml:"services" json:"services"`
}

Pool ...

func (Pool) Get

func (c Pool) Get(name string) List

Get ...

type Pooler

type Pooler interface {
	Pool() (*url.URL, error)
}

Pooler ...

type Signature

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

Signature model

func NewCustomSignature

func NewCustomSignature(id, secret, alg string, h func() hash.Hash) *Signature

NewCustomSignature create sign with custom hash function

func NewMD5

func NewMD5(id, secret string) *Signature

NewMD5 create sign md5

func NewSHA256

func NewSHA256(id, secret string) *Signature

NewSignature create sign sha256

func NewSHA512

func NewSHA512(id, secret string) *Signature

NewSHA512 create sign sha512

func (*Signature) Algorithm

func (s *Signature) Algorithm() string

Algorithm getter

func (*Signature) Create

func (s *Signature) Create(b []byte) []byte

Create getting hash as bytes

func (*Signature) CreateString

func (s *Signature) CreateString(b []byte) string

CreateString getting hash as string

func (*Signature) ID

func (s *Signature) ID() string

ID signature

func (*Signature) Validate

func (s *Signature) Validate(b []byte, ex string) bool

Validate signature

type SignatureStorage

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

SignatureStorage storage

func NewSignatureStorage

func NewSignatureStorage() *SignatureStorage

NewSignatureStorage init storage

func (*SignatureStorage) Add

func (ss *SignatureStorage) Add(s Signer)

Add adding to storage

func (*SignatureStorage) CleanAll

func (ss *SignatureStorage) CleanAll()

CleanAll removing all from storage

func (*SignatureStorage) Count

func (ss *SignatureStorage) Count() int

Count count sign in storage

func (*SignatureStorage) Del

func (ss *SignatureStorage) Del(id string)

Del deleting from storage

func (*SignatureStorage) Get

func (ss *SignatureStorage) Get(id string) Signer

Get getting to storage

type Signer

type Signer interface {
	ID() string
	Algorithm() string
	Create(b []byte) []byte
	CreateString(b []byte) string
	Validate(b []byte, ex string) bool
}

Signer interface

Jump to

Keyboard shortcuts

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