build: golang.org/x/build/revdial Index | Files | Directories

package revdial

import "golang.org/x/build/revdial"

Package revdial implements a Dialer and Listener which work together to turn an accepted connection (for instance, a Hijacked HTTP request) into a Dialer which can then create net.Conns connecting back to the original dialer, which then gets a net.Listener accepting those conns.

This is basically a very minimal SOCKS5 client & server.

The motivation is that sometimes you want to run a server on a machine deep inside a NAT. Rather than connecting to the machine directly (which you can't, because of the NAT), you have the sequestered machine connect out to a public machine. Both sides then use revdial and the public machine can become a client for the NATed machine.

Deprecated: this package should not be used and actually can no longer be used: half of its code has been deleted as it's no longer in use. We kept the half still needed by cmd/coordinator for old buildlet clients, but the new buildlet no longer uses this. Instead, callers should use the revdial/v2 version that is based on a different design without the flow control issues.

Index

Package Files

revdial.go

type Dialer Uses

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

The Dialer can create new connections.

func NewDialer Uses

func NewDialer(rw *bufio.ReadWriter, c io.Closer) *Dialer

NewDialer returns the side of the connection which will initiate new connections. This will typically be the side which did the HTTP Hijack. The io.Closer is what gets closed by the Close or by any errors. It will typically be the hijacked Conn.

func (*Dialer) Close Uses

func (d *Dialer) Close() error

Close closes the Dialer and all still-open connections from it.

func (*Dialer) Dial Uses

func (d *Dialer) Dial() (net.Conn, error)

Dial creates a new connection back to the Listener.

func (*Dialer) Done Uses

func (d *Dialer) Done() <-chan struct{}

Done returns a channel which is closed when d is either closed or closed by the peer.

Directories

PathSynopsis
v2Package revdial implements a Dialer and Listener which work together to turn an accepted connection (for instance, a Hijacked HTTP request) into a Dialer which can then create net.Conns connecting back to the original dialer, which then gets a net.Listener accepting those conns.

Package revdial imports 10 packages (graph) and is imported by 1 packages. Updated 2019-07-21. Refresh now. Tools for package owners.