@@ -37,6 +37,16 @@ type KVPairRoute struct {
3737 NeedEncap bool `json:"NeedEncap"`
3838}
3939
40+ type KVPairL4WfpProxyPolicy struct {
41+ Type CNIPolicyType `json:"Type"`
42+ OutboundProxyPort string `json:"OutboundProxyPort"`
43+ InboundProxyPort string `json:"InboundProxyPort"`
44+ UserSID string `json:"UserSID"`
45+ FilterTuple json.RawMessage `json:"FilterTuple"`
46+ InboundExceptions json.RawMessage `json:"InboundExceptions"`
47+ OutboundExceptions json.RawMessage `json:"OutboundExceptions"`
48+ }
49+
4050var ValidWinVerForDnsNat bool
4151
4252// SerializePolicies serializes policies to json.
@@ -206,6 +216,14 @@ func GetPolicyType(policy Policy) CNIPolicyType {
206216 }
207217 }
208218
219+ // Check if the type is L4WFPProxy
220+ var l4WfpProxyPolicy KVPairL4WfpProxyPolicy
221+ if err := json .Unmarshal (policy .Data , & l4WfpProxyPolicy ); err == nil {
222+ if l4WfpProxyPolicy .Type == L4WFPProxyPolicy {
223+ return L4WFPProxyPolicy
224+ }
225+ }
226+
209227 // Check if the type if Port mapping / NAT
210228 var dataPortMapping hcn.EndpointPolicy
211229 if err := json .Unmarshal (policy .Data , & dataPortMapping ); err == nil {
@@ -386,6 +404,28 @@ func GetHcnACLPolicy(policy Policy) (hcn.EndpointPolicy, error) {
386404 return aclEndpolicySetting , nil
387405}
388406
407+ // GetHcnL4WFPProxyPolicy returns L4WFPProxy policy.
408+ func GetHcnL4WFPProxyPolicy (policy Policy ) (hcn.EndpointPolicy , error ) {
409+ l4WfpEndpolicySetting := hcn.EndpointPolicy {
410+ Type : hcn .L4WFPPROXY ,
411+ }
412+
413+ // Check beforehand, the input meets the expected format
414+ // otherwise, endpoint creation will fail later on.
415+ var l4WfpProxyPolicySetting hcn.L4WfpProxyPolicySetting
416+ if err := json .Unmarshal (policy .Data , & l4WfpProxyPolicySetting ); err != nil {
417+ return l4WfpEndpolicySetting , err
418+ }
419+
420+ l4WfpProxyPolicySettingBytes , err := json .Marshal (l4WfpProxyPolicySetting )
421+ if err != nil {
422+ return l4WfpEndpolicySetting , err
423+ }
424+
425+ l4WfpEndpolicySetting .Settings = l4WfpProxyPolicySettingBytes
426+ return l4WfpEndpolicySetting , nil
427+ }
428+
389429// GetHcnEndpointPolicies returns array of all endpoint policies.
390430func GetHcnEndpointPolicies (policyType CNIPolicyType , policies []Policy , epInfoData map [string ]interface {}, enableSnatForDns , enableMultiTenancy bool ) ([]hcn.EndpointPolicy , error ) {
391431 var (
@@ -408,6 +448,8 @@ func GetHcnEndpointPolicies(policyType CNIPolicyType, policies []Policy, epInfoD
408448 endpointPolicy , err = GetHcnPortMappingPolicy (policy )
409449 case ACLPolicy :
410450 endpointPolicy , err = GetHcnACLPolicy (policy )
451+ case L4WFPProxyPolicy :
452+ endpointPolicy , err = GetHcnL4WFPProxyPolicy (policy )
411453 default :
412454 // return error as we should be able to parse all the policies specified
413455 return hcnEndPointPolicies , fmt .Errorf ("Failed to set Policy: Type: %s, Data: %s" , policy .Type , policy .Data )
0 commit comments