policy

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 1 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// ProtocolTcp indicates tcp protocol id for portmapping
	ProtocolTcp = 6

	// ProtocolUdp indicates udp protocol id for portmapping
	ProtocolUdp = 17

	// CnetAddressSpace indicates constant for the key string
	CnetAddressSpace = "cnetAddressSpace"
)

Variables

View Source
var ValidWinVerForDnsNat bool

Functions

func AddDnsNATPolicyV1

func AddDnsNATPolicyV1() (json.RawMessage, error)

AddDnsNATPolicyV1 returns serialized DNS NAT policy (json) for HNSv1

func AddNATPolicyV2

func AddNATPolicyV2(vip string, destinations []string) (hcn.EndpointPolicy, error)

AddNATPolicyV2 returns serialized endpoint policy based on vip (IP to snat to) and destination(s)

func GetHcnACLPolicy

func GetHcnACLPolicy(policy Policy) (hcn.EndpointPolicy, error)

GetHcnACLPolicy returns ACL policy.

func GetHcnEndpointPolicies

func GetHcnEndpointPolicies(policyType CNIPolicyType, policies []Policy, epInfoData map[string]interface{}, enableSnatForDns, enableMultiTenancy bool, natInfo []NATInfo) ([]hcn.EndpointPolicy, error)

GetHcnEndpointPolicies returns array of all endpoint policies.

func GetHcnL4WFPProxyPolicy

func GetHcnL4WFPProxyPolicy(policy Policy) (hcn.EndpointPolicy, error)

GetHcnL4WFPProxyPolicy returns L4WFPProxy policy.

func GetHcnLoopbackDSRPolicy

func GetHcnLoopbackDSRPolicy(policy Policy) (hcn.EndpointPolicy, error)

GetHcnLoopbackDSRPolicy policy is for pod to reach itself by cluster service IP.

func GetHcnNetAdapterPolicy

func GetHcnNetAdapterPolicy(networkAdapterName string) (hcn.NetworkPolicy, error)

GetHcnNetAdapterPolicy returns network adapter name policy.

func GetHcnOutBoundNATPolicy

func GetHcnOutBoundNATPolicy(policy Policy, epInfoData map[string]interface{}) (hcn.EndpointPolicy, error)

GetHcnOutBoundNATPolicy returns outBoundNAT policy.

func GetHcnPortMappingPolicy

func GetHcnPortMappingPolicy(policy Policy) (hcn.EndpointPolicy, error)

GetHcnPortMappingPolicy returns port mapping policy.

func GetHcnRoutePolicy

func GetHcnRoutePolicy(policy Policy) (hcn.EndpointPolicy, error)

GetHcnRoutePolicy returns Route policy.

func GetOutBoundNatExceptionList

func GetOutBoundNatExceptionList(policy Policy) ([]string, error)

GetOutBoundNatExceptionList returns exception list for outbound nat policy

func SerializeHcnSubnetVlanPolicy

func SerializeHcnSubnetVlanPolicy(vlanID uint32) ([]byte, error)

SerializeHcnSubnetVlanPolicy serializes subnet policy for VLAN to json.

func SerializeLoopbackDSRPolicy

func SerializeLoopbackDSRPolicy(policy Policy) (json.RawMessage, error)

func SerializeNATPolicy

func SerializeNATPolicy(policy Policy) (json.RawMessage, error)

func SerializeOutBoundNATPolicy

func SerializeOutBoundNATPolicy(policy Policy, epInfoData map[string]interface{}) (json.RawMessage, error)

SerializeOutBoundNATPolicy formulates OutBoundNAT policy and returns serialized json

func SerializePolicies

func SerializePolicies(policyType CNIPolicyType, policies []Policy, epInfoData map[string]interface{}, enableSnatForDns, enableMultiTenancy bool) []json.RawMessage

SerializePolicies serializes policies to json.

Types

type CNIPolicyType

type CNIPolicyType string
const (
	NetworkPolicy     CNIPolicyType = "NetworkPolicy"
	EndpointPolicy    CNIPolicyType = "EndpointPolicy"
	OutBoundNatPolicy CNIPolicyType = "OutBoundNAT"
	RoutePolicy       CNIPolicyType = "ROUTE"
	PortMappingPolicy CNIPolicyType = "NAT"
	ACLPolicy         CNIPolicyType = "ACL"
	L4WFPProxyPolicy  CNIPolicyType = "L4WFPPROXY"
	LoopbackDSRPolicy CNIPolicyType = "LoopbackDSR"
)

func GetPolicyType

func GetPolicyType(policy Policy) CNIPolicyType

GetPolicyType parses the policy and returns the policy type

type KVPairL4WfpProxyPolicy

type KVPairL4WfpProxyPolicy struct {
	Type               CNIPolicyType   `json:"Type"`
	OutboundProxyPort  string          `json:"OutboundProxyPort"`
	InboundProxyPort   string          `json:"InboundProxyPort"`
	UserSID            string          `json:"UserSID"`
	FilterTuple        json.RawMessage `json:"FilterTuple"`
	InboundExceptions  json.RawMessage `json:"InboundExceptions"`
	OutboundExceptions json.RawMessage `json:"OutboundExceptions"`
}

type KVPairOutBoundNAT

type KVPairOutBoundNAT struct {
	Type          CNIPolicyType   `json:"Type"`
	ExceptionList json.RawMessage `json:"ExceptionList"`
}

type KVPairRoute

type KVPairRoute struct {
	Type              CNIPolicyType `json:"Type"`
	DestinationPrefix string        `json:"DestinationPrefix"`
	NeedEncap         bool          `json:"NeedEncap"`
}

type KVPairRoutePolicy

type KVPairRoutePolicy struct {
	Type              CNIPolicyType   `json:"Type"`
	DestinationPrefix json.RawMessage `json:"DestinationPrefix"`
	NeedEncap         json.RawMessage `json:"NeedEncap"`
}

type LoopbackDSR

type LoopbackDSR struct {
	Type      CNIPolicyType `json:"Type"`
	IPAddress net.IP        `json:"IPAddress"`
}

type NATInfo

type NATInfo struct {
	Destinations []string
	VirtualIP    string
}

NATInfo contains information about NAT rules

type Policy

type Policy struct {
	Type CNIPolicyType
	Data json.RawMessage
}

Jump to

Keyboard shortcuts

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