noisenet

package
v0.0.0-...-178df11 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(network, laddr string, config *noise.Config) (net.Listener, error)

Listen creates a Noise Listener accepting connections on the given network address using net.Listen. The configuration config must be non-nil.

Types

type Conn

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

Conn represents a secured connection. It implements the net.Conn interface.

func Client

func Client(conn net.Conn, config *noise.Config) *Conn

Client returns a new Noise client side connection using conn as the underlying transport. The config cannot be nil: users must set either ServerName or InsecureSkipVerify in the config.

func Dial

func Dial(network, addr string, localAddr string, config *noise.Config) (*Conn, error)

Dial connects to the given network address using net.Dial and then initiates a Noise handshake, returning the resulting Noise connection.

func DialWithDialer

func DialWithDialer(dialer *net.Dialer, network, addr, localAddr string, config *noise.Config) (*Conn, error)

DialWithDialer connects to the given network address using dialer.Dial and then initiates a Noise handshake, returning the resulting Noise connection. Any timeout or deadline given in the dialer apply to connection and Noise handshake as a whole.

func Server

func Server(conn net.Conn, config *noise.Config) *Conn

Server returns a new Noise server side connection using net.Conn as the underlying transport. The configuration config must be non-nil and must include at least one certificate or else set GetCertificate.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) Handshake

func (c *Conn) Handshake() (err error)

Handshake runs the client or server handshake protocol if it has not yet been run. Most uses of this package need not call Handshake explicitly: the first Read or Write will call it automatically.

func (*Conn) IsRemoteAuthenticated

func (c *Conn) IsRemoteAuthenticated() bool

IsRemoteAuthenticated can be used to check if the remote peer has been properly authenticated. It serves no real purpose for the moment as the handshake will not go through if a peer is not properly authenticated in patterns where the peer needs to be authenticated.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*Conn) Read

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

Read can be made to time out and return a net.Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*Conn) SetDeadline

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

SetDeadline sets the read and write deadlines associated with the connection. A zero value for t means Read and Write will not time out. After a Write has timed out, the Noise state is corrupt and all future writes will return the same error.

func (*Conn) SetReadDeadline

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

SetReadDeadline sets the read deadline on the underlying connection. A zero value for t means Read will not time out.

func (*Conn) SetWriteDeadline

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

SetWriteDeadline sets the write deadline on the underlying connection. A zero value for t means Write will not time out. After a Write has timed out, the Noise state is corrupt and all future writes will return the same error.

func (*Conn) Write

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

Write writes data to the connection.

type Listener

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

A Listener implements a network Listener (net.Listener) for Noise connections.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept waits for and returns the next incoming Noise connection. The returned connection is of type *Conn.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address.

func (*Listener) Close

func (l *Listener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

Jump to

Keyboard shortcuts

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