utils

package
v0.0.0-...-1df5730 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPort = errors.New("invalid port")
)

Functions

func AddParamsToContact

func AddParamsToContact(contact *sip.ContactHeader, expires *sip.Expires)

func BuildContactHeader

func BuildContactHeader(name string, from, to sip.Message, expires *sip.Expires)

func GetBranchID

func GetBranchID(msg sip.Message) sip.MaybeString

branch 是从via头域获取. 参考:https://www.jianshu.com/p/84d7289a4d3b.

func GetIP

func GetIP(addr string) string

func GetLoggers

func GetLoggers() map[string]*MyLogger

func GetPort

func GetPort(addr string) string

func ListenUDPInPortRange

func ListenUDPInPortRange(portMin, portMax int, laddr *net.UDPAddr) (*net.UDPConn, error)

func NewLogrusLogger

func NewLogrusLogger(level log.Level, prefix string, fields log.Fields) log.Logger

func SetLogLevel

func SetLogLevel(prefix string, level log.Level) error

func StrToUint16

func StrToUint16(str string) uint16

Types

type MyLogger

type MyLogger struct {
	Logger *log.LogrusLogger
	// contains filtered or unexported fields
}

func (*MyLogger) Level

func (ml *MyLogger) Level() string

Jump to

Keyboard shortcuts

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