network

package
v0.0.0-...-fdfa60e Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccessControlDialTargetHostNotAllowed = errors.New(
		"unable to dial to the specified remote host due to restriction")
)

Errors

Functions

This section is empty.

Types

type AllowedHost

type AllowedHost interface {
	Allowed(host string) bool
}

AllowedHost returns whether or not give host is allowed

type AllowedHosts

type AllowedHosts map[string]struct{}

AllowedHosts contains a map of allowed remote hosts

func (AllowedHosts) Allowed

func (a AllowedHosts) Allowed(host string) bool

Allowed returns whether or not given host is allowed

type Dial

type Dial func(
	network string, address string, timeout time.Duration) (net.Conn, error)

Dial dial to remote machine

func AccessControlDial

func AccessControlDial(allowed AllowedHost, dial Dial) Dial

AccessControlDial creates an access controlled Dial

func BuildSocks5Dial

func BuildSocks5Dial(
	socks5Address string, userName string, password string) (Dial, error)

BuildSocks5Dial builds a Socks5 dialer

func TCPDial

func TCPDial() Dial

TCPDial build a TCP dialer

type ReadTimeoutConn

type ReadTimeoutConn struct {
	net.Conn
	// contains filtered or unexported fields
}

ReadTimeoutConn is a reader that will enforce a timeout rules

func NewReadTimeoutConn

func NewReadTimeoutConn(c net.Conn, timeout time.Duration) ReadTimeoutConn

NewReadTimeoutConn creates a ReadTimeoutConn

func (ReadTimeoutConn) Read

func (c ReadTimeoutConn) Read(b []byte) (int, error)

Read writes data

func (*ReadTimeoutConn) SetReadDeadline

func (c *ReadTimeoutConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets read deadline

func (*ReadTimeoutConn) SetReadTimeout

func (c *ReadTimeoutConn) SetReadTimeout(t time.Duration)

SetReadTimeout sets write timeout

type TimeoutConn

type TimeoutConn struct {
	net.Conn
	// contains filtered or unexported fields
}

TimeoutConn read write

func NewTimeoutConn

func NewTimeoutConn(
	c net.Conn,
	rTimeout time.Duration,
	wTimeout time.Duration,
) TimeoutConn

NewTimeoutConn creates a new TimeoutConn

func (*TimeoutConn) Read

func (c *TimeoutConn) Read(b []byte) (int, error)

Read reads data

func (*TimeoutConn) SetDeadline

func (c *TimeoutConn) SetDeadline(t time.Time) error

SetDeadline sets read and write deadline

func (*TimeoutConn) SetReadDeadline

func (c *TimeoutConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the next read deadline

func (*TimeoutConn) SetReadTimeout

func (c *TimeoutConn) SetReadTimeout(t time.Duration)

SetReadTimeout sets read timeout

func (*TimeoutConn) SetWriteDeadline

func (c *TimeoutConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the next read deadline

func (*TimeoutConn) SetWriteTimeout

func (c *TimeoutConn) SetWriteTimeout(t time.Duration)

SetWriteTimeout sets write timeout

func (*TimeoutConn) Write

func (c *TimeoutConn) Write(b []byte) (int, error)

Write writes data

type WriteTimeoutConn

type WriteTimeoutConn struct {
	net.Conn
	// contains filtered or unexported fields
}

WriteTimeoutConn is a writer that will enforce a timeout rules onto a net.Conn

func NewWriteTimeoutConn

func NewWriteTimeoutConn(c net.Conn, timeout time.Duration) WriteTimeoutConn

NewWriteTimeoutConn creates a WriteTimeoutConnWriter

func (*WriteTimeoutConn) SetWriteDeadline

func (c *WriteTimeoutConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets write deadline

func (*WriteTimeoutConn) SetWriteTimeout

func (c *WriteTimeoutConn) SetWriteTimeout(t time.Duration)

SetWriteTimeout sets write timeout

func (WriteTimeoutConn) Write

func (c WriteTimeoutConn) Write(b []byte) (int, error)

Write writes data

Jump to

Keyboard shortcuts

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