Documentation ¶
Overview ¶
Package net provides net functionality for vald's network connection
Package net provides net functionality for vald's network connection ¶
Package tcp provides tcp option
Index ¶
- Variables
- func IsLocal(host string) bool
- func JoinHostPort(host string, port uint16) string
- func LoadLocalIP() string
- func Parse(addr string) (host string, port uint16, isLocal, isIPv4, isIPv6 bool, err error)
- func ScanPorts(ctx context.Context, start, end uint16, host string) (ports []uint16, err error)
- func SplitHostPort(hostport string) (host string, port uint16, err error)
- type Conn
- type Dialer
- type DialerOption
- func WithDNSCache(c cacher.Cache[*dialerCache]) DialerOption
- func WithDNSCacheExpiration(dur string) DialerOption
- func WithDNSRefreshDuration(dur string) DialerOption
- func WithDialerFallbackDelay(dur string) DialerOption
- func WithDialerKeepalive(dur string) DialerOption
- func WithDialerTimeout(dur string) DialerOption
- func WithDisableDNSCache() DialerOption
- func WithDisableDialerDualStack() DialerOption
- func WithEnableDNSCache() DialerOption
- func WithEnableDialerDualStack() DialerOption
- func WithSocketFlag(flg control.SocketFlag) DialerOption
- func WithTLS(cfg *tls.Config) DialerOption
- type ListenConfig
- type Listener
- type NetworkType
- type Resolver
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultResolver is an alias of net.DefaultResolver. DefaultResolver = net.DefaultResolver // Listen is an alias of net.Listen. Listen = net.Listen // IPv4 is an alias of net.IPv4. IPv4 = net.IPv4 )
Functions ¶
func JoinHostPort ¶ added in v1.0.2
JoinHostPort joins the host/IP address and the port number,.
func Parse ¶
Parse parses the hostname, IPv4 or IPv6 address and return the hostname/IP, port number, whether the address is local IP and IPv4 or IPv6, and any parsing error occurred. The address should contains the port number, otherwise an error will return.
func ScanPorts ¶
ScanPorts scans the given range of port numbers from the host (inclusively), and return the list of ports that can be connected through TCP, or any error occurred.
func SplitHostPort ¶
SplitHostPort splits the address, and return the host/IP address and the port number, and any error occurred. If it is the loopback address, it will return the loopback address and corresponding port number. IPv6 loopback address is not supported yet. For more information, please read https://github.com/vdaas/vald/projects/3#card-43504189
Types ¶
type Dialer ¶
type Dialer interface { GetDialer() func(ctx context.Context, network, addr string) (Conn, error) StartDialerCache(ctx context.Context) DialContext(ctx context.Context, network, address string) (Conn, error) }
Dialer is an interface to get the dialer instance to connect to an address.
func NewDialer ¶ added in v1.0.3
func NewDialer(opts ...DialerOption) (der Dialer, err error)
NewDialer initialize and return the dialer instance.
type DialerOption ¶ added in v1.0.3
type DialerOption func(*dialer)
DialerOption represent the functional option for dialer.
func WithDNSCache ¶ added in v1.6.0
func WithDNSCache(c cacher.Cache[*dialerCache]) DialerOption
WithDNSCache returns the functional option to set the cache.
func WithDNSCacheExpiration ¶ added in v1.0.3
func WithDNSCacheExpiration(dur string) DialerOption
WithDNSCacheExpiration returns the functional option to set the DNSCacheExpiration.
func WithDNSRefreshDuration ¶ added in v1.0.3
func WithDNSRefreshDuration(dur string) DialerOption
WithDNSRefreshDuration returns the functional option to set the DNSRefreshDuration.
func WithDialerFallbackDelay ¶ added in v1.0.3
func WithDialerFallbackDelay(dur string) DialerOption
WithDialerFallbackDelay returns the functional option to set the DialerFallbackDelay.
func WithDialerKeepalive ¶ added in v1.3.1
func WithDialerKeepalive(dur string) DialerOption
WithDialerKeepalive returns the functional option to set the DialerKeepalive.
func WithDialerTimeout ¶ added in v1.0.3
func WithDialerTimeout(dur string) DialerOption
WithDialerTimeout returns the functional option to set the DialerTimeout.
func WithDisableDNSCache ¶ added in v1.0.3
func WithDisableDNSCache() DialerOption
WithDisableDNSCache returns the functional option to disable DNSCache.
func WithDisableDialerDualStack ¶ added in v1.0.3
func WithDisableDialerDualStack() DialerOption
WithDisableDialerDualStack returns the functional option to disable DialerDualStack.
func WithEnableDNSCache ¶ added in v1.0.3
func WithEnableDNSCache() DialerOption
WithEnableDNSCache returns the functional option to enable DNSCache.
func WithEnableDialerDualStack ¶ added in v1.0.3
func WithEnableDialerDualStack() DialerOption
WithEnableDialerDualStack returns the functional option to enable DialerDualStack.
func WithSocketFlag ¶ added in v1.0.3
func WithSocketFlag(flg control.SocketFlag) DialerOption
WithSocketFlag returns the functional option to set the socket options.
func WithTLS ¶ added in v1.0.3
func WithTLS(cfg *tls.Config) DialerOption
WithTLS returns the functional option to set the DialerTLS.
type ListenConfig ¶
type ListenConfig = net.ListenConfig
ListenConfig is an alias of net.ListenConfig.
type NetworkType ¶ added in v1.0.3
type NetworkType uint
NetworkType represents a network type such as TCP, TCP6, etc.
const ( Unknown NetworkType = iota UNIX UNIXGRAM UNIXPACKET ICMP ICMP6 IGMP TCP TCP4 TCP6 UDP UDP4 UDP6 )
func NetworkTypeFromString ¶ added in v1.0.3
func NetworkTypeFromString(str string) NetworkType
NetworkTypeFromString returns the corresponding network type from string.
func (NetworkType) String ¶ added in v1.0.3
func (n NetworkType) String() string
String returns the string of the network type.
Directories ¶
Path | Synopsis |
---|---|
Package control provides network socket option
|
Package control provides network socket option |
Package grpc provides generic functionality for grpc
|
Package grpc provides generic functionality for grpc |
admin
Package admin provides grpc admin metrics registration API for providing grpc metrics endpoints
|
Package admin provides grpc admin metrics registration API for providing grpc metrics endpoints |
codes
Package codes provides status codes of grpc
|
Package codes provides status codes of grpc |
credentials
Package credentials provides generic functionality for grpc credentials setting
|
Package credentials provides generic functionality for grpc credentials setting |
errdetails
Package errdetails provides error detail for gRPC status
|
Package errdetails provides error detail for gRPC status |
health
Package health provides generic functionality for grpc health checks.
|
Package health provides generic functionality for grpc health checks. |
interceptor/client/metric
Package metric provides gRPC client interceptors for client metric
|
Package metric provides gRPC client interceptors for client metric |
interceptor/server/logging
Package logging provides gRPC interceptors for access logging
|
Package logging provides gRPC interceptors for access logging |
interceptor/server/recover
Package recover provides gRPC interceptors for recovery
|
Package recover provides gRPC interceptors for recovery |
keepalive
Package keepalive provides grpc keepalive configuration
|
Package keepalive provides grpc keepalive configuration |
pool
Package pool provides gRPC connection pool client
|
Package pool provides gRPC connection pool client |
proto
Package proto provides proto file logic
|
Package proto provides proto file logic |
reflection
Package reflection provides grpc reflection for providing grpc server proto specs
|
Package reflection provides grpc reflection for providing grpc server proto specs |
status
Package status provides statuses and errors returned by grpc handler functions
|
Package status provides statuses and errors returned by grpc handler functions |
types
Package types provides alias of protobuf library types
|
Package types provides alias of protobuf library types |
http
|
|
dump
Package dump provides http request/response dump logic
|
Package dump provides http request/response dump logic |
metrics
Package metrics provides pprof profiler handler
|
Package metrics provides pprof profiler handler |
middleware
Package middleware provides rest.Func Middleware
|
Package middleware provides rest.Func Middleware |
rest
Package rest provides REST API common logic & variable
|
Package rest provides REST API common logic & variable |
transport
Package transport provides http transport roundtrip option
|
Package transport provides http transport roundtrip option |