utils

package
v0.0.0-...-9b16b4d Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerSign = "OpenNG"
)

Variables

View Source
var Background = backgroundCtx{}

Functions

func ByteCountSI

func ByteCountSI(b uint64) string

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func ConnSync

func ConnSync(conn net.Conn, oconn net.Conn)

func HashPassword

func HashPassword(password string) (string, error)

func RandString

func RandString(n int) string

func TrimLeftChar

func TrimLeftChar(s string) string

Types

type BufferedLookup

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

func NewBufferedLookup

func NewBufferedLookup(f LookupFunc) *BufferedLookup

func (*BufferedLookup) Lookup

func (bl *BufferedLookup) Lookup(id string) (index interface{})

func (*BufferedLookup) Refresh

func (bl *BufferedLookup) Refresh()

type ByteCounterConn

type ByteCounterConn struct {
	Tx, Rx *uint64
	net.Conn
}

func (*ByteCounterConn) Read

func (bc *ByteCounterConn) Read(p []byte) (n int, e error)

func (*ByteCounterConn) Write

func (bc *ByteCounterConn) Write(p []byte) (n int, e error)

type Context

type Context interface {
	Signal(interface{}, interface{}) error
	Slot(interface{}) ContextSlot
	Store(interface{}, interface{})
	Load(interface{}) (interface{}, bool)

	Close()
}

type ContextSlot

type ContextSlot interface {
	Wait() <-chan interface{}
	Close()
}

type GroupRegexp

type GroupRegexp []*regexp2.Regexp

func MustCompileRegexp

func MustCompileRegexp(exps []string) GroupRegexp

func NewGroupRegexp

func NewGroupRegexp(exps []string) (GroupRegexp, error)

func (GroupRegexp) MatchString

func (r GroupRegexp) MatchString(k string) bool

func (GroupRegexp) String

func (r GroupRegexp) String() (ret []string)

type HangContext

type HangContext struct {
}

func (HangContext) Close

func (HangContext) Close()

func (HangContext) Load

func (HangContext) Load(k interface{}) (interface{}, bool)

func (HangContext) Signal

func (ctx HangContext) Signal(key interface{}, val interface{}) error

func (HangContext) Slot

func (ctx HangContext) Slot(interface{}) ContextSlot

func (HangContext) Store

func (HangContext) Store(k interface{}, v interface{})

type LookupFunc

type LookupFunc func(string) interface{}

type NilContext

type NilContext struct {
}

func (NilContext) Close

func (NilContext) Close()

func (NilContext) Load

func (NilContext) Load(k interface{}) (interface{}, bool)

func (NilContext) Signal

func (ctx NilContext) Signal(key interface{}, val interface{})

func (NilContext) Slot

func (ctx NilContext) Slot(interface{}) ContextSlot

func (NilContext) Store

func (NilContext) Store(k interface{}, v interface{})

type OneConn

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

func (*OneConn) Close

func (conn *OneConn) Close() error

func (*OneConn) LocalAddr

func (conn *OneConn) LocalAddr() net.Addr

func (*OneConn) Read

func (conn *OneConn) Read(p []byte) (i int, e error)

func (*OneConn) RemoteAddr

func (conn *OneConn) RemoteAddr() net.Addr

func (*OneConn) SetDeadline

func (conn *OneConn) SetDeadline(t time.Time) error

func (*OneConn) SetReadDeadline

func (conn *OneConn) SetReadDeadline(t time.Time) error

func (*OneConn) SetWriteDeadline

func (conn *OneConn) SetWriteDeadline(t time.Time) error

func (*OneConn) Write

func (conn *OneConn) Write(p []byte) (int, error)

type RoConn

type RoConn struct {
	Reader io.Reader
}

func (*RoConn) Close

func (conn *RoConn) Close() error

func (*RoConn) LocalAddr

func (conn *RoConn) LocalAddr() net.Addr

func (*RoConn) Read

func (conn *RoConn) Read(p []byte) (int, error)

func (*RoConn) RemoteAddr

func (conn *RoConn) RemoteAddr() net.Addr

func (*RoConn) SetDeadline

func (conn *RoConn) SetDeadline(time.Time) error

func (*RoConn) SetReadDeadline

func (conn *RoConn) SetReadDeadline(time.Time) error

func (*RoConn) SetWriteDeadline

func (conn *RoConn) SetWriteDeadline(time.Time) error

func (*RoConn) Write

func (conn *RoConn) Write([]byte) (int, error)

type RwConn

type RwConn struct {
	Reader  io.Reader
	Writer  io.Writer
	Rawconn net.Conn
}

func (*RwConn) Close

func (conn *RwConn) Close() error

func (*RwConn) LocalAddr

func (conn *RwConn) LocalAddr() net.Addr

func (*RwConn) Read

func (conn *RwConn) Read(p []byte) (int, error)

func (*RwConn) RemoteAddr

func (conn *RwConn) RemoteAddr() net.Addr

func (*RwConn) SetDeadline

func (conn *RwConn) SetDeadline(t time.Time) error

func (*RwConn) SetReadDeadline

func (conn *RwConn) SetReadDeadline(t time.Time) error

func (*RwConn) SetWriteDeadline

func (conn *RwConn) SetWriteDeadline(t time.Time) error

func (*RwConn) Write

func (conn *RwConn) Write(p []byte) (int, error)

type SignalContext

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

func (*SignalContext) Close

func (ctx *SignalContext) Close()

func (*SignalContext) Signal

func (ctx *SignalContext) Signal(key interface{}, val interface{}) error

func (*SignalContext) Slot

func (ctx *SignalContext) Slot(key interface{}) ContextSlot

type SignalContextSlot

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

func (*SignalContextSlot) Close

func (slt *SignalContextSlot) Close()

func (*SignalContextSlot) Wait

func (slt *SignalContextSlot) Wait() <-chan interface{}

type SingleConnListener

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

func ConnGetSocket

func ConnGetSocket(c net.Conn) (l *SingleConnListener)

func (*SingleConnListener) Accept

func (l *SingleConnListener) Accept() (net.Conn, error)

func (*SingleConnListener) Addr

func (l *SingleConnListener) Addr() net.Addr

func (*SingleConnListener) Close

func (l *SingleConnListener) Close() error

type StoreContext

type StoreContext struct {
	sync.Map
}

func (*StoreContext) Load

func (ctx *StoreContext) Load(k interface{}) (interface{}, bool)

func (*StoreContext) NilLoad

func (ctx *StoreContext) NilLoad(k interface{}) interface{}

func (*StoreContext) Store

func (ctx *StoreContext) Store(k interface{}, v interface{})

type TextStreamLogger

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

func NewTextStreamLogger

func NewTextStreamLogger() (broker *TextStreamLogger)

func (*TextStreamLogger) ServeHTTP

func (broker *TextStreamLogger) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*TextStreamLogger) Write

func (b *TextStreamLogger) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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