udwNet

package
v0.0.0-...-f254aa5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const ErrMsgSocketCloseError = "use of closed network connection"

Variables

View Source
var FakeAddr = fakeAddr{}

Functions

func BufioConn

func BufioConn() net.Conn

func CloseRead

func CloseRead(conn net.Conn) error

func CloseWrite

func CloseWrite(conn net.Conn) error

func ConnTwoWayCopy

func ConnTwoWayCopy(req ConnTwoWayCopyRequest)

func ErrorMsgIsNetworkIsUnreachable

func ErrorMsgIsNetworkIsUnreachable(s string) bool

func GetIpAndPortFromNetAddr

func GetIpAndPortFromNetAddr(addri net.Addr) (ip net.IP, port uint16, errMsg string)

func GetIpStringFromAddrStringIgnoreNotFound

func GetIpStringFromAddrStringIgnoreNotFound(addr string) string

func GetIpStringFromtNetAddrIgnoreNotExist

func GetIpStringFromtNetAddrIgnoreNotExist(addri net.Addr) (s string)

func GetIpStringNoPortOrInput

func GetIpStringNoPortOrInput(addr string) string

func GetPossiableConnectAddrDebugString

func GetPossiableConnectAddrDebugString(listenAddr string) string

func GetPossiableConnectAddrStringList

func GetPossiableConnectAddrStringList(listenAddr string) (outList []string)

func GetProtocolNotSupportPortError

func GetProtocolNotSupportPortError() error

func GetSocketCloseError

func GetSocketCloseError() error

func IPMaskGetOnes

func IPMaskGetOnes(mask net.IPMask) int

func IPNetGetGenMaskString

func IPNetGetGenMaskString(ipNet *net.IPNet) (s string)

func IPNetGetMaxIp

func IPNetGetMaxIp(ipnet *net.IPNet) net.IP

func IPNetGetMinIp

func IPNetGetMinIp(ipnet *net.IPNet) net.IP

func IPNetGetOnes

func IPNetGetOnes(ipnet net.IPNet) int

func IPNetIsZero

func IPNetIsZero(ipnet net.IPNet) bool

func IpClone

func IpClone(a net.IP) net.IP

func IpGetBit

func IpGetBit(ip net.IP, index uint8) uint8

func IpLess

func IpLess(a net.IP, b net.IP) bool

func IpSetBit

func IpSetBit(ip net.IP, index uint8, value uint8) net.IP

func IpSetBit0

func IpSetBit0(ip net.IP, index uint8) net.IP

func IpSetBit1

func IpSetBit1(ip net.IP, index uint8) net.IP

func Ipv4AddAndCopyWithBuffer

func Ipv4AddAndCopyWithBuffer(ip net.IP, toAdd uint32, bufW *udwBytes.BufWriter) net.IP

func Ipv4GetBit

func Ipv4GetBit(ip net.IP, index uint8) uint8

func Ipv4ToUint32OrZero

func Ipv4ToUint32OrZero(a net.IP) uint32

func IsBadFileDescripter

func IsBadFileDescripter(err error) bool

func IsConnectionRefused

func IsConnectionRefused(err error) bool

func IsConnectionRefusedString

func IsConnectionRefusedString(errMsg string) bool

func IsErrorMsgNetwork

func IsErrorMsgNetwork(errorMsg string) bool

func IsErrorMsgSocketClose

func IsErrorMsgSocketClose(errMsg string) bool

func IsInLinkLocalNetwork

func IsInLinkLocalNetwork(ip net.IP) bool

func IsInLoopBackNetwork

func IsInLoopBackNetwork(ip net.IP) bool

func IsInterruptedSystemCall

func IsInterruptedSystemCall(err error) bool

func IsIpv6Only

func IsIpv6Only() bool

func IsLocalNetwork

func IsLocalNetwork(ip net.IP) bool

func IsMessageTooLong

func IsMessageTooLong(err error) bool

func IsNetworkIsUnreachable

func IsNetworkIsUnreachable(err error) bool

func IsNoBufferSpaceAvailable

