go123: lab.nexedi.com/kirr/go123/xnet Index | Files | Directories

package xnet

import "lab.nexedi.com/kirr/go123/xnet"

Package xnet provides addons to std package net.


Package Files

net.go trace.go

type Networker Uses

type Networker interface {
    // Network returns name of the network.
    Network() string

    // Name returns name of the access-point on the network.
    // Example of name is local hostname if networker provides access to
    // OS-level dial/listen.
    Name() string

    // Dial connects to addr on underlying network.
    // See net.Dial for semantic details.
    Dial(ctx context.Context, addr string) (net.Conn, error)

    // Listen starts listening on local address laddr on underlying network access-point.
    // See net.Listen for semantic details.
    // XXX also introduce xnet.Listener in which Accept() accepts also ctx?
    Listen(laddr string) (net.Listener, error)

Networker is interface representing access-point to a streaming network.

func NetPlain Uses

func NetPlain(network string) Networker

NetPlain creates Networker corresponding to regular network accessors from std package net.

network is "tcp", "tcp4", "tcp6", "unix", etc...

func NetTLS Uses

func NetTLS(inner Networker, config *tls.Config) Networker

NetTLS wraps underlying networker with TLS layer according to config.

The config must be valid:

- for tls.Client -- for Dial to work,
- for tls.Server -- for Listen to work.

func NetTrace Uses

func NetTrace(inner Networker, tracer Tracer) Networker

NetTrace wraps underlying networker with IO tracing layer.

Tracing is done via calling trace func right after corresponding networking event happenned. No synchronization for notification is performed - if one is required tracing func must implement such synchronization itself.

only initiation events are traced:

1. Tx only (no Rx):

- because Write, contrary to Read, never writes partial data on non-error
- because in case of pipenet tracing writes only is enough to get whole network exchange picture

2. Dial only (no Accept)

- for similar reasons.

WARNING NetTrace functionality is currently very draft.

type TraceConnect Uses

type TraceConnect struct {
    // XXX also put networker?
    Src, Dst net.Addr
    Dialed   string

TraceConnect is event corresponding to established network connection.

type TraceDial Uses

type TraceDial struct {
    // XXX also put networker?
    Dialer, Addr string

TraceDial is event corresponding to network dial start.

type TraceListen Uses

type TraceListen struct {
    // XXX also put networker?
    Laddr net.Addr

TraceListen is event corresponding to network listening.

type TraceTx Uses

type TraceTx struct {
    // XXX also put network somehow?
    Src, Dst net.Addr
    Pkt      []byte

TraceTx is event corresponding to network transmission.

type Tracer Uses

type Tracer interface {

Tracer is the interface that needs to be implemented by network trace receivers.


internal/virtnettestPackage virtnettest provides basic tests to be run on virtnet network implementations.
lonetPackage lonet provides TCP network simulated on top of localhost TCP loopback.
pipenetPackage pipenet provides TCP-like synchronous in-memory network of net.Pipes.
virtnetPackage virtnet provides infrastructure for TCP-like virtual networks.

Package xnet imports 5 packages (graph) and is imported by 6 packages. Updated 2020-07-07. Refresh now. Tools for package owners.