util

package
v0.0.0-...-a54ed49 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableNAT represents nat table in iptables
	TableNAT = "nat"
	// ChainPrerouting represents PREROUTING chain in iptables
	ChainPrerouting = "PREROUTING"
	// ChainPostrouting represents POSTROUTING chain in iptables
	ChainPostrouting = "POSTROUTING"
)
View Source
const (

	// MinPort is the smallest port number that can be used by forwarder pod
	MinPort = 2049
	// MaxPort is the biggest port number that can be used by forwarder pod
	MaxPort = 65536
)
View Source
const (
	// SSHPort is port number to used for ssh server
	// TODO: change this to variable
	SSHPort = "2022"
)

Variables

This section is empty.

Functions

func AddChains

func AddChains(table string, expected map[string][][]string) error

AddChains adds {expected} rules in {table}. Existing ruleSpec in the chains won't be deleted. It returns error if there are any error on adding chains. {expected} is passed as a map of chain name to slice of ruleSpec. ex) to specify "-j pre1" and "-j pre2" in "PREROUTING" chain

map[string][][]string{"PREROUTING": [][]string{{"-j", "pre1"}, {"-j", "pre2"}}}

func CheckChainsExist

func CheckChainsExist(table string, expected map[string][][]string) bool

CheckChainsExist checks if all {expected} rules exist in {table}. It returns error if it fails to find any expected rules or there's error in checking {expected} is passed as a map of chain name to slice of ruleSpec. ex) to specify "-j pre1" and "-j pre2" in "PREROUTING" chain

map[string][][]string{"PREROUTING": [][]string{{"-j", "pre1"}, {"-j", "pre2"}}}

func DNATRuleSpec

func DNATRuleSpec(dstIP, srcIP, dPort, destinationIP, destinationPort string) []string

DNATRuleSpec returns ruleSpec to DNAT for the given arguments

func DirectTCPIPHandler

func DirectTCPIPHandler(srv *glssh.Server, conn *ssh.ServerConn, newChan ssh.NewChannel, ctx glssh.Context)

DirectTCPIPHandler is a handler for direct-tcpip. This is modified from gliderlabs original one so that it can reserve source ip.

func GetHexIP

func GetHexIP(ip string) (string, error)

GetHexIP returns hex expression of IP address ex) 192.168.122.1 -> c0a87a01

func GetRuleName

func GetRuleName(ip string) (string, error)

GetRuleName returns configmap name for gateway which has ip ex) 192.168.122.1 -> gwrulec0a87a01

func IsPortOpen

func IsPortOpen(ip, port string) bool

IsPortOpen checks if ip:port is open by connecting to it It returns false if there is an error connecting to it or connection is nil, otherwise it returns true.

func NewSSHServer

func NewSSHServer(addr string) glssh.Server

NewSSHServer returns ssh server instance that will listen on {addr}

func ReplaceChains

func ReplaceChains(table string, expected map[string][][]string) error

ReplaceChains replaces rules in {table} to {expected}. Existing rules in the chains will be deleted. It returns error if there are any error on replacing chains. {expected} is passed as a map of chain name to slice of ruleSpec. ex) to specify "-j pre1" and "-j pre2" in "PREROUTING" chain

map[string][][]string{"PREROUTING": [][]string{{"-j", "pre1"}, {"-j", "pre2"}}}

func RuleSyncingCondition

func RuleSyncingCondition(stat corev1.ConditionStatus) status.Condition

RuleSyncingCondition sets submarinerv1alpha1.ConditionRuleSyncing to stat

func RuleUpdatingCondition

func RuleUpdatingCondition(stat corev1.ConditionStatus) status.Condition

RuleUpdatingCondition sets submarinerv1alpha1.ConditionRuleUpdating to stat

func SNATRuleSpec

func SNATRuleSpec(dstIP, srcIP, dPort string) []string

SNATRuleSpec returns ruleSpec to SNAT for the given arguments

Types

type Controller

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

Controller represents a cotroller

func NewController

NewController returns a controller instance

func (*Controller) Run

func (c *Controller) Run()

Run runs a controller

type ReconcilerInterface

type ReconcilerInterface interface {
	Reconcile(namespace, name string) error
}

ReconcilerInterface is an interface for reconciler

type Tunnel

type Tunnel struct {
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

Tunnel represents ssh tunnel

func NewTunnel

func NewTunnel(local, server, remote string, config *ssh.ClientConfig) *Tunnel

NewTunnel returns a Tunnel instance

func (*Tunnel) Forward

func (t *Tunnel) Forward() error

Forward implements ssh forward functionality. It forwards remote endpoint to local endpoint via server endpoint where ssh forward server running. Forward() can be canceled by calling Cancel().

func (*Tunnel) ForwardNB

func (t *Tunnel) ForwardNB()

ForwardNB is non-blocking version of Forward It retries with exponential backoff on failure.

func (*Tunnel) RemoteForward

func (t *Tunnel) RemoteForward() error

RemoteForward implements ssh remote forward functionality. It forwards local endpoint to remote endpoint via server endpoint where ssh forward server running. RemoteForward() can be canceled by calling Cancel().

func (*Tunnel) RemoteForwardNB

func (t *Tunnel) RemoteForwardNB()

RemoteForwardNB is non-blocking version of RemoteForward It retries with exponential backoff on failure.

func (*Tunnel) String

func (t *Tunnel) String() string

String returns string representation of Tunnel. ex)

"local: 192.168.122.100:8080, server: 192.168.122.101:2022, remote: 192.168.122.102:80"

Directories

Path Synopsis
Package mock_util is a generated GoMock package.
Package mock_util is a generated GoMock package.

Jump to

Keyboard shortcuts

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