func IsNoBufferSpaceAvailable(err error) bool

func IsNoRouteToHost

func IsNoRouteToHost(err error) bool

func IsNoRouteToHostString

func IsNoRouteToHostString(errMsg string) bool

func IsPrivateNetwork

func IsPrivateNetwork(ip net.IP) bool

func IsResourceBusy

func IsResourceBusy(err error) bool

func IsSocketCloseError

func IsSocketCloseError(err error) bool

func IsStringValidIp

func IsStringValidIp(sIp string) bool

func IsTimeoutError

func IsTimeoutError(err error) bool

func IsTimeoutErrorString

func IsTimeoutErrorString(errMsg string) bool

func IsUseOfClosedNetworkConnection

func IsUseOfClosedNetworkConnection(err error) bool

func IsVpnConnectedIgnorePanic

func IsVpnConnectedIgnorePanic() bool

func JoinHostPortInt

func JoinHostPortInt(host string, port int) string

func JoinHostPortNoAlloc

func JoinHostPortNoAlloc(buf []byte, ip string, port int) []byte

func LessDelayDial

func LessDelayDial(network string, address string) (conn net.Conn, err error)

func LessDelayTcpConn

func LessDelayTcpConn(conn *net.TCPConn) (connOut net.Conn, err error)

func ListenerConnWrapper

func ListenerConnWrapper(l net.Listener, connWrapper ConnWrapper) net.Listener

func MustGetCurrentIpWithPortList

func MustGetCurrentIpWithPortList(port uint16) (sList []string)

func MustGetDefaultGatewayIP

func MustGetDefaultGatewayIP() net.IP

func MustGetDefaultRouteRuleInterfaceFirstIpAddr

func MustGetDefaultRouteRuleInterfaceFirstIpAddr() net.IP

func MustGetHostFromAddr

func MustGetHostFromAddr(addr string) string

func MustGetIpFromNetAddr

func MustGetIpFromNetAddr(addri net.Addr) (ip net.IP)

func MustGetIpList

func MustGetIpList() (ipList []net.IP)

func MustGetIpListToString

func MustGetIpListToString() string

func MustGetLocalAddrFromAddr

func MustGetLocalAddrFromAddr(addr net.Addr) string

func MustGetLocalAddrFromListener

func MustGetLocalAddrFromListener(listener net.Listener) string

func MustGetPortFromNetAddr

func MustGetPortFromNetAddr(addri net.Addr) int

func MustGetPortFromNetAddrIgnoreNotFound

func MustGetPortFromNetAddrIgnoreNotFound(addri net.Addr) int

func MustGetServerAddrString

func MustGetServerAddrString(s Server) string

func MustGetServerLocalAddrString

func MustGetServerLocalAddrString(s Server) string

func MustIpv4Add

func MustIpv4Add(ip net.IP, toAdd uint32) net.IP

func MustIpv4ToUint32

func MustIpv4ToUint32(a net.IP) uint32

func MustIpv4ToWindowsDword

func MustIpv4ToWindowsDword(a net.IP) uint32

func MustIsVpnConnected

func MustIsVpnConnected() bool

func MustLessDelayListen

func MustLessDelayListen(network string, address string) net.Listener

func MustListen

func MustListen(network string, address string) net.Listener

func MustLookupDomainInAddrString

func MustLookupDomainInAddrString(addr string) string

func MustParseCIDR

func MustParseCIDR(s string) *net.IPNet

func MustParseIPNet

func MustParseIPNet(s string) *net.IPNet

func MustParseIpStringToInt64

func MustParseIpStringToInt64(ipStr string) int64

func MustRouteDeleteWithString

func MustRouteDeleteWithString(IpNetString string)

func MustRouteSetWithString

func MustRouteSetWithString(IpNetString string, gatewayString string)

func MustServerStart

func MustServerStart(s Server)

func MustSplitIpPort

func MustSplitIpPort(addr string) (ip net.IP, port uint16)

func MustSplitIpPortForListener

func MustSplitIpPortForListener(addr string) (ip net.IP, port uint16)

