// NewChecker creates a new policy checker.
763423
func NewChecker(policy *audit.Policy) Checker {
	for i, rule := range policy.Rules {
		policy.Rules[i].OmitStages = unionStages(policy.OmitStages, rule.OmitStages)
	}
	return &policyChecker{*policy}
}
1084308
func NewPolicyChecker(channelPolicyManagerGetter policies.ChannelPolicyManagerGetter, localMSP msp.IdentityDeserializer, principalGetter mgmt.MSPPrincipalGetter) PolicyChecker {
	return &policyChecker{channelPolicyManagerGetter, localMSP, principalGetter}
}
132774
func NewEnforcer(rules map[string]string) (*Enforcer, error) {
	p := Enforcer{
		rules:  make(map[string]rule, len(rules)),
		checks: make(map[string]Check, 4),
	}
	p.AddCheck("rule", RuleCheck)
	p.AddCheck("role", RoleCheck)
	p.AddCheck("http", HTTPCheck)
	p.AddCheck("default", DefaultCheck)

	for name, str := range rules {
		lexer := newLexer(str)
		if yyParse(lexer) != 0 {
			return nil, fmt.Errorf("Failed to parse rule %s: %s", name, lexer.parseResult.(string))
		}
		p.rules[name] = lexer.parseResult.(rule)
	}
	return &p, nil
}
1032365
func (s *Server) newCheckServiceNodeSorter(cs lib.CoordinateSet, nodes structs.CheckServiceNodes) (sort.Interface, error) {
	state := s.fsm.State()
	vec := make([]float64, len(nodes))
	for i, node := range nodes {
		_, other, err := state.Coordinate(node.Node.Node, nil)
		if err != nil {
			return nil, err
		}
		c1, c2 := cs.Intersect(other)
		vec[i] = lib.ComputeDistance(c1, c2)
	}
	return &checkServiceNodeSorter{nodes, vec}, nil
}
696920
func New(certFile, keyFile string, d time.Duration) *TLSHealthChecker {
	c, err := tls.LoadX509KeyPair(certFile, keyFile)
	if err != nil {
		return &TLSHealthChecker{cert: nil}
	}
	if len(c.Certificate) > 0 {
		c1, _ := x509.ParseCertificate(c.Certificate[0])
		return &TLSHealthChecker{cert: c1, dur: d}
	}
	return &TLSHealthChecker{cert: nil}
}
1343142
func (in *Influx) NewCounter(name string) *Counter {
	return &Counter{
		name: name,
		obs:  in.counters.Observe,
	}
}
434163
func NewHealthCheck() http.Handler {
	return api.HTTPHandler{
		Handler: api.HandlerFunc(healthHandler),
		Methods: []string{"GET"},
	}
}
618024
func NewCheck(notify chan<- *Notification) *Check {
	return &Check{
		state:  StateUnknown,
		notify: notify,
		update: make(chan Config, 1),
		quit:   make(chan bool, 1),
	}
}
139427
func New(url string) KeyChecker {
	return &keyCheckV1{
		target: url,
		client: new(http.Client),
	}
}
872279
func NewMockLogger(ctrl *gomock.Controller) *MockLogger {
	mock := &MockLogger{ctrl: ctrl}
	mock.recorder = &MockLoggerMockRecorder{mock}
	return mock
}
890767
func NewProveCheck(g *libkb.GlobalContext, sigID keybase1.SigID) *ProveCheck {
	return &ProveCheck{
		Contextified: libkb.NewContextified(g),
		sigID:        sigID,
	}
}
715720
func NewChecker(trustedIPs []string) (*Checker, error) {
	if len(trustedIPs) == 0 {
		return nil, errors.New("no trusted IPs provided")
	}

	checker := &Checker{}

	for _, ipMask := range trustedIPs {
		if ipAddr := net.ParseIP(ipMask); ipAddr != nil {
			checker.authorizedIPs = append(checker.authorizedIPs, &ipAddr)
		} else {
			_, ipAddr, err := net.ParseCIDR(ipMask)
			if err != nil {
				return nil, fmt.Errorf("parsing CIDR trusted IPs %s: %v", ipAddr, err)
			}
			checker.authorizedIPsNet = append(checker.authorizedIPsNet, ipAddr)
		}
	}

	return checker, nil
}
380940
func NewFlagCheckOption(flag bool) Option {
	return &option{optionType: flagCheckOption, value: NewFlagCheckFilter(flag)}
}
666186
func New(defaultConfPath, liveConfPath string, portChecker checker) *Resetter {
	return &Resetter{
		defaultConfPath: defaultConfPath,
		liveConfPath:    liveConfPath,
		portChecker:     portChecker,
		timeout:         time.Second * 30,
		Monit:           monit.New(),
		redis:           redis.New(),
	}
}
1082915
func NewChannelVerifier(policy string, polMgr policies.ChannelPolicyManagerGetter) *ChannelVerifier {
	return &ChannelVerifier{
		Policy:                     policy,
		ChannelPolicyManagerGetter: polMgr,
	}
}
493845
func NewConstraintChecker(ctx Context, constraints []*structs.Constraint) *ConstraintChecker {
	return &ConstraintChecker{
		ctx:         ctx,
		constraints: constraints,
	}
}
146880
func NewWatcher() (*Watcher, error) {
	kq, err := kqueue()
	if err != nil {
		return nil, err
	}

	w := &Watcher{
		kq:              kq,
		watches:         make(map[string]int),
		dirFlags:        make(map[string]uint32),
		paths:           make(map[int]pathInfo),
		fileExists:      make(map[string]bool),
		externalWatches: make(map[string]bool),
		Events:          make(chan Event),
		Errors:          make(chan error),
		done:            make(chan struct{}),
	}

	go w.readEvents()
	return w, nil
}