tunnel

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Overview

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	Magic     = []byte{0x20, 0x88}
	HeaderLen = 8
	Version   = byte(0x01)

	MagicIndex      = 0
	VersionIndex    = 2
	FlagIndex       = 3
	TypeIndex       = 4
	DataLengthIndex = 6
	PayLoadIndex    = 8

	ConnectUnknownFailed     ConnectStatus = 0
	ConnectSuccess           ConnectStatus = 1
	ConnectAuthFailed        ConnectStatus = 2
	ConnectValidatorNotFound ConnectStatus = 3
	ConnectClusterNotExist   ConnectStatus = 4

	RequestType  = []byte{0x01, 0x00}
	ResponseType = []byte{0x02, 0x00}
)
View Source
var ErrUnRecognizedData = errors.New("unrecognized payload data")

Functions

func CreateAgentBackendConnection

func CreateAgentBackendConnection(conn api.Connection) *agentBackendConnection

func CreateTunnelNetworkFilterFactory

func CreateTunnelNetworkFilterFactory(config map[string]interface{}) (api.NetworkFilterChainFactory, error)

func DecodeFromBuffer

func DecodeFromBuffer(buffer api.IoBuffer) (interface{}, error)

func Encode

func Encode(i interface{}) (buffer.IoBuffer, error)

func NewHost

func NewHost(config v2.Host, clusterInfo types.ClusterInfo, connection types.ClientConnection) *host

func NewHostRemover

func NewHostRemover(address string, cluster string) *hostRemover

Types

type AgentAsideConnection

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

AgentAsideConnection indicates a connection on the client side. Unlike AgentClientConnection, AgentAsideConnection is only responsible for sending control commands to server, such as GracefulCloseOnewayRequest

func NewAgentAsideConnection

func NewAgentAsideConnection(config ConnectionConfig, listener types.Listener) *AgentAsideConnection

func (AgentAsideConnection) Close

func (a AgentAsideConnection) Close() error

func (AgentAsideConnection) OnEvent

func (a AgentAsideConnection) OnEvent(event api.ConnectionEvent)

func (AgentAsideConnection) PrepareClose

func (a AgentAsideConnection) PrepareClose()

func (AgentAsideConnection) ReadOneMessage

func (a AgentAsideConnection) ReadOneMessage() (interface{}, error)

func (AgentAsideConnection) Write

func (a AgentAsideConnection) Write(request interface{}) error

type AgentBootstrapConfig

type AgentBootstrapConfig struct {
	Enable bool `json:"enable"`
	// The number of connections established between the agent and each server
	ConnectionNum int `json:"connection_num"`
	// The cluster of remote server
	Cluster string `json:"cluster"`
	// After the connection is established, the data transmission is processed by this listener
	HostingListener string `json:"hosting_listener"`
	// Static remote server list
	StaticServerList []string `json:"server_list"`

	// DynamicServerListConfig is used to specify dynamic server configuration
	DynamicServerListConfig struct {
		DynamicServerLister string `json:"dynamic_server_lister"`
	} `json:"dynamic_server_list_config"`

	// ConnectRetryTimes
	ConnectRetryTimes int `json:"connect_retry_times"`
	// ReconnectBaseDuration
	ReconnectBaseDuration api.DurationConfig `json:"reconnect_base_duration"`

	// ConnectTimeoutDuration specifies the timeout for establishing a connection and initializing the agent
	ConnectTimeoutDuration api.DurationConfig `json:"connect_timeout_duration"`
	CredentialPolicy       string             `json:"credential_policy"`
	// GracefulCloseMaxWaitDuration specifies the maximum waiting time to close conn gracefully
	GracefulCloseMaxWaitDuration api.DurationConfig `json:"graceful_close_max_wait_duration"`

	TLSContext *v2.TLSConfig `json:"tls_context"`
}

type AgentClientConnection

type AgentClientConnection struct {
	ConnectionConfig
	// contains filtered or unexported fields
}

AgentClientConnection indicates a tunnel agent connection on the client side

func NewAgentCoreConnection

func NewAgentCoreConnection(config ConnectionConfig, listener types.Listener) *AgentClientConnection

func (AgentClientConnection) Close

func (a AgentClientConnection) Close() error

func (AgentClientConnection) OnEvent

func (a AgentClientConnection) OnEvent(event api.ConnectionEvent)

func (AgentClientConnection) PrepareClose

func (a AgentClientConnection) PrepareClose()

func (AgentClientConnection) ReadOneMessage

func (a AgentClientConnection) ReadOneMessage() (interface{}, error)

func (AgentClientConnection) Write

func (a AgentClientConnection) Write(request interface{}) error

type AgentPeer

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

func (*AgentPeer) Start

func (a *AgentPeer) Start()

func (*AgentPeer) Stop

func (a *AgentPeer) Stop()

type ConnectStatus

type ConnectStatus int64

type ConnectionConfig

type ConnectionConfig struct {
	Address           string `json:"address"`
	ClusterName       string `json:"cluster_name"`
	Weight            int64  `json:"weight"`
	ConnectRetryTimes int    `json:"connect_retry_times"`
	// ConnectTimeoutDuration specifies the timeout for establishing a connection and initializing the agent
	ConnectTimeoutDuration       time.Duration `json:"connect_timeout_duration"`
	Network                      string        `json:"network"`
	ReconnectBaseDuration        time.Duration `json:"reconnect_base_duration"`
	CredentialPolicy             string        `json:"credential_policy"`
	ConnectionNumPerAddress      int           `json:"connection_num_per_address"`
	GracefulCloseMaxWaitDuration time.Duration `json:"graceful_close_max_wait_duration"`

	TLSContext *v2.TLSConfig `json:"tls_context"`
}

type ConnectionInitInfo

type ConnectionInitInfo struct {
	ClusterName      string                 `json:"cluster_name"`
	Weight           int64                  `json:"weight"`
	HostName         string                 `json:"host_name"`
	CredentialPolicy string                 `json:"credential_policy"`
	Credential       string                 `json:"credential"`
	Extra            map[string]interface{} `json:"extra"`
}

ConnectionInitInfo is the basic information of agent host, it is sent immediately after the physical connection is established

type ConnectionInitResponse

type ConnectionInitResponse struct {
	Status ConnectStatus `json:"status"`
}

type GracefulCloseOnewayRequest

type GracefulCloseOnewayRequest struct {
	Addresses   []string `json:"addresses"`
	ClusterName string   `json:"cluster_name"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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