func MustTcpRandomListen

func MustTcpRandomListen() net.Listener

func NetErrorMsgSimple

func NetErrorMsgSimple(errorMsg string) string

func NewDebugConn

func NewDebugConn(conn net.Conn, name string) net.Conn

func NewDebugConnNoData

func NewDebugConnNoData(conn net.Conn) net.Conn

func NewDebugConnNoDataWithName

func NewDebugConnNoDataWithName(conn net.Conn, name string) net.Conn

func NewFixedAddressDialer

func NewFixedAddressDialer(parent Dialer, network string, address string) func() (net.Conn, error)

func NewFixedDialerV2

func NewFixedDialerV2(parent Dialer, network string, address string) func(network, address string) (net.Conn, error)

func NewRwcOverConn

func NewRwcOverConn(rwc io.ReadWriteCloser, conn net.Conn) net.Conn

func NewSizeDebugConn

func NewSizeDebugConn(conn net.Conn, name string) net.Conn

func NewStringDebugConn

func NewStringDebugConn(conn net.Conn, name string) net.Conn

func NewTimeoutDialer

func NewTimeoutDialer(timeout time.Duration) func(network, addr string) (net.Conn, error)

func ParseGenmask

func ParseGenmask(genMask string) (mask net.IPMask, err error)

func ParseIpToBuf

func ParseIpToBuf(s string, buf []byte) (ip net.IP)

func ParseIpv4ToUint32

func ParseIpv4ToUint32(s string) (b uint32, ok bool)

func PortFromAddrString

func PortFromAddrString(addr string) (int, error)

func PortFromNetAddr

func PortFromNetAddr(addr net.Addr) (int, error)

func RouteTableDebugPrint

func RouteTableDebugPrint()

func RouteTableDebugPrintToWriter

func RouteTableDebugPrintToWriter(w io.Writer)

func RunTCPServerListenAddr

func RunTCPServerListenAddr(listenAddr string, handle ConnHandlerFunc) (closer func() error)

func RunTCPServerV2

func RunTCPServerV2(Listener net.Listener, handle ConnHandlerFunc) (closer func() error)

func RwcConn

func RwcConn(rwc io.ReadWriteCloser) net.Conn

func RwcConnWithSetDeadline

func RwcConnWithSetDeadline(rwc io.ReadWriteCloser, setDeadline func(t time.Time) error) net.Conn

func SetMockedListen

func SetMockedListen(f func(network, address string) (net.Listener, error))

func SplitIpPort

func SplitIpPort(addr string) (ip net.IP, port uint16, err error)

func TcpNewListener

func TcpNewListener(listenAddr string, processor func(conn net.Conn)) (closer func())

func TcpNewListenerFromExistListener

func TcpNewListenerFromExistListener(listener net.Listener, processor func(conn net.Conn)) (closer func())

func TimeoutConn

func TimeoutConn(conn net.Conn, timeout time.Duration) net.Conn

func TproxyListenerPortWorkAround

func TproxyListenerPortWorkAround(addr string) []string

func TransferIpv4StringToSupportIpv6Only

func TransferIpv4StringToSupportIpv6Only(ipS string) string

func Uint32ToIpv4

func Uint32ToIpv4(u uint32) net.IP

Types

type ConnHandler

type ConnHandler interface {
	ConnHandle(conn net.Conn)
}

type ConnHandlerFunc

type ConnHandlerFunc func(conn net.Conn)

func (ConnHandlerFunc) ConnHandle

func (f ConnHandlerFunc) ConnHandle(conn net.Conn)

type ConnServer

type ConnServer struct {
	Listener net.Listener
	Handler  ConnHandler
	Closer   io.Closer
}

func NewTCPServer

func NewTCPServer(listenAddr string, hander ConnHandler, closer io.Closer) (s *ConnServer, err error)

func (*ConnServer) Addr

func (server *ConnServer) Addr() (net.Addr, error)

func (*ConnServer) Close

func (server *ConnServer) Close() (err error)

func (*ConnServer) Start

func (server *ConnServer) Start() (err error)

