util

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DiscoveryDirectProtocol = "xtcp"

Variables

View Source
var (
	XConnVersion   = "2"
	YukinetVersion = "Unknown"
	BuildDate      = ""
)
View Source
var BiCopyInflight = atomic.Int64{}

Functions

func ByteCountIEC

func ByteCountIEC(b uint64) string

func ExtractConnRemoteURL

func ExtractConnRemoteURL(Conn net.Conn) *url.URL

func GenerateDirectAccessAddresses

func GenerateDirectAccessAddresses(protocol string, addresses []string, port string, queryMap url.Values) ([]url.URL, error)

func NewHookedListener

func NewHookedListener(raw net.Listener, hook ListenerHook) net.Listener

func Relay

func Relay(RuntimeContext context.Context, peerA io.ReadWriteCloser, peerB io.ReadWriteCloser) error

func ResolveIPForInterface

func ResolveIPForInterface(devName string) ([]string, error)

`devName` can be a list of interface names separated by `,`.

Types

type DefaultLogger

type DefaultLogger struct{}

func (*DefaultLogger) Errorf

func (*DefaultLogger) Errorf(format string, args ...interface{})

func (*DefaultLogger) Printf

func (*DefaultLogger) Printf(format string, args ...interface{})

type HookedListener

type HookedListener struct {
	net.Listener
	// contains filtered or unexported fields
}

HookedListener is a listener with a customized hook function.

func (*HookedListener) Accept

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

func (*HookedListener) Addr

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

type InmemoryListener

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

InmemoryListener implements a listener for testing purpose.

func NewInMemoryListener

func NewInMemoryListener() *InmemoryListener

NewInMemoryListener creates an inmemory listener.

func (*InmemoryListener) Accept

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

Accept returns a connection just like net.Listener.

func (*InmemoryListener) Addr

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

Addr returns the address of the listener.

func (*InmemoryListener) Close

func (l *InmemoryListener) Close() error

Close closes the listener. Will immeidately return nil if the listener is already closed.

func (*InmemoryListener) Dial

func (l *InmemoryListener) Dial() (net.Conn, error)

Dial creates a connection to the InMemoryListener directly.

func (*InmemoryListener) IsClosed

func (l *InmemoryListener) IsClosed() bool

IsClosed returns if the listener is closed.

type ListenerHook

type ListenerHook func(net.Conn, error) (bool, net.Conn, error)

ListenerHook specifies a callback that is invoked after inner listener returns a result from Accept(). If `skip` is true, returned connection will be closed (if not error) and will re-invoke the Accept for the next result.

type Logger

type Logger interface {
	Printf(string, ...interface{})
	Errorf(string, ...interface{})
}

Logger is a generic logging interface.

type LoggerTracker

type LoggerTracker struct{ Logger }

func (*LoggerTracker) Close

func (l *LoggerTracker) Close() error

type NopLogger

type NopLogger struct{}

NopLogger drops all loggings.

func (*NopLogger) Errorf

func (*NopLogger) Errorf(string, ...interface{})

func (*NopLogger) Printf

func (*NopLogger) Printf(string, ...interface{})

type NopTracer

type NopTracer struct{}

func (*NopTracer) Close

func (*NopTracer) Close() error

func (*NopTracer) Errorf

func (*NopTracer) Errorf(string, ...interface{})

func (*NopTracer) Printf

func (*NopTracer) Printf(string, ...interface{})

type Timer

type Timer struct {
	*time.Timer
	// contains filtered or unexported fields
}

Timer roughly copies the interface of the Linux kernel's struct timer_list.

func NewTimer

func NewTimer(whenExpired func()) *Timer

func (*Timer) Del

func (timer *Timer) Del()

func (*Timer) DelSync

func (timer *Timer) DelSync()

func (*Timer) IsPending

func (timer *Timer) IsPending() bool

func (*Timer) Mod

func (timer *Timer) Mod(d time.Duration)

type TraceWrapper added in v0.2.15

type TraceWrapper struct {
	Trace trace.Trace
	// contains filtered or unexported fields
}

func (*TraceWrapper) Close added in v0.2.15

func (t *TraceWrapper) Close() error

func (*TraceWrapper) Errorf added in v0.2.15

func (t *TraceWrapper) Errorf(format string, args ...interface{})

func (*TraceWrapper) Printf added in v0.2.15

func (t *TraceWrapper) Printf(format string, args ...interface{})

type Tracer

type Tracer interface {
	Logger
	io.Closer
}

Tracer is a generic trace interface, it will close the trace if Close() is called.

type TracerFunc

type TracerFunc func(Conn net.Conn, Family string, Instance string) Tracer

type URLAddr

type URLAddr struct {
	URL *url.URL
}

func (*URLAddr) Network

func (u *URLAddr) Network() string

func (*URLAddr) String

func (u *URLAddr) String() string

Jump to

Keyboard shortcuts

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