net

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var DefaultResolver = net.DefaultResolver

DefaultResolver is an alias of net.DefaultResolver.

Functions

func IsLocal

func IsLocal(host string) bool

IsLocal returns if the host is the localhost address.

func JoinHostPort added in v1.0.2

func JoinHostPort(host string, port uint16) string

JoinHostPort joins the host/IP address and the port number,

func LoadLocalIP added in v1.0.0

func LoadLocalIP() string

LoadLocalIP returns local ip address

func Parse

func Parse(addr string) (host string, port uint16, isLocal, isIPv4, isIPv6 bool, err error)

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

func ScanPorts(ctx context.Context, start, end uint16, host string) (ports []uint16, err error)

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

func SplitHostPort(hostport string) (host string, port uint16, err error)

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 Conn

type Conn = net.Conn

Conn is an alias of net.Conn.

func DialContext added in v1.0.3

func DialContext(ctx context.Context, network, addr string) (conn Conn, err error)

Dial is a wrapper function of the net.Dial function.

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 WithCache added in v1.0.3

func WithCache(c cache.Cache) DialerOption

WithCache 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.0.3

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 WithErrGroup added in v1.0.3

func WithErrGroup(eg errgroup.Group) DialerOption

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 Listener

type Listener = net.Listener

Listener is an alias of net.Listener.

type NetworkType added in v1.0.3

type NetworkType uint
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

func (NetworkType) String added in v1.0.3

func (n NetworkType) String() string

type Resolver

type Resolver = net.Resolver

Resolver is an alias of net.Resolver.

Directories

Path Synopsis
Package control provides network socket option Package control provides network socket option
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 Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc
Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc Package grpc provides generic functionality for grpc
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
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
interceptor/server/trace
Package trace provides gRPC interceptors for traces
Package trace provides gRPC interceptors for traces
keepalive
Package keepalive provides grpc keepalive configuration
Package keepalive provides grpc keepalive configuration
metric
Package metric provides metrics functions for grpc Package metric provides metrics functions for grpc Package metric provides metrics functions for grpc Package metric provides metrics functions for grpc
Package metric provides metrics functions for grpc Package metric provides metrics functions for grpc Package metric provides metrics functions for grpc Package metric provides metrics functions for grpc
pool
Package pool provides grpc connection pool client Package pool provides grpc connection pool client
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 routing provides implementation of Go API for routing http Handler wrapped by rest.Func Package middleware provides rest.Func Middleware
Package middleware provides rest.Func Middleware Package routing provides implementation of Go API for routing http Handler wrapped by rest.Func 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 Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
Package transport provides http transport roundtrip option Package transport provides http transport roundtrip option Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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