type ConnTwoWayCopyRequest

type ConnTwoWayCopyRequest struct {
	FromHopConn  net.Conn
	NextHopConn  net.Conn
	AddTimeout   time.Duration
	IsPrintError bool
}

type ConnWrapper

type ConnWrapper func(conn net.Conn) (net.Conn, error)

type Dialer

type Dialer func(network, address string) (net.Conn, error)

func NewDebugDialerNoData

func NewDebugDialerNoData(parent Dialer) Dialer

func NewRetractableNetDial

func NewRetractableNetDial(closer *udwClose.Closer, timeout time.Duration) Dialer

func NewSupportIpv6OnlyDialer

func NewSupportIpv6OnlyDialer(oldDialer Dialer) Dialer

func WrapDialTimeout

func WrapDialTimeout(req WrapDialTimeoutReq) Dialer

func WrapTcpDial

func WrapTcpDial(req WrapTcpDialRequest) Dialer

type DirectDialer

type DirectDialer interface {
	DirectDial() (net.Conn, error)
}

type DirectDialerFunc

type DirectDialerFunc func() (net.Conn, error)

func (DirectDialerFunc) Dial

func (f DirectDialerFunc) Dial() (net.Conn, error)

type FixedAddressDialer

type FixedAddressDialer func() (net.Conn, error)

type FuncServer

type FuncServer struct {
	StartFunc func() error
	CloseFunc func() error
	AddrFunc  func() (net.Addr, error)
	ExistAddr net.Addr
}

func (*FuncServer) Addr

func (s *FuncServer) Addr() (net.Addr, error)

func (*FuncServer) Close

func (s *FuncServer) Close() error

func (*FuncServer) Start

func (s *FuncServer) Start() error

type GetUnderlyingConner

type GetUnderlyingConner interface {
	GetUnderlyingConn() net.Conn
}

type NetDevice

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

func GetNetDeviceByIndex

func GetNetDeviceByIndex(index int) (dev *NetDevice, err error)

func GetNetDeviceByName

func GetNetDeviceByName(name string) (dev *NetDevice, err error)

func GetNetDeviceList

func GetNetDeviceList() (devlist []*NetDevice, err error)

func MustGetNetDeviceList

func MustGetNetDeviceList() []*NetDevice

func (*NetDevice) CanConnect

func (i *NetDevice) CanConnect() bool

func (*NetDevice) GetFirstIpv4IP

func (i *NetDevice) GetFirstIpv4IP() net.IP

func (*NetDevice) GetIndex

func (i *NetDevice) GetIndex() int

func (*NetDevice) GetIpList

func (i *NetDevice) GetIpList() []net.IP

func (*NetDevice) GetName

func (i *NetDevice) GetName() string

func (*NetDevice) GetNonLinkLocalIpList

func (i *NetDevice) GetNonLinkLocalIpList() []net.IP

func (*NetDevice) HasIpv4Addr

func (i *NetDevice) HasIpv4Addr() bool

func (*NetDevice) IsPointToPoint

func (i *NetDevice) IsPointToPoint() bool

func (*NetDevice) IsUp

func (i *NetDevice) IsUp() bool

func (*NetDevice) String

func (i *NetDevice) String() string

type NewDialer

type NewDialer func() (response NewDialerResponse)

type NewDialerResponse

type NewDialerResponse struct {
	Dialer Dialer
	Closer func()
}

func TcpNewDialer

func TcpNewDialer() (response NewDialerResponse)

type NewListener

type NewListener func(listenAddr string, processor func(conn net.Conn)) (Closer func())

type RouteContext

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

func NewRouteContext

func NewRouteContext() RouteContext

func (RouteContext) MustGetDefaultRouteRule

func (ctx RouteContext) MustGetDefaultRouteRule() (rule *RouteRuleV2)

func (RouteContext) MustGetRouteTable

func (ctx RouteContext) MustGetRouteTable() (ruleList []*RouteRuleV2)

func (RouteContext) MustRouteDelete

func (ctx RouteContext) MustRouteDelete(ipNet net.IPNet)

