func MatchesFromFilterRules(pf []tailcfg.FilterRule) ([]Match, error) {
	mm := make([]Match, 0, len(pf))
	var erracc error

	for _, r := range pf {
		m := Match{}

		for i, s := range r.SrcIPs {
			bits := 32
			if len(r.SrcBits) > i {
				bits = r.SrcBits[i]
			}
			net, err := parseIP(s, bits)
			if err != nil && erracc == nil {
				erracc = err
				continue
			}
			m.Srcs = append(m.Srcs, net)
		}

		for _, d := range r.DstPorts {
			bits := 32
			if d.Bits != nil {
				bits = *d.Bits
			}
			net, err := parseIP(d.IP, bits)
			if err != nil && erracc == nil {
				erracc = err
				continue
			}
			m.Dsts = append(m.Dsts, NetPortRange{
				Net: net,
				Ports: PortRange{
					First: d.Ports.First,
					Last:  d.Ports.Last,
				},
			})
		}

		mm = append(mm, m)
	}
	return mm, erracc
}
// MatchesFromFilterRules converts tailcfg FilterRules into Matches.
// If an error is returned, the Matches result is still valid,
// containing the rules that were successfully converted.
MatchesFromFilterRules converts tailcfg FilterRules into Matches.
If an error is returned, the Matches result is still valid,
containing the rules that were successfully converted.
// MatchesFromFilterRules converts tailcfg FilterRules into Matches . // If an error is returned the Matches result is still valid // containing the rules that were successfully converted .
func MatchesFromFilterRules(pf []tailcfg.FilterRule) ([]Match, error) {
	mm := make([]Match, 0, len(pf))
	var erracc error
	for _, r := range pf {
		m := Match{}
		for i, s := range r.SrcIPs {
			bits := 32
			if len(r.SrcBits) > i {
				bits = r.SrcBits[i]
			}
			net, err := parseIP(s, bits)
			if err != nil && erracc == nil {
				erracc = err
				continue
			}
			m.Srcs = append(m.Srcs, net)
		}
		for _, d := range r.DstPorts {
			bits := 32
			if d.Bits != nil {
				bits = *d.Bits
			}
			net, err := parseIP(d.IP, bits)
			if err != nil && erracc == nil {
				erracc = err
				continue
			}
			m.Dsts = append(m.Dsts, NetPortRange{
				Net: net,
				Ports: PortRange{
					First: d.Ports.First,
					Last:  d.Ports.Last,
				},
			})
		}
		mm = append(mm, m)
	}
	return mm, erracc
}
func MatchesFromFilterRules ( pf [ ] tailcfg . FilterRule ) ( [ ] Match , error ) { mm := make ( [ ] Match , 0 , len ( pf ) ) var erracc error for _ , r := range pf { m := Match { } for i , s := range r . SrcIPs { bits := 32 if len ( r . SrcBits ) > i { bits = r . SrcBits [ i ] } net , err := parseIP ( s , bits ) if err != nil && erracc == nil { erracc = err continue } m . Srcs = append ( m . Srcs , net ) } for _ , d := range r . DstPorts { bits := 32 if d . Bits != nil { bits = * d . Bits } net , err := parseIP ( d . IP , bits ) if err != nil && erracc == nil { erracc = err continue } m . Dsts = append ( m . Dsts , NetPortRange { Net : net , Ports : PortRange { First : d . Ports . First , Last : d . Ports . Last , } , } ) } mm = append ( mm , m ) } return mm , erracc }
MatchesFromFilterRules converts tailcfg FilterRules into Matches.
MatchesFromFilterRules converts tailcfg FilterRules into Matches .