bridge

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0, BSD-3-Clause, MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize = 17000
View Source
const DefaultPort = 80
View Source
const EXT_APIACCESS = 1
View Source
const EXT_DNS = 2
View Source
const PACKET_TYPE_DATA = 0
View Source
const PACKET_TYPE_HELLO = 1

Variables

This section is empty.

Functions

func DefaultLinkName

func DefaultLinkName(meshname string, ip net.IP) kubelink.LinkName

func NewBridgeMode

func NewBridgeMode(env runmode.RunModeEnv) (runmode.RunMode, error)

func NewConnectTask

func NewConnectTask(name kubelink.LinkName, runmode *mode) tasks.Task

func NewTunnelConnection

func NewTunnelConnection(mux *Mux, conn net.Conn, link *kubelink.Link, links kubelink.Links, handlers ...ConnectionFailHandler) (*TunnelConnection, *ConnectionHello, error)

func RegisterExtension

func RegisterExtension(id byte, c ConnectionHelloExtensionHandler)

Types

type APIExtension

type APIExtension kubelink.LinkAccessInfo

func (*APIExtension) Data

func (this *APIExtension) Data() []byte

func (*APIExtension) Id

func (this *APIExtension) Id() byte

func (*APIExtension) String

func (this *APIExtension) String() string

type APIExtensionHandler

type APIExtensionHandler struct{}

func (*APIExtensionHandler) Add

func (this *APIExtensionHandler) Add(hello *ConnectionHello, mux *Mux)

func (*APIExtensionHandler) Parse

func (this *APIExtensionHandler) Parse(id byte, data []byte) (ConnectionHelloExtension, error)

type CertInfo

type CertInfo struct {
	certs.CertificateSource
	// contains filtered or unexported fields
}

func NewCertInfo

func NewCertInfo(logger logger.LogContext, source certs.CertificateSource) *CertInfo

func (*CertInfo) ClientConfig

func (this *CertInfo) ClientConfig() *tls.Config

func (*CertInfo) Dial

func (this *CertInfo) Dial(endpoint string) (net.Conn, error)

func (*CertInfo) ServerConfig

func (this *CertInfo) ServerConfig() *tls.Config

func (*CertInfo) UseTLS

func (this *CertInfo) UseTLS() bool

type ConnectionFailHandler

type ConnectionFailHandler interface {
	Notify(*TunnelConnection, error)
}

type ConnectionHandler

type ConnectionHandler interface {
	UpdateAccess(hello *ConnectionHello)
	GetAccess() kubelink.LinkAccessInfo
	GetDNSInfo() kubelink.LinkDNSInfo
}

type ConnectionHello

type ConnectionHello struct {
	ConnectionHelloHeader
	Extensions map[byte]ConnectionHelloExtension
	Raw        map[byte][]byte
}

func NewConnectionHello

func NewConnectionHello() *ConnectionHello

func ParseConnectionHello

func ParseConnectionHello(logger logger.LogContext, header *ConnectionHelloHeader, data []byte) (*ConnectionHello, error)

func (*ConnectionHello) Data

func (this *ConnectionHello) Data() []byte

type ConnectionHelloExtension

type ConnectionHelloExtension interface {
	Id() byte
	Data() []byte
}

func GetExtension

func GetExtension(id byte, data []byte) (ConnectionHelloExtension, error)

type ConnectionHelloExtensionHandler

type ConnectionHelloExtensionHandler interface {
	Parse(id byte, data []byte) (ConnectionHelloExtension, error)
	Add(hello *ConnectionHello, mux *Mux)
}

type ConnectionHelloHeader

type ConnectionHelloHeader [net.IPv6len * 5]byte

func (*ConnectionHelloHeader) GetCIDR

func (this *ConnectionHelloHeader) GetCIDR() *net.IPNet

func (*ConnectionHelloHeader) GetClusterAddress

func (this *ConnectionHelloHeader) GetClusterAddress() *net.IPNet

func (*ConnectionHelloHeader) GetClusterIP

func (this *ConnectionHelloHeader) GetClusterIP() net.IP

func (*ConnectionHelloHeader) GetExtensionLength

func (this *ConnectionHelloHeader) GetExtensionLength() uint16

func (*ConnectionHelloHeader) GetPort

func (this *ConnectionHelloHeader) GetPort() uint16

func (*ConnectionHelloHeader) SetCIDR

func (this *ConnectionHelloHeader) SetCIDR(cidr *net.IPNet)

func (*ConnectionHelloHeader) SetClusterAddress

func (this *ConnectionHelloHeader) SetClusterAddress(cidr *net.IPNet)

func (*ConnectionHelloHeader) SetExtensionLength

func (this *ConnectionHelloHeader) SetExtensionLength(len uint16)

func (*ConnectionHelloHeader) SetPort

func (this *ConnectionHelloHeader) SetPort(port uint16)