func (RouteContext) MustRouteDeleteWithString

func (ctx RouteContext) MustRouteDeleteWithString(IpNetString string)

func (RouteContext) MustRouteSet

func (ctx RouteContext) MustRouteSet(ipNet net.IPNet, gateWayIp net.IP)

func (RouteContext) MustRouteSetWithString

func (ctx RouteContext) MustRouteSetWithString(IpNetString string, gatewayString string)

type RouteRuleV2

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

func MustGetDefaultRouteRule

func MustGetDefaultRouteRule() (rule *RouteRuleV2)

func MustGetRouteTable

func MustGetRouteTable() (ruleList []*RouteRuleV2)

func (*RouteRuleV2) GetDstIpNet

func (rule *RouteRuleV2) GetDstIpNet() net.IPNet

func (*RouteRuleV2) GetGatewayIp

func (rule *RouteRuleV2) GetGatewayIp() net.IP

func (*RouteRuleV2) GetOutInterface

func (rule *RouteRuleV2) GetOutInterface() *NetDevice

func (*RouteRuleV2) IsIpv4

func (rule *RouteRuleV2) IsIpv4() bool

func (*RouteRuleV2) String

func (rule *RouteRuleV2) String() string

type RwcDialer

type RwcDialer interface {
	RwcDial(addr string) (rwc io.ReadWriteCloser, err error)
}

type RwcDialerFunc

type RwcDialerFunc func(addr string) (rwc io.ReadWriteCloser, err error)

func (RwcDialerFunc) RwcDial

func (f RwcDialerFunc) RwcDial(addr string) (rwc io.ReadWriteCloser, err error)

type RwcOverConn

type RwcOverConn struct {
	Rwc io.ReadWriteCloser
	io.Reader
	io.Writer
	io.Closer
	net.Conn
}

func (*RwcOverConn) Close

func (c *RwcOverConn) Close() (err error)

func (*RwcOverConn) GetUnderlyingConn

func (c *RwcOverConn) GetUnderlyingConn() net.Conn

func (*RwcOverConn) Read

func (c *RwcOverConn) Read(p []byte) (n int, err error)

func (*RwcOverConn) Write

func (c *RwcOverConn) Write(p []byte) (n int, err error)

type Server

type Server interface {
	Start() error

	Close() error

	Addr() (net.Addr, error)
}

type TcpListener

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

func TcpNewListenerReturnListener

func TcpNewListenerReturnListener(listenAddr string, processor func(conn net.Conn)) (tl *TcpListener)

func (*TcpListener) Close

func (tl *TcpListener) Close()

func (*TcpListener) GetListenPort

func (tl *TcpListener) GetListenPort() int

type TunImp

type TunImp struct {
	NewDialer   func() (response NewDialerResponse)
	NewListener func(listenAddr string, processor func(conn net.Conn)) (Closer func())
}

type UdpListener

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

func MustRunUdpListener

func MustRunUdpListener(listenAddr string, processor func(ctx UdpReadContext)) *UdpListener

func (*UdpListener) Close

func (l *UdpListener) Close()

func (*UdpListener) GetListenConn

func (l *UdpListener) GetListenConn() *net.UDPConn

func (*UdpListener) GetListenPort

func (l *UdpListener) GetListenPort() int

func (*UdpListener) IsClose

func (l *UdpListener) IsClose() bool

type UdpReadContext

type UdpReadContext struct {
	Conn *net.UDPConn
	Data []byte
	Addr *net.UDPAddr
}

type WrapDialTimeoutReq

type WrapDialTimeoutReq struct {
	Dial    Dialer
	Timeout time.Duration
	Closer  *udwClose.Closer
}

type WrapTcpDialRequest

type WrapTcpDialRequest struct {
	ParentDial                  Dialer
	ParentDialTimeout           time.Duration
	ParentDialAlreadyHasTimeout bool

	Closer   *udwClose.Closer
	ConnWrap func(conn net.Conn) (_conn net.Conn, err error)
}

Directories

Path Synopsis
udwDns

Jump to

Keyboard shortcuts

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