network

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 34 Imported by: 19

Documentation

Index

Constants

View Source
const (
	DefaultReadBufferSize = 1 << 7

	NetBufferDefaultSize     = 0
	NetBufferDefaultCapacity = 1 << 4

	DefaultConnectTimeout = 10 * time.Second
)

Network related const

View Source
const (
	SO_MARK        = 0x24
	SOL_IP         = 0x0
	IP_TRANSPARENT = 0x13
)
View Source
const UdpPacketMaxSize = 64 * 1024

Variables

View Source
var DefaultResolverFile string = "/etc/resolv.conf"
View Source
var (
	ProxyMap = sync.Map{}
)
View Source
var TransferTimeout = time.Second * 30 //default 30s

TransferTimeout is the total transfer time

View Source
var (
	// UseNetpollMode indicates which mode should be used for connection IO processing
	UseNetpollMode = false
)

Functions

func DelUDPProxyMap added in v0.15.0

func DelUDPProxyMap(key string)

func GetProxyMapKey added in v0.15.0

func GetProxyMapKey(raddr, laddr string) string

func NewClientConnection

func NewClientConnection(connectTimeout time.Duration, tlsMng types.TLSClientContextManager, remoteAddr net.Addr, stopChan chan struct{}) types.ClientConnection

NewClientConnection new client-side connection

func NewFilterManager added in v0.25.0

func NewFilterManager(conn api.Connection) api.FilterManager

func NewListener

func NewListener(lc *v2.Listener) types.Listener

func NewRequestInfo

func NewRequestInfo() api.RequestInfo

NewrequestInfo

func NewServerConnection

func NewServerConnection(ctx context.Context, rawc net.Conn, stopChan chan struct{}) api.Connection

NewServerConnection new server-side connection, rawc is the raw connection from go/net

func RegisterClientConnFactory added in v0.25.0

func RegisterClientConnFactory(factory ClientConnFactory)

func RegisterListenerFactory added in v0.27.0

func RegisterListenerFactory(factory ListenerFactory)

func RegisterServerConnFactory added in v0.27.0

func RegisterServerConnFactory(factory ServerConnFactory)

func SetNetpollMode added in v0.20.0

func SetNetpollMode(enable bool)

SetNetpollMode set the netpoll mode

func SetTransferTimeout

func SetTransferTimeout(time time.Duration)

func SetUDPProxyMap added in v0.15.0

func SetUDPProxyMap(key string, conn api.Connection)

func TransferServer

func TransferServer(handler types.ConnectionHandler)

TransferServer is called on new mosn start

Types

type ClientConnFactory added in v0.25.0

type ClientConnFactory func(connectTimeout time.Duration, tlsMng types.TLSClientContextManager, remoteAddr net.Addr,
	stopChan chan struct{}) types.ClientConnection

Factory function for creating client side connection.

func GetClientConnFactory added in v0.27.0

func GetClientConnFactory() ClientConnFactory

type DnsResolver added in v0.13.0

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

func NewDnsResolver added in v0.13.0

func NewDnsResolver(config *v2.DnsResolverConfig) *DnsResolver

func NewDnsResolverFromFile added in v0.13.0

func NewDnsResolverFromFile(configFile string, resolverPort string) *DnsResolver

func (*DnsResolver) DnsResolve added in v0.13.0

func (dr *DnsResolver) DnsResolve(dnsAddr string, dnsLookupFamily v2.DnsLookupFamily) *[]DnsResponse

type DnsResponse added in v0.13.0

type DnsResponse struct {
	Address string
	Ttl     time.Duration
}

type ListenerFactory added in v0.27.0

type ListenerFactory func(lc *v2.Listener) types.Listener

Factory function for creating mosn listener.

func GetListenerFactory added in v0.27.0

func GetListenerFactory() ListenerFactory

type ListenerState

type ListenerState int
const (
	ListenerInited ListenerState = iota
	ListenerRunning
	ListenerStopped
	ListenerClosed
)

listener state ListenerInited means listener is inited, a inited listener can be started or stopped ListenerRunning means listener is running, start a running listener will be ignored. ListenerStopped means listener is stopped. ListenerClosed means listener is closed, start a closed listener without restart flag will be ignored.

type RequestInfo

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

RequestInfo

func (*RequestInfo) BytesReceived

func (r *RequestInfo) BytesReceived() uint64