type DNSExtension

type DNSExtension kubelink.LinkDNSInfo

func (*DNSExtension) Data

func (this *DNSExtension) Data() []byte

func (*DNSExtension) Id

func (this *DNSExtension) Id() byte

func (*DNSExtension) String

func (this *DNSExtension) String() string

type DNSExtensionHandler

type DNSExtensionHandler struct{}

func (*DNSExtensionHandler) Add

func (this *DNSExtensionHandler) Add(hello *ConnectionHello, mux *Mux)

func (*DNSExtensionHandler) Parse

func (this *DNSExtensionHandler) Parse(id byte, data []byte) (ConnectionHelloExtension, error)

type DefaultConnectionHandler

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

func NewDefaultConnectionHandler

func NewDefaultConnectionHandler(runmode *mode) *DefaultConnectionHandler

func (*DefaultConnectionHandler) GetAccess

func (*DefaultConnectionHandler) GetDNSInfo

func (this *DefaultConnectionHandler) GetDNSInfo() kubelink.LinkDNSInfo

func (*DefaultConnectionHandler) UpdateAccess

func (this *DefaultConnectionHandler) UpdateAccess(hello *ConnectionHello)

type LinkStateHandler

type LinkStateHandler interface {
	Notify(*kubelink.Link, error)
}

type Mux

type Mux struct {
	logger.LogContext
	// contains filtered or unexported fields
}

func NewMux

func NewMux(ctx context.Context, logger logger.LogContext, certInfo *CertInfo, port uint16, localCIDRs tcp.CIDRList, tun *Tun, links kubelink.Links, handlers ...LinkStateHandler) *Mux

func (*Mux) AddTunnel

func (this *Mux) AddTunnel(t *TunnelConnection)

func (*Mux) AssureTunnel

func (this *Mux) AssureTunnel(logger logger.LogContext, link *kubelink.Link) (*TunnelConnection, error)

func (*Mux) Close

func (this *Mux) Close(ip net.IP) error

func (*Mux) FindConnection

func (this *Mux) FindConnection(log logger.LogContext, packet []byte) *TunnelConnection

func (*Mux) GetConnectionForIP

func (this *Mux) GetConnectionForIP(ip net.IP) (*TunnelConnection, error)

func (*Mux) GetError

func (this *Mux) GetError(ip net.IP) error

func (*Mux) HandleTun

func (this *Mux) HandleTun() error

func (*Mux) Notify

func (this *Mux) Notify(t *TunnelConnection, err error)

func (*Mux) QueryConnectionForIP

func (this *Mux) QueryConnectionForIP(ip net.IP) (*TunnelConnection, *kubelink.Link)

func (*Mux) RegisterFailHandler

func (this *Mux) RegisterFailHandler(handlers ...LinkStateHandler)

func (*Mux) RemoveTunnel

func (this *Mux) RemoveTunnel(t *TunnelConnection)

func (*Mux) Send

func (this *Mux) Send(log logger.LogContext, packet []byte) error

func (*Mux) ServeConnection

func (this *Mux) ServeConnection(ctx context.Context, conn net.Conn)

func (*Mux) SetAutoConnect

func (this *Mux) SetAutoConnect(b bool)

type Server

type Server struct {
	logger.LogContext
	// contains filtered or unexported fields
}

func NewServer

func NewServer(name string, mux *Mux) *Server

func (*Server) Start

func (this *Server) Start(certInfo *CertInfo, bindAddress string, port int)

Start starts a server.

type Tun

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

func NewTun

func NewTun(logger logger.LogContext, name string) (*Tun, error)

func (*Tun) Close

func (this *Tun) Close() error

func (*Tun) Read

func (this *Tun) Read(buf []byte) (int, error)

func (*Tun) String

func (this *Tun) String() string

func (*Tun) Write

func (this *Tun) Write(data []byte) (int, error)

type TunnelConnection

type TunnelConnection struct {
	logger.LogContext
	// contains filtered or unexported fields
}
func (this *TunnelConnection) ApplyLink(link kubelink.LinkName)

func (*TunnelConnection) Close

func (this *TunnelConnection) Close() error

func (*TunnelConnection) ReadPacket

func (this *TunnelConnection) ReadPacket(data []byte) (int, byte, error)

func (*TunnelConnection) RegisterStateHandler

func (this *TunnelConnection) RegisterStateHandler(handlers ...ConnectionFailHandler)

func (*TunnelConnection) Send

func (this *TunnelConnection) Send(packet []byte) error

func (*TunnelConnection) Serve

func (this *TunnelConnection) Serve() error

func (*TunnelConnection) String

func (this *TunnelConnection) String() string

func (*TunnelConnection) WritePacket

func (this *TunnelConnection) WritePacket(ty byte, data []byte) error

Jump to

Keyboard shortcuts

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