broker

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: Apache-2.0, BSD-3-Clause, MIT Imports: 43 Imported by: 1

Documentation

Index

Constants

View Source
const BufferSize = 17000
View Source
const CLUSTER_DNS_IP = 10
View Source
const CMD_TASK_PREFIX = "task:"
View Source
const DNSMODE_DNS = "dns"
View Source
const DNSMODE_KUBERNETES = "kubernetes"
View Source
const DNSMODE_NONE = "none"
View Source
const EXT_APIACCESS = 1
View Source
const EXT_DNS = 2
View Source
const IPCHAIN = "POSTROUTING"
View Source
const IPTAB = "nat"
View Source
const KUBELINK_DNS_IP = 11
View Source
const MANAGE_MODE_CERT = "cert"
View Source
const MANAGE_MODE_NONE = "none"
View Source
const MANAGE_MODE_SELF = "self"
View Source
const PACKET_TYPE_DATA = 0
View Source
const PACKET_TYPE_HELLO = 1

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(data []byte, max int) string

func Create

func Create(controller controller.Interface) (reconcile.Interface, error)

func CreateSecrets

func CreateSecrets(controller controller.Interface) (reconcile.Interface, error)

func DefaultLinkName

func DefaultLinkName(ip net.IP) string

func NewTunnelConnection

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

func RegisterExtension

func RegisterExtension(id byte, c ConnectionHelloExtensionHandler)

func SetLinkAddress

func SetLinkAddress(logger logger.LogContext, link netlink.Link, addr *net.IPNet) error

func TaskReconciler

func TaskReconciler(count int) controller.ConfigurationModifier

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 BaseTask

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

func NewBaseTask

func NewBaseTask(ttype, name string) BaseTask

func (*BaseTask) Execute

func (this *BaseTask) Execute(logger logger.LogContext) reconcile.Status

func (*BaseTask) Id

func (this *BaseTask) Id() string

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 Config

type Config struct {
	controllers.Config

	ClusterAddress *net.IPNet
	ClusterCIDR    *net.IPNet
	ClusterName    string

	ServiceCIDR *net.IPNet

	Responsible    utils.StringSet
	Port           int
	AdvertisedPort int

	CertFile   string
	KeyFile    string
	CACertFile string

	Secret     string
	ManageMode string
	DNSName    string
	Service    string
	Interface  string
	MeshDomain string

	ServiceAccount   resources.ObjectName
	DNSAdvertisement bool

	DNSPropagation string

	CoreDNSServiceIP  net.IP
	CoreDNSDeployment string
	CoreDNSSecret     string
	CoreDNSConfigure  bool

	DNSServiceIP  net.IP
	ClusterDomain string

	AutoConnect   bool
	DisableBridge bool
	// contains filtered or unexported fields
}

func (*Config) AddOptionsToSet

func (this *Config) AddOptionsToSet(set config.OptionSet)
func (this *Config) MatchLink(obj *v1alpha1.KubeLink) (bool, net.IP)

func (*Config) Prepare

func (this *Config) Prepare() error

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.IP

func (*ConnectionHelloHeader) GetClusterCIDR

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

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(ip net.IP)

func (*ConnectionHelloHeader) SetClusterCIDR

func (this *ConnectionHelloHeader) SetClusterCIDR(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 (*DefaultConnectionHandler) GetAccess

func (*DefaultConnectionHandler) GetDNSInfo

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

func (*DefaultConnectionHandler) UpdateAccess

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

type Kubeconfig

type Kubeconfig Manifest

func NewKubeconfig

func NewKubeconfig() Kubeconfig

func (Kubeconfig) AddCluster

func (this Kubeconfig) AddCluster(name, url, ca, token string)

type LinkStateHandler

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

type Manifest

type Manifest map[string]interface{}

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, addr *net.IPNet, 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) ServeConnection

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

func (*Mux) SetAutoConnect

func (this *Mux) SetAutoConnect(b bool)

type SecretCache

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

func GetSharedSecrets

func GetSharedSecrets(controller controller.Interface) *SecretCache

func NewSecretCache

func NewSecretCache() *SecretCache

func (*SecretCache) AllocSecret

func (this *SecretCache) AllocSecret(name resources.ObjectName, link resources.ObjectName)

func (*SecretCache) GetSecretUsers

func (this *SecretCache) GetSecretUsers(name resources.ObjectName) resources.ObjectNameSet

func (*SecretCache) ReleaseSecret

func (this *SecretCache) ReleaseSecret(name resources.ObjectName, link resources.ObjectName)
func (this *SecretCache) ReleaseSecretForLink(link resources.ObjectName)

func (*SecretCache) UpdateSecret

func (this *SecretCache) UpdateSecret(name resources.ObjectName, link resources.ObjectName)

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 Task

type Task interface {
	Id() string
	Execute(logger logger.LogContext) reconcile.Status
}

func NewConnectTask

func NewConnectTask(name string, reconciler *reconciler) Task

type Tasks

type Tasks interface {
	ScheduleTask(task Task, override bool)
}

func GetTaskClient

func GetTaskClient(controller controller.Interface) Tasks

type Tun

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

func NewTun

func NewTun(logger logger.LogContext, name string, clusterAddress *net.IPNet) (*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 (*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) 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