Involved Source Filesconvert.go Package manet provides Multiaddr specific versions of common
functions in stdlib's net package. This means wrappers of
standard net symbols like net.Dial and net.Listen, as well
as conversion to/from net.Addr.ip.go Package manet provides Multiaddr
(https://github.com/multiformats/go-multiaddr) specific versions of common
functions in Go's standard `net` package. This means wrappers of standard
net symbols like `net.Dial` and `net.Listen`, as well as conversion to
and from `net.Addr`.private.goregistry.goresolve.go
Package-Level Type Names (total 7)
/* sort by: | */
CodecMap holds a map of NetCodecs indexed by their Protocol ID
along with parsers for the addresses they use.
It is used to keep a list of supported network address codecs (protocols
which addresses can be converted to and from multiaddresses). FromNetAddr converts a net.Addr to Multiaddress. RegisterFromNetAddr registers a conversion from net.Addr instances to multiaddrs RegisterToNetAddr registers a conversion from multiaddrs to net.Addr instances ToNetAddr converts a Multiaddress to a standard net.Addr.
func NewCodecMap() *CodecMap
Conn is the equivalent of a net.Conn object. It is the
result of calling the Dial or Listen functions in this
package, with associated local and remote Multiaddrs. Close closes the connection.
Any blocked Read or Write operations will be unblocked and return errors.
Close may or may not block until any buffered data is sent;
for TCP connections see [*TCPConn.SetLinger]. LocalAddr returns the local network address, if known. LocalMultiaddr returns the local Multiaddr associated
with this connection Read reads data from the connection.
Read can be made to time out and return an error after a fixed
time limit; see SetDeadline and SetReadDeadline. RemoteAddr returns the remote network address, if known. RemoteMultiaddr returns the remote Multiaddr associated
with this connection SetDeadline sets the read and write deadlines associated
with the connection. It is equivalent to calling both
SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations
fail instead of blocking. The deadline applies to all future
and pending I/O, not just the immediately following call to
Read or Write. After a deadline has been exceeded, the
connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other
I/O methods will return an error that wraps os.ErrDeadlineExceeded.
This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
The error's Timeout method will return true, but note that there
are other possible errors for which the Timeout method will
return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending
the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out. SetReadDeadline sets the deadline for future Read calls
and any currently-blocked Read call.
A zero value for t means Read will not time out. SetWriteDeadline sets the deadline for future Write calls
and any currently-blocked Write call.
Even if write times out, it may return n > 0, indicating that
some of the data was successfully written.
A zero value for t means Write will not time out. Write writes data to the connection.
Write can be made to time out and return an error after a fixed
time limit; see SetDeadline and SetWriteDeadline.
*github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Conn
github.com/libp2p/go-libp2p/p2p/transport/tcpreuse/internal/sampledconn.ManetTCPConnInterface(interface)
*github.com/libp2p/go-libp2p/p2p/transport/websocket.Conn
Conn : github.com/libp2p/go-libp2p/core/network.ConnMultiaddrs
Conn : github.com/miekg/dns.Writer
Conn : github.com/pion/datachannel.ReadDeadliner
Conn : github.com/pion/datachannel.WriteDeadliner
Conn : github.com/pion/stun.Connection
Conn : github.com/pion/stun/v3.Connection
Conn : github.com/prometheus/common/expfmt.Closer
Conn : internal/bisect.Writer
Conn : io.Closer
Conn : io.ReadCloser
Conn : io.Reader
Conn : io.ReadWriteCloser
Conn : io.ReadWriter
Conn : io.WriteCloser
Conn : io.Writer
Conn : net.Conn
func Dial(remote ma.Multiaddr) (Conn, error)
func WrapNetConn(nconn net.Conn) (Conn, error)
func (*Dialer).Dial(remote ma.Multiaddr) (Conn, error)
func (*Dialer).DialContext(ctx context.Context, remote ma.Multiaddr) (Conn, error)
func Listener.Accept() (Conn, error)
func github.com/libp2p/go-libp2p/core/transport.GatedMaListener.Accept() (Conn, network.ConnManagementScope, error)
func github.com/libp2p/go-libp2p/p2p/net/reuseport.(*Transport).Dial(raddr ma.Multiaddr) (Conn, error)
func github.com/libp2p/go-libp2p/p2p/net/reuseport.(*Transport).DialContext(ctx context.Context, raddr ma.Multiaddr) (Conn, error)
func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.(*Listener).Accept() (Conn, error)
func github.com/libp2p/go-libp2p/p2p/transport/tcpreuse.(*ConnMgr).DialContext(ctx context.Context, raddr ma.Multiaddr) (Conn, error)
func github.com/libp2p/go-libp2p/p2p/transport/tcpreuse/internal/sampledconn.PeekBytes(conn Conn) (sampledconn.PeekedBytes, Conn, error)
func github.com/libp2p/go-libp2p/core/transport.Upgrader.Upgrade(ctx context.Context, t transport.Transport, maconn Conn, dir network.Direction, p peer.ID, scope network.ConnManagementScope) (transport.CapableConn, error)
func github.com/libp2p/go-libp2p/p2p/transport/tcpreuse/internal/sampledconn.PeekBytes(conn Conn) (sampledconn.PeekedBytes, Conn, error)
Dialer contains options for connecting to an address. It
is effectively the same as net.Dialer, but its LocalAddr
and RemoteAddr options are Multiaddrs, instead of net.Addrs. Dialer is just an embedded net.Dialer, with all its options. Cancel is an optional channel whose closure indicates that
the dial should be canceled. Not all types of dials support
cancellation.
Deprecated: Use DialContext instead. If Control is not nil, it is called after creating the network
connection but before actually dialing.
Network and address parameters passed to Control function are not
necessarily the ones passed to Dial. Calling Dial with TCP networks
will cause the Control function to be called with "tcp4" or "tcp6",
UDP networks become "udp4" or "udp6", IP networks become "ip4" or "ip6",
and other known networks are passed as-is.
Control is ignored if ControlContext is not nil. If ControlContext is not nil, it is called after creating the network
connection but before actually dialing.
Network and address parameters passed to ControlContext function are not
necessarily the ones passed to Dial. Calling Dial with TCP networks
will cause the ControlContext function to be called with "tcp4" or "tcp6",
UDP networks become "udp4" or "udp6", IP networks become "ip4" or "ip6",
and other known networks are passed as-is.
If ControlContext is not nil, Control is ignored. Deadline is the absolute point in time after which dials
will fail. If Timeout is set, it may fail earlier.
Zero means no deadline, or dependent on the operating system
as with the Timeout option. DualStack previously enabled RFC 6555 Fast Fallback
support, also known as "Happy Eyeballs", in which IPv4 is
tried soon if IPv6 appears to be misconfigured and
hanging.
Deprecated: Fast Fallback is enabled by default. To
disable, set FallbackDelay to a negative value. FallbackDelay specifies the length of time to wait before
spawning a RFC 6555 Fast Fallback connection. That is, this
is the amount of time to wait for IPv6 to succeed before
assuming that IPv6 is misconfigured and falling back to
IPv4.
If zero, a default delay of 300ms is used.
A negative value disables Fast Fallback support. KeepAlive specifies the interval between keep-alive
probes for an active network connection.
KeepAlive is ignored if KeepAliveConfig.Enable is true.
If zero, keep-alive probes are sent with a default value
(currently 15 seconds), if supported by the protocol and operating
system. Network protocols or operating systems that do
not support keep-alive ignore this field.
If negative, keep-alive probes are disabled. KeepAliveConfig specifies the keep-alive probe configuration
for an active network connection, when supported by the
protocol and operating system.
If KeepAliveConfig.Enable is true, keep-alive probes are enabled.
If KeepAliveConfig.Enable is false and KeepAlive is negative,
keep-alive probes are disabled. Resolver optionally specifies an alternate resolver to use. Timeout is the maximum amount of time a dial will wait for
a connect to complete. If Deadline is also set, it may fail
earlier.
The default is no timeout.
When using TCP and dialing a host name with multiple IP
addresses, the timeout may be divided between them.
With or without a timeout, the operating system may impose
its own earlier timeout. For instance, TCP timeouts are
often around 3 minutes. LocalAddr is the local address to use when dialing an
address. The address must be of a compatible type for the
network being dialed.
If nil, a local address is automatically chosen. Dial connects to a remote address, using the options of the
Dialer. Dialer uses an underlying net.Dialer to Dial a
net.Conn, then wraps that in a Conn object (with local and
remote Multiaddrs). DialContext allows to provide a custom context to Dial(). MultipathTCP reports whether MPTCP will be used.
This method doesn't check if MPTCP is supported by the operating
system or not. SetMultipathTCP directs the [Dial] methods to use, or not use, MPTCP,
if supported by the operating system. This method overrides the
system default and the GODEBUG=multipathtcp=... setting if any.
If MPTCP is not available on the host or not supported by the server,
the Dial methods will fall back to TCP.
A Listener is a generic network listener for stream-oriented protocols.
it uses an embedded net.Listener, overriding net.Listener.Accept to
return a Conn and providing Multiaddr. Accept waits for and returns the next connection to the listener.
Returns a Multiaddr friendly Conn Addr returns the net.Listener's network address. Close closes the listener.
Any blocked Accept operations will be unblocked and return errors. Multiaddr returns the listener's (local) Multiaddr.
*github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Listener
Listener : github.com/multiformats/go-multiaddr.Multiaddrer
Listener : github.com/prometheus/common/expfmt.Closer
Listener : io.Closer
func Listen(laddr ma.Multiaddr) (Listener, error)
func WrapNetListener(nl net.Listener) (Listener, error)
func github.com/libp2p/go-libp2p/p2p/net/reuseport.(*Transport).Listen(laddr ma.Multiaddr) (Listener, error)
func NetListener(l Listener) net.Listener
func github.com/libp2p/go-libp2p/core/transport.Upgrader.GateMaListener(Listener) transport.GatedMaListener
func github.com/libp2p/go-libp2p/core/transport.Upgrader.UpgradeListener(transport.Transport, Listener) transport.Listener
A PacketConn is a generic packet oriented network connection which uses an
underlying net.PacketConn, wrapped with the locally bound Multiaddr. Close closes the connection.
Any blocked ReadFrom or WriteTo operations will be unblocked and return errors. LocalAddr returns the local network address, if known.( PacketConn) LocalMultiaddr() ma.Multiaddr ReadFrom reads a packet from the connection,
copying the payload into p. It returns the number of
bytes copied into p and the return address that
was on the packet.
It returns the number of bytes read (0 <= n <= len(p))
and any error encountered. Callers should always process
the n > 0 bytes returned before considering the error err.
ReadFrom can be made to time out and return an error after a
fixed time limit; see SetDeadline and SetReadDeadline.( PacketConn) ReadFromMultiaddr(b []byte) (int, ma.Multiaddr, error) SetDeadline sets the read and write deadlines associated
with the connection. It is equivalent to calling both
SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations
fail instead of blocking. The deadline applies to all future
and pending I/O, not just the immediately following call to
Read or Write. After a deadline has been exceeded, the
connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other
I/O methods will return an error that wraps os.ErrDeadlineExceeded.
This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
The error's Timeout method will return true, but note that there
are other possible errors for which the Timeout method will
return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending
the deadline after successful ReadFrom or WriteTo calls.
A zero value for t means I/O operations will not time out. SetReadDeadline sets the deadline for future ReadFrom calls
and any currently-blocked ReadFrom call.
A zero value for t means ReadFrom will not time out. SetWriteDeadline sets the deadline for future WriteTo calls
and any currently-blocked WriteTo call.
Even if write times out, it may return n > 0, indicating that
some of the data was successfully written.
A zero value for t means WriteTo will not time out. WriteTo writes a packet with payload p to addr.
WriteTo can be made to time out and return an Error after a
fixed time limit; see SetDeadline and SetWriteDeadline.
On packet-oriented connections, write timeouts are rare.( PacketConn) WriteToMultiaddr(b []byte, maddr ma.Multiaddr) (int, error)
PacketConn : github.com/pion/datachannel.ReadDeadliner
PacketConn : github.com/pion/datachannel.WriteDeadliner
PacketConn : github.com/prometheus/common/expfmt.Closer
PacketConn : io.Closer
PacketConn : net.PacketConn
func ListenPacket(laddr ma.Multiaddr) (PacketConn, error)
func WrapPacketConn(pc net.PacketConn) (PacketConn, error)
AddrMatch returns the Multiaddrs that match the protocol stack on addr
Dial connects to a remote address. It uses an underlying net.Conn,
then wraps it in a Conn object (with local and remote Multiaddrs).
DialArgs is a convenience function that returns network and address as
expected by net.Dial. See https://godoc.org/net#Dial for an overview of
possible return values (we do not support the unixpacket ones yet). Unix
addresses do not, at present, compose.
FromNetAddr converts a net.Addr type to a Multiaddr.
InterfaceMultiaddrs will return the addresses matching net.InterfaceAddrs
IsIP6LinkLocal returns whether a Multiaddr starts with an IPv6 link-local
multiaddress (with zero or one leading zone). These addresses are non
routable.
IsIPLoopback returns whether a Multiaddr starts with a "Loopback" IP address
This means either /ip4/127.*.*.*/*, /ip6/::1/*, or /ip6/::ffff:127.*.*.*.*/*,
or /ip6zone/<any value>/ip6/<one of the preceding ip6 values>/*
IsIPUnspecified returns whether a Multiaddr starts with an Unspecified IP address
This means either /ip4/0.0.0.0/* or /ip6/::/*
IsNAT64IPv4ConvertedIPv6Addr returns whether addr is a well-known prefix "64:ff9b::/96" addr
used for NAT64 Translation. See RFC 6052
IsPrivateAddr returns true if the IP part of the mutiaddr is in a private network
IsPublicAddr returns true if the IP part of the multiaddr is a publicly routable address
or if it's a dns address without a special use domain e.g. .local.
IsThinWaist returns whether a Multiaddr starts with "Thin Waist" Protocols.
This means: /{IP4, IP6}[/{TCP, UDP}]
Listen announces on the local network address laddr.
The Multiaddr must be a "ThinWaist" stream-oriented network:
ip4/tcp, ip6/tcp, (TODO: unix, unixpacket)
See Dial for the syntax of laddr.
ListenPacket announces on the local network address laddr.
The Multiaddr must be a packet driven network, like udp4 or udp6.
See Dial for the syntax of laddr.
MultiaddrToIPNet converts a multiaddr to an IPNet. Useful for seeing if another IP address is contained within this multiaddr network+mask
NetListener turns this Listener into a net.Listener.
- Connections returned from Accept implement multiaddr/net Conn.
- Calling WrapNetListener on the net.Listener returned by this function will
return the original (underlying) multiaddr/net Listener.
NewCodecMap initializes and returns a CodecMap object.
RegisterFromNetAddr registers a conversion from net.Addr instances to multiaddrs.
RegisterToNetAddr registers a conversion from multiaddrs to net.Addr instances.
ResolveUnspecifiedAddress expands an unspecified ip addresses (/ip4/0.0.0.0, /ip6/::) to
use the known local interfaces. If ifaceAddr is nil, we request interface addresses
from the network stack. (this is so you can provide a cached value if resolving many addrs)
ResolveUnspecifiedAddresses expands unspecified ip addresses (/ip4/0.0.0.0, /ip6/::) to
use the known local interfaces.
ToIP converts a Multiaddr to a net.IP when possible
ToNetAddr converts a Multiaddr to a net.Addr
Must be ThinWaist. acceptable protocol stacks are:
/ip{4,6}/{tcp, udp}
WrapNetConn wraps a net.Conn object with a Multiaddr friendly Conn.
This function does it's best to avoid "hiding" methods exposed by the wrapped
type. Guarantees:
- If the wrapped connection exposes the "half-open" closer methods
(CloseWrite, CloseRead), these will be available on the wrapped connection
via type assertions.
- If the wrapped connection is a UnixConn, IPConn, TCPConn, or UDPConn, all
methods on these wrapped connections will be available via type assertions.
WrapNetListener wraps a net.Listener with a manet.Listener.
WrapPacketConn wraps a net.PacketConn with a manet.PacketConn.
Package-Level Variables (total 9)
IP4Loopback is the ip4 loopback multiaddr
IP4MappedIP6Loopback is the IPv4 Mapped IPv6 loopback address.
Unspecified Addresses (used for )
IP6Loopback is the ip6 loopback multiaddr
Unspecified Addresses (used for )
Private4 and Private6 are well-known private networks
Private4 and Private6 are well-known private networks
Unroutable4 and Unroutable6 are well known unroutable address ranges
Unroutable4 and Unroutable6 are well known unroutable address ranges
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.