tunnel

package
v0.0.0-...-9fce2f1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

README

remotedialer

This package is taken from rancher/remotedialer because my implementation (internal/tun) doesn't get me a shit. But the client side of rancher remotedialer doesn't fit this project, so I need to put it right here and make some changes from it.

Documentation

Index

Constants

View Source
const (
	Data messageType = iota + 1
	Connect
	Error
	AddClient
	RemoveClient
	Pause
	Resume
)
View Source
const (
	PingWaitDuration  = 60 * time.Second
	PingWriteInterval = 5 * time.Second
	MaxRead           = 8192
	HandshakeTimeOut  = 10 * time.Second
)
View Source
const (
	MaxBuffer = 1 << 21
)

Variables

View Source
var (
	Token = "X-API-Tunnel-Token"
	ID    = "X-API-Tunnel-ID"
)
View Source
var DefaultClientAuthorizer = func(proto, address string) bool { return true }
View Source
var ErrMessageType = errors.New("invalid message type")
View Source
var PrintTunnelData bool

PrintTunnelData No tunnel logging by default

Functions

func DefaultErrorWriter

func DefaultErrorWriter(w http.ResponseWriter, r *http.Request, code int, err error)

func DefaultServerAuthorizer

func DefaultServerAuthorizer(req *http.Request) (string, error)

Types

type Authorizer

type Authorizer func(*http.Request) (string, error)

type Client

type Client interface {
	Listen(context.Context) (net.Listener, error)
	Close() error
}

func Dial

func Dial(addr string, opts ...ClientOption) (Client, error)

func DialContext

func DialContext(c context.Context, addr string, opts ...ClientOption) (Client, error)

type ClientOption

type ClientOption func(*ClientOptions)

func ClientAuthorizer

func ClientAuthorizer(a ConnectAuthorizer) ClientOption

func ClientCredentials

func ClientCredentials(id, token string) ClientOption

type ClientOptions

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

type ConnectAuthorizer

type ConnectAuthorizer func(proto, address string) bool

ConnectAuthorizer custom for authorization

type Dialer

type Dialer func(ctx context.Context, network, address string) (net.Conn, error)

type ErrorWriter

type ErrorWriter func(http.ResponseWriter, *http.Request, int, error)

type Node

type Node struct {
	Id   string
	Peer bool
}

type Server

type Server interface {
	http.Handler
	Dialer(string) (Dialer, error)
}

func NewServer

func NewServer(opts ...ServerOption) Server

type ServerOption

type ServerOption func(*ServerOptions)

func ServerAuthorizer

func ServerAuthorizer(a Authorizer) ServerOption

func ServerErrorWriter

func ServerErrorWriter(e ErrorWriter) ServerOption

func ServerOnConnect

func ServerOnConnect(f func(*Node) error) ServerOption

func ServerOnDisconnect

func ServerOnDisconnect(f func(*Node) error) ServerOption

type ServerOptions

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

type Session

type Session struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewClientSession

func NewClientSession(auth ConnectAuthorizer, conn *websocket.Conn) *Session

func NewClientSessionWithDialer

func NewClientSessionWithDialer(auth ConnectAuthorizer, conn *websocket.Conn, dialer Dialer) *Session

func (*Session) Accept

func (s *Session) Accept() (net.Conn, error)

func (*Session) Addr

func (s *Session) Addr() net.Addr

func (*Session) Close

func (s *Session) Close() error

func (*Session) Dial

func (s *Session) Dial(ctx context.Context, proto, address string) (net.Conn, error)

func (*Session) Serve

func (s *Session) Serve(ctx context.Context) (int, error)

Jump to

Keyboard shortcuts

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