Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPeerHeaders(h http.Header) bool
- func CheckRelayLoops(h http.Header) bool
- func CloneHeader(h http.Header) http.Header
- func CopyHeader(dst, src http.Header)
- func DeleteCache(cache *ristretto.Cache, key interface{})
- func Fatal(format string, a ...interface{})
- func GenUUID()
- func GetCache(cache *ristretto.Cache, key interface{}) (interface{}, bool)
- func GetRelayIP() string
- func GetRelayIPPort() string
- func InitCache(evict OnEvict) (*ristretto.Cache, error)
- func InsertCache(cache *ristretto.Cache, expiry time.Duration, key, value interface{}) bool
- func IsHTTPS(addr string) bool
- func KeepAlive(conn net.Conn) error
- func PeerSetHeaderNonce(h http.Header) error
- func SanitizeValues(input string) string
- func SetXForwardedFor(h http.Header, remoteAddr string)
- func SetXForwardedParalus(h http.Header, msg *ControlMessage)
- func SetXRAYUUID(h http.Header)
- func SplitHostPort(hostport string) (host, port string)
- func Transfer(dst io.Writer, src io.Reader, tlog *relaylogger.RelayLog, direction string)
- func UnSetXForwardedParalus(h http.Header)
- func WriteFile(filename, data string) error
- func WriteToHeader(h http.Header, c *ControlMessage)
- type ControlMessage
- type CountWriter
- type FlushWriter
- type OnEvict
- type ProxyConfig
- type ProxyProtocolMessage
- type RelayNetworkConfig
- type Relaynetwork
- type SNICertificate
- type ServiceAccountCacheObject
Constants ¶
const ( KUBECTL = "kubectl" KUBEWEB = "kubeweb" GENTCP = "tcp" HTTPUP = "httpupgrade" )
Known relay services
const ( RELAY = "relay" CDRELAY = "cdrelay" RELAYAGENT = "relay-agent" CDRELAYAGENT = "cdrelay-agent" DIALIN = "dialin" JoinString = "--" )
Known server types
const ( KUBECTLCORE = "paralus-core-relay-agent" KUBECTLDEDICATED = "paralus-non-core-relay-agent" CDAGENTCORE = "paralus-core-cd-relay-agent" )
Relay Network Types
const ( HTTP = "HTTP" HTTPS = "https" TCP = "tcp" UNIX = "unix" )
Known protocol types.
const ( KUBECTLDILAIN = "kubectldialin" KUBEWEBDIALIN = "kubewebdialin" PEERKEY = "04112005676520746869732070617373776f726420746f206120736563726574" )
Known dialin types
const ( //HeaderError .. HeaderError = "X-Error" //HeaderAction ... HeaderAction = "X-Action" //HeaderForwardedHost .. HeaderForwardedHost = "X-Forwarded-Host" //HeaderForwardedService .. HeaderForwardedService = "X-Forwarded-Service" //HeaderParalusUserName .. HeaderParalusUserName = "X-Paralus-User" //HeaderParalusNamespace .. HeaderParalusNamespace = "X-Paralus-Namespace" //HeaderParalusScope .. HeaderParalusScope = "X-Paralus-Scope" //HeaderParalusAllow .. HeaderParalusAllow = "X-Paralus-Allow" //HeaderParalusAuthZSA yaml contains service account HeaderParalusAuthZSA = "X-Paralus-AuthzSA" //HeaderParalusAuthZRole yaml contains role HeaderParalusAuthZRole = "X-Paralus-AuthzRole" //HeaderParalusAuthZRoleBinding yaml contains rolebinding HeaderParalusAuthZRoleBinding = "X-Paralus-AuthzRoleBinding" //HeaderParalusServiceAccountNoExpire don't expire service account HeaderParalusServiceAccountNoExpire = "X-Paralus-ServiceAccount-NoExpire" //HeaderClearSecret to clear the current secret cache of user HeaderClearSecret = "X-Paralus-Clear-Cache" )
const ( ActionProxy = "proxy" // DefaultAuditPolicyPath default audit policy filter path // k8s audit need a file path DefaultAuditPolicyPath = "./relayaudit.yaml" //DefaultAuditPath defailt audit log files path DefaultAuditPath = "-" // - means standard out //ParalusRelayServiceAccountNameSpace namespace used to create service account for relays ParalusRelayServiceAccountNameSpace = "system-sa" )
Known actions.
Variables ¶
var ( // LogLevel loglevel set from commadline LogLevel int // Mode relay/relay-agent Mode string // ClusterID unique id of the cluster ClusterID string // AgentID unique id for cd agent AgentID string // ExitChan trigger this channel to exit ExitChan = make(chan bool) // TerminateChan trigger this channel to exit TerminateChan = make(chan bool) // IdleTimeout is the maximum amount of time to wait for the // next read/write before closing connection. IdleTimeout = 5 * time.Minute // DefaultTimeout specifies a general purpose timeout. DefaultTimeout = 5 * time.Minute // DefaultPingTimeout specifies a ping timeout. DefaultPingTimeout = 5 * time.Second // DefaultKeepAliveIdleTime specifies how long connection can be idle // before sending keepalive message. DefaultKeepAliveIdleTime = 15 * time.Second // DefaultKeepAliveCount specifies maximal number of keepalive messages // sent before marking connection as dead. DefaultKeepAliveCount = 3 // DefaultKeepAliveInterval specifies how often retry sending keepalive // messages when no response is received. DefaultKeepAliveInterval = 5 * time.Second //DefaultMuxTimeout specifies vmux timeout DefaultMuxTimeout = 10 * time.Second //UNIXSOCKET prefix path for unix socket UNIXSOCKET = "/tmp/relay-unix-" // need to change this from tmp to appropriate path after integration //UNIXAGENTSOCKET prefix path for unix socket UNIXAGENTSOCKET = "/tmp/relay-agent-unix-" // need to change this from tmp to appropriate path after integration //ProxyProtocolSize Default PROXY PROTO buffer size ProxyProtocolSize = 1024 //RelayUUID runtime Unique ID for relay RelayUUID string //RelayIPFromConfig IP address of the relay for peering RelayIPFromConfig string //PeerCache stores peer dialin info PeerCache *ristretto.Cache //ServiceAccountCache stores service account, role, role binding in relay-agetn in connector ServiceAccountCache *ristretto.Cache //ServiceAccountCacheDefaultExpiry default expiry ServiceAccountCacheDefaultExpiry = 600 * time.Second //PeerCacheDefaultExpiry default expiry PeerCacheDefaultExpiry = 600 * time.Second //PeerHelloInterval heartbeat interval PeerHelloInterval = 60 * time.Second //PeerServiceURI is the URI to join peering service PeerServiceURI string //PeerCertificate used for peering service communication PeerCertificate []byte //PeerPrivateKey used for peering service communication PeerPrivateKey []byte //PeerCACertificate used for peering service communication PeerCACertificate []byte //RelayUserCert used for user/peer communication RelayUserCert []byte //RelayUserKey used for user/peer communication RelayUserKey []byte //RelayUserCACert used for user/peer communication RelayUserCACert []byte //RelayUserPort user facing seerver port RelayUserPort int32 // RelayUserHost user facing seerver host (domain) RelayUserHost string //RelayConnectorCert used for relay-connector termination RelayConnectorCert []byte //RelayConnectorKey used for relay-connector termination RelayConnectorKey []byte //RelayConnectorCACert used for relay-connector termination RelayConnectorCACert []byte // RelayConnectorHost connector facing server host (domain) RelayConnectorHost string // RelayConnectorPort connector facing server port RelayConnectorPort int32 // CDRelayUserCert used for client/peer communication CDRelayUserCert []byte // CDRelayUserKey used for client/peer communication CDRelayUserKey []byte // CDRelayUserCACert used for client/peer communication CDRelayUserCACert []byte // CDRelayUserHost client facing server host CDRelayUserHost string // CDRelayUserPort client facing server port CDRelayUserPort int // CDRelayConnectorCert used for cd-relay-connector termination CDRelayConnectorCert []byte // CDRelayConnectorKey used for cd-relay-connector termination CDRelayConnectorKey []byte // CDRelayConnectorCACert used for cd-relay-connector termination CDRelayConnectorCACert []byte // CDRelayConnectorHost connector facing server host (domain) CDRelayConnectorHost string // CDRelayConnectorPort connector facing server port CDRelayConnectorPort int //RelayNetworks list of relaynemtworks from configmap RelayNetworks []Relaynetwork // RelayAgentConfig map of relay agent configurations RelayAgentConfig map[string]RelayNetworkConfig // MaxDials max connections dialed MaxDials = 10 // MinDials minimum connections dialed MinDials = 8 //PODNAME name of the pod PODNAME string // DialoutProxy setting used while connecting to relay IP:PORT or HOST:PORT format DialoutProxy = "" // DialoutProxyAuth Proxy-Authorization header base64 encoded value of user:password DialoutProxyAuth = "" // DefaultTCPUpstream default TCP upstream DefaultTCPUpstream = "127.0.0.1:16001" // ScalingStreamsThreshold concurrent streams count to trigger scaling ScalingStreamsThreshold = 400 // ScalingStreamsRateThreshold new streams rate to trigger scaling ScalingStreamsRateThreshold = 200 // MaxScaleMultiplier multiplier to limit max scaled connections MaxScaleMultiplier = 3 // HealingInterval time to close idle scaled connection HealingInterval = 24 // Hour )
Functions ¶
func CheckPeerHeaders ¶
CheckPeerHeaders validates upstreams request
func CheckRelayLoops ¶
CheckRelayLoops :does XRAY UUDI already present in header?
func DeleteCache ¶
DeleteCache delete value from cache
func GetRelayIPPort ¶
func GetRelayIPPort() string
GetRelayIPPort get relay IP:PORT of user facing server
func InitCache ¶
InitCache initialize the cache to store dialin cluster-connection information of peers. When a dialin miss happens look into this cache to find the peer IP address to forward the user connection.
func InsertCache ¶
InsertCache inserts the value to cache
func SanitizeValues ¶ added in v0.1.1
func SetXForwardedFor ¶
SetXForwardedFor ...
func SetXForwardedParalus ¶
func SetXForwardedParalus(h http.Header, msg *ControlMessage)
SetXForwardedParalus set paralus headers
func SplitHostPort ¶
SplitHostPort separates host and port. If the port is not valid, it returns the entire input as host, and it doesn't check the validity of the host.
func UnSetXForwardedParalus ¶
UnSetXForwardedParalus set paralus headers
func WriteToHeader ¶
func WriteToHeader(h http.Header, c *ControlMessage)
WriteToHeader writes ControlMessage to HTTP header.
Types ¶
type ControlMessage ¶
type ControlMessage struct { Action string ForwardedHost string ForwardedService string RemoteAddr string ParalusUserName string ParalusNamespace string ParalusScope string ParalusAllow string ParalusAuthz string }
ControlMessage is sent from server to client before streaming data. It's used to inform client about the data and action to take. Based on that client routes requests to backend services.
func ReadControlMessage ¶
func ReadControlMessage(r *http.Request) (*ControlMessage, error)
ReadControlMessage reads ControlMessage from HTTP headers.
type CountWriter ¶
CountWriter to measure bytes
type FlushWriter ¶
FlushWriter flush writer
type ProxyConfig ¶
type ProxyConfig struct { Protocol string Addr string ServiceSNI string RootCA string ClientCRT string ClientKEY string Upstream string UpstreamClientCRT string UpstreamClientKEY string UpstreamRootCA string UpstreamSkipVerify bool UpstreamKubeConfig string Version string }
ProxyConfig configs for the proxy
type ProxyProtocolMessage ¶
ProxyProtocolMessage used across dialin unix socket
type RelayNetworkConfig ¶
type RelayNetworkConfig struct { // Network configmap Network Relaynetwork // RelayAgentCert used for relay-agent client cert RelayAgentCert []byte // RelayAgentKey used for relay-agent client cert RelayAgentKey []byte // RelayAgentCACert used for relay-agent client cert RelayAgentCACert []byte }
RelayNetworkConfig config for relay agent
type Relaynetwork ¶
type Relaynetwork struct { Token string `json:"token"` // bootstrap agent token Addr string `json:"addr"` // bootstrap register host Domain string `json:"endpoint"` // dialout domain Name string `json:"name"` // network name TemplateToken string `json:"templateToken"` // bootstrap template token Upstream string `json:"upstream"` // upstream tcp service host:port }
Relaynetwork configmap data
type SNICertificate ¶
SNICertificate sni based certs