func (*RequestInfo) BytesSent

func (r *RequestInfo) BytesSent() uint64

func (*RequestInfo) DownstreamLocalAddress

func (r *RequestInfo) DownstreamLocalAddress() net.Addr

func (*RequestInfo) DownstreamRemoteAddress

func (r *RequestInfo) DownstreamRemoteAddress() net.Addr

func (*RequestInfo) Duration

func (r *RequestInfo) Duration() time.Duration

func (*RequestInfo) GetResponseFlag

func (r *RequestInfo) GetResponseFlag(flag api.ResponseFlag) bool

func (*RequestInfo) GetResponseFlagResult added in v0.19.0

func (r *RequestInfo) GetResponseFlagResult() string

func (*RequestInfo) IsHealthCheck

func (r *RequestInfo) IsHealthCheck() bool

func (*RequestInfo) OnUpstreamHostSelected

func (r *RequestInfo) OnUpstreamHostSelected(host api.HostInfo)

func (*RequestInfo) ProcessTimeDuration

func (r *RequestInfo) ProcessTimeDuration() time.Duration

func (*RequestInfo) Protocol

func (r *RequestInfo) Protocol() api.ProtocolName

func (*RequestInfo) RequestFinishedDuration

func (r *RequestInfo) RequestFinishedDuration() time.Duration

func (*RequestInfo) RequestReceivedDuration

func (r *RequestInfo) RequestReceivedDuration() time.Duration

func (*RequestInfo) ResponseCode

func (r *RequestInfo) ResponseCode() int

func (*RequestInfo) ResponseReceivedDuration

func (r *RequestInfo) ResponseReceivedDuration() time.Duration

func (*RequestInfo) RouteEntry

func (r *RequestInfo) RouteEntry() api.RouteRule

func (*RequestInfo) SetBytesReceived

func (r *RequestInfo) SetBytesReceived(bytesReceived uint64)

func (*RequestInfo) SetBytesSent

func (r *RequestInfo) SetBytesSent(bytesSent uint64)

func (*RequestInfo) SetDownstreamLocalAddress

func (r *RequestInfo) SetDownstreamLocalAddress(addr net.Addr)

func (*RequestInfo) SetDownstreamRemoteAddress

func (r *RequestInfo) SetDownstreamRemoteAddress(addr net.Addr)

func (*RequestInfo) SetHealthCheck

func (r *RequestInfo) SetHealthCheck(isHc bool)

func (*RequestInfo) SetProcessTimeDuration

func (r *RequestInfo) SetProcessTimeDuration(d time.Duration)

func (*RequestInfo) SetProtocol added in v0.12.0

func (r *RequestInfo) SetProtocol(p api.ProtocolName)

func (*RequestInfo) SetRequestFinishedDuration

func (r *RequestInfo) SetRequestFinishedDuration(t time.Time)

func (*RequestInfo) SetRequestReceivedDuration

func (r *RequestInfo) SetRequestReceivedDuration(t time.Time)

func (*RequestInfo) SetResponseCode

func (r *RequestInfo) SetResponseCode(code int)

func (*RequestInfo) SetResponseFlag

func (r *RequestInfo) SetResponseFlag(flag api.ResponseFlag)

func (*RequestInfo) SetResponseReceivedDuration

func (r *RequestInfo) SetResponseReceivedDuration(t time.Time)

func (*RequestInfo) SetRouteEntry

func (r *RequestInfo) SetRouteEntry(routerRule api.RouteRule)

func (*RequestInfo) SetStartTime

func (r *RequestInfo) SetStartTime()

func (*RequestInfo) SetUpstreamLocalAddress

func (r *RequestInfo) SetUpstreamLocalAddress(addr string)

func (*RequestInfo) StartTime

func (r *RequestInfo) StartTime() time.Time

func (*RequestInfo) UpstreamHost

func (r *RequestInfo) UpstreamHost() api.HostInfo

func (*RequestInfo) UpstreamLocalAddress

func (r *RequestInfo) UpstreamLocalAddress() string

type ServerConnFactory added in v0.27.0

type ServerConnFactory func(ctx context.Context, rawc net.Conn, stopChan chan struct{}) api.Connection

Factory function for creating server side connection.

func GetServerConnFactory added in v0.27.0

func GetServerConnFactory() ServerConnFactory

Jump to

Keyboard shortcuts

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