Files
zt/router/posture/mac.go
Andrew MartinezandGitHub bb5cc51a97 adds posture cache, instance, instance data, and event hooks (#3267)
* adds posture cache, instance, instance data, and event hooks

- reworks router security
- abstracts api session and service sessions
- use connection tracker instead of various maps
- doc
- adds service sessions as always JWTs
- addes token logging fields
- removes multiple connection tracking fields
- adds support for router specific posture data/respones
- adds support for router posture check evaluation
- defer dial/bind posture checking for legacy to controller
- fix double session event emitting
- fix session event missing id
2025-10-15 14:01:56 -04:00

48 lines
944 B
Go

package posture
import (
"github.com/openziti/ziti/common/pb/edge_ctrl_pb"
)
type MacCheck struct {
*edge_ctrl_pb.DataState_PostureCheck
*edge_ctrl_pb.DataState_PostureCheck_Mac
}
func (m MacCheck) Evaluate(state *InstanceData) *CheckError {
if state == nil {
return &CheckError{
Id: m.Id,
Name: m.Name,
Cause: NilStateError,
}
}
notInListErr := &OneInListError[Str]{}
macMap := map[string]struct{}{}
for _, macAddresses := range state.Macs.Addresses {
macMap[macAddresses] = struct{}{}
}
for _, macAddress := range m.MacAddresses {
if _, ok := macMap[macAddress]; ok {
return nil
}
}
for _, mac := range m.MacAddresses {
notInListErr.ValidValues = append(notInListErr.ValidValues, Str(mac))
}
for _, mac := range state.Macs.Addresses {
notInListErr.GivenValues = append(notInListErr.GivenValues, Str(mac))
}
return &CheckError{
Id: m.Id,
Name: m.Name,
Cause: notInListErr,